Skip to content

Commit

Permalink
test: Add Test that shows WASSER_MSZW is not a problem
Browse files Browse the repository at this point in the history
  • Loading branch information
hf-kklein committed Aug 26, 2024
1 parent c896b5a commit 4a3b5fb
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions BO4ETestProject/TestGeraetemerkmalConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class TestGeraeteerkmalDeserialization
{
private const string JsonString = "{\"merkmal\":\"G4\"}";
private const string JsonStringWithPeriod = "{\"merkmal\":\"G2Period5\"}";
private const string JsonStringWasser = "{\"merkmal\":\"WASSER_MWZW\"}";
internal class SomethingWithAGeraetemerkmal
{
[JsonProperty(PropertyName = "merkmal")] // system.text
Expand Down Expand Up @@ -62,11 +63,18 @@ public void TestNewtonsoft_Success_Nullable()
result.Merkmal.Should().Be(Geraetemerkmal.GAS_G4);
}

[TestMethod]
public void TestNewtonsoft_Success_Nullable_WASSER_MWZW()
{
var result = Newtonsoft.Json.JsonConvert.DeserializeObject<SomethingWithANullableGeraetemerkmal>(JsonString, new LenientGeraetemerkmalGasConverter());
result.Merkmal.Should().Be(Geraetemerkmal.GAS_G4);
}

[TestMethod]
public void TestNewtonsoft_Success_Nullable_GPointSomething()
{
var result = Newtonsoft.Json.JsonConvert.DeserializeObject<SomethingWithANullableGeraetemerkmal>(JsonStringWithPeriod, new LenientGeraetemerkmalGasConverter());
result.Merkmal.Should().Be(Geraetemerkmal.GAS_G2P5);
var result = Newtonsoft.Json.JsonConvert.DeserializeObject<SomethingWithANullableGeraetemerkmal>(JsonStringWasser, new LenientGeraetemerkmalGasConverter());
result.Merkmal.Should().Be(Geraetemerkmal.WASSER_MWZW);
}

[TestMethod]
Expand All @@ -80,6 +88,17 @@ public void TestSystemText_Success_NonNullable()
result.Merkmal.Should().Be(Geraetemerkmal.GAS_G4);
}

[TestMethod]
public void TestSystemText_Success_NonNullable_WASSER_MWZW()
{
var settings = new System.Text.Json.JsonSerializerOptions()
{
Converters = { new LenientSystemTextGeraetemerkmalGasConverter() }
};
var result = System.Text.Json.JsonSerializer.Deserialize<SomethingWithAGeraetemerkmal>(JsonStringWasser, settings);
result.Merkmal.Should().Be(Geraetemerkmal.WASSER_MWZW);
}

[TestMethod]
public void TestSystemText_Success_GPointSomething()
{
Expand Down

0 comments on commit 4a3b5fb

Please sign in to comment.