-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test (which doesn't really cover the case we're interested in)
anonymize
- Loading branch information
Showing
4 changed files
with
109 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
using BO4E.BO; | ||
using BO4E.meta.LenientConverters; | ||
using FluentAssertions; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Converters; | ||
using JsonConverter = Newtonsoft.Json.JsonConverter; | ||
using JsonSerializer = System.Text.Json.JsonSerializer; | ||
|
||
namespace TestBO4E | ||
{ | ||
[TestClass] | ||
public class TestVerwendungszweckeDeserialization | ||
{ | ||
private void _TestVerwendungszweckeDeserialization(Func<Marktlokation, string> serializer, Func<string, Marktlokation> deserializer) | ||
{ | ||
var jsonString = File.ReadAllText("testjsons/marktlokation_with_verwendungszwecke.json"); | ||
var malo = deserializer(jsonString); | ||
malo.Should().NotBeNull(); | ||
malo.Zaehlwerke.Single().Verwendungszwecke.Should().NotBeEmpty(); | ||
} | ||
|
||
[TestMethod] | ||
public void TestVerwendunszweckDeserializationNewtonsoft() | ||
{ | ||
var settings = new JsonSerializerSettings | ||
{ | ||
Converters = new List<JsonConverter> { new VerwendungszweckJsonNetConverter(), new StringEnumConverter() } | ||
}; | ||
_TestVerwendungszweckeDeserialization(_malo => JsonConvert.SerializeObject(_malo, settings), str => JsonConvert.DeserializeObject<Marktlokation>(str, settings)); | ||
} | ||
|
||
[TestMethod] | ||
public void TestVerwendunszweckDeserializationSystemText() | ||
{ | ||
var jsonOptions = new JsonSerializerOptions | ||
{ | ||
Converters = { new JsonStringEnumConverter(), new VerwendungszweckJsonConverter() } | ||
}; | ||
_TestVerwendungszweckeDeserialization(_malo => JsonSerializer.Serialize(_malo, jsonOptions), str => JsonSerializer.Deserialize<Marktlokation>(str, jsonOptions)); | ||
} | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
BO4ETestProject/testjsons/marktlokation_with_verwendungszwecke.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{ | ||
"boTyp": "MARKTLOKATION", | ||
"versionStruktur": "1", | ||
"marktlokationsId": "VerwendungszweckJsonConverter", | ||
"sparte": "STROM", | ||
"energierichtung": "AUSSP", | ||
"netzebene": "NSP", | ||
"bilanzierungsgebiet": "11YN10000762-01E", | ||
"lokationsadresse": { | ||
"postleitzahl": "12345", | ||
"ort": "Teststadt", | ||
"strasse": "Teststr.", | ||
"hausnummer": "6B", | ||
"landescode": "DE", | ||
"ortsteil": "Blub" | ||
}, | ||
"marktrollen": [ | ||
{ | ||
"code": "4033872000058", | ||
"marktrolle": "UENB" | ||
}, | ||
{ | ||
"code": "9906214000003", | ||
"marktrolle": "MSB", | ||
"weiterverpflichtet": false | ||
} | ||
], | ||
"regelzone": "10YDE-EON------1", | ||
"zeitreihentyp": "SLS", | ||
"zaehlwerke": [ | ||
{ | ||
"obisKennzahl": "1-1:1.9.0", | ||
"verwendungszwecke": [ | ||
{ | ||
"marktrolle": "LF", | ||
"zweck": [ | ||
"ENDKUNDENABRECHNUNG", | ||
"NETZNUTZUNGSABRECHNUNG", | ||
"MEHRMINDERMENGENABRECHNUNG" | ||
] | ||
} | ||
], | ||
"verbrauchsart": "KL", | ||
"unterbrechbarkeit": "NUV", | ||
"anzahlAblesungen": 1 | ||
} | ||
] | ||
} |