[#34] Second step of not using Bio as Attribute

This commit is contained in:
2024-02-20 16:36:12 +01:00
parent 049927f90c
commit c82e8de724
9 changed files with 140 additions and 77 deletions

View File

@ -8,7 +8,9 @@ namespace Tests.HelperTests {
public class BillingDataTest {
private static readonly JsonSerializerOptions JsonOpts = new() { WriteIndented = true };
private static readonly string[] Vaributes = ["GV", "GVD", "GVK", "GVS", "GVZ", "WR", "WRS", "ZW", "ZWS", "ZWZ"];
private static readonly RawVaribute[] Vaributes = [
new("GV/"), new("GV/D"), new("GV/K"), new("GV/S"), new("GV/Z"),
new("WR/"), new("WR/S"), new("ZW/"), new("ZW/S"), new("ZW/Z")];
private static (string, string?) GetSortIdAttrId(string bucket) {
return (bucket[..2], bucket.Length > 2 ? bucket[2..] : null);
@ -345,14 +347,7 @@ namespace Tests.HelperTests {
}
private static List<Varibute> GetSelection(IEnumerable<string> attVars) {
return attVars.Select(s => {
var sortid = s[..2];
var attrid = s.Length > 2 ? s[2..] : null;
return new Varibute(
new WineVar(sortid, sortid),
attrid == null ? null : new WineAttr(attrid, attrid)
);
}).ToList();
return attVars.Select(s => new Varibute(new RawVaribute(s))).ToList();
}
[Test]
@ -378,7 +373,7 @@ namespace Tests.HelperTests {
List<GraphEntry> entries = [
new GraphEntry(0, 4, new BillingData.Curve(BillingData.CurveMode.Oe, new() {
[73] = 0.5m
}, null), GetSelection(["GV"]))
}, null), GetSelection(["GV/"]))
];
var data = BillingData.FromGraphEntries(entries);
Assert.That(data.ToJsonString(JsonOpts), Is.EqualTo("""
@ -397,7 +392,7 @@ namespace Tests.HelperTests {
new GraphEntry(0, 4, new BillingData.Curve(BillingData.CurveMode.Oe, new() {
[73] = 0.5m,
[83] = 1.0m
}, null), GetSelection(["GV"]))
}, null), GetSelection(["GV/"]))
];
var data = BillingData.FromGraphEntries(entries);
Assert.That(data.ToJsonString(JsonOpts), Is.EqualTo("""
@ -425,10 +420,10 @@ namespace Tests.HelperTests {
new GraphEntry(0, 4, new BillingData.Curve(BillingData.CurveMode.Oe, new() {
[73] = 0.5m,
[84] = 1.0m
}, null), GetSelection(["GV", "ZW"])),
}, null), GetSelection(["GV/", "ZW/"])),
new GraphEntry(10, 4, new BillingData.Curve(BillingData.CurveMode.Oe, new() {
[73] = 0.75m,
}, null), GetSelection(["WR"]))
}, null), GetSelection(["WR/"]))
];
var data = BillingData.FromGraphEntries(entries);
Assert.That(data.ToJsonString(JsonOpts), Is.EqualTo("""
@ -459,14 +454,14 @@ namespace Tests.HelperTests {
new GraphEntry(0, 4, new BillingData.Curve(BillingData.CurveMode.Oe, new() {
[73] = 0.5m,
[84] = 1.0m
}, null), GetSelection(["GVB", "ZWB"])),
}, null), GetSelection(["GV/B", "ZW/B"])),
new GraphEntry(2, 4, new BillingData.Curve(BillingData.CurveMode.Oe, new() {
[73] = 0.75m,
}, null), GetSelection(["WR", "BL", "RR", "FV"])),
}, null), GetSelection(["WR/", "BL/", "RR/", "FV/"])),
new GraphEntry(4, 4, new BillingData.Curve(BillingData.CurveMode.Oe, new() {
[73] = 0.65m,
[84] = 1.2m
}, null), GetSelection(["BP", "SA"]))
}, null), GetSelection(["BP/", "SA/"]))
];
var data = BillingData.FromGraphEntries(entries);
Assert.That(data.ToJsonString(JsonOpts), Is.EqualTo("""