BillingData: Compact data even more

This commit is contained in:
2024-03-07 10:42:26 +01:00
parent b5d060aca6
commit ccd4a58007
2 changed files with 112 additions and 4 deletions

View File

@ -556,7 +556,7 @@ namespace Tests.HelperTests {
}
[Test]
public void TestWrite_06_Cultivation() {
public void TestWrite_06_Cultivation_1() {
List<GraphEntry> entries = [
new GraphEntry(0, 4, new BillingData.Curve(BillingData.CurveMode.Oe, new() {
[73] = 0.5m,
@ -604,7 +604,84 @@ namespace Tests.HelperTests {
}
[Test]
public void TestWrite_07_AttributeAndCultivation() {
public void TestWrite_07_Cultivation_2() {
List<GraphEntry> entries = [
new GraphEntry(0, 4, new BillingData.Curve(BillingData.CurveMode.Oe, new() {
[73] = 0.6m,
[84] = 1.0m
}, null), GetSelection(["GV/-", "GV/-B"])),
new GraphEntry(2, 4, new BillingData.Curve(BillingData.CurveMode.Oe, new() {
[73] = 0.75m,
}, null), GetSelection(["ZW/-", "ZW/-B"])),
new GraphEntry(2, 4, new BillingData.Curve(BillingData.CurveMode.Oe, new() {
[73] = 0.8m,
}, null), GetSelection(["BP/-", "BP/-B"])),
];
var data = BillingData.FromGraphEntries(entries);
Assert.That(data.ToJsonString(JsonOpts), Is.EqualTo("""
{
"mode": "elwig",
"version": 1,
"payment": {
"GV": "curve:1",
"ZW": 0.75,
"BP": 0.8
},
"curves": [
{
"id": 1,
"mode": "oe",
"data": {
"73oe": 0.6,
"84oe": 1
}
}
]
}
"""));
}
[Test]
public void TestWrite_08_Cultivation_3() {
List<GraphEntry> entries = [
new GraphEntry(0, 4, new BillingData.Curve(BillingData.CurveMode.Oe, new() {
[73] = 0.6m,
[84] = 1.0m
}, null), GetSelection(["GV/-", "GV/-B"])),
new GraphEntry(2, 4, new BillingData.Curve(BillingData.CurveMode.Oe, new() {
[73] = 0.75m,
}, null), GetSelection(["BP/-B", "ZW/-B", "FV/-B"])),
new GraphEntry(2, 4, new BillingData.Curve(BillingData.CurveMode.Oe, new() {
[73] = 0.8m,
}, null), GetSelection(["BP/-", "ZW/-", "FV/-", "WR/-", "BL/-"])),
];
var data = BillingData.FromGraphEntries(entries);
Assert.That(data.ToJsonString(JsonOpts), Is.EqualTo("""
{
"mode": "elwig",
"version": 1,
"payment": {
"default": 0.8,
"GV": "curve:1",
"GV-B": "curve:1",
"-B": 0.75
},
"curves": [
{
"id": 1,
"mode": "oe",
"data": {
"73oe": 0.6,
"84oe": 1
}
}
]
}
"""));
}
[Test]
public void TestWrite_09_AttributeAndCultivation() {
List<GraphEntry> entries = [
new GraphEntry(0, 4, new BillingData.Curve(BillingData.CurveMode.Oe, new() {
[73] = 0.75m,