Skip to content

Commit

Permalink
annotate VersionStruktur property with AutoNumberToStringConverter (
Browse files Browse the repository at this point in the history
#555)

* annotate `VersionStruktur` property with `AutoNumberToStringConverter`

* add test

---------

Co-authored-by: Konstantin <[email protected]>
  • Loading branch information
hf-kklein and Konstantin authored Nov 7, 2024
1 parent 2b0171c commit 001f371
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions BO4E/BO/BusinessObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Text.Json.Serialization;
using BO4E.COM;
using BO4E.meta;
using BO4E.meta.LenientConverters;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Schema;
Expand Down Expand Up @@ -147,6 +148,7 @@ public string? BoTyp
[JsonPropertyName("versionStruktur")]
[JsonPropertyOrder(2)]
[ProtoMember(2)]
[System.Text.Json.Serialization.JsonConverter(typeof(AutoNumberToStringConverter))]
public string? VersionStruktur { get; set; }

/// <summary>
Expand Down
10 changes: 10 additions & 0 deletions BO4ETestProject/TestAutoNumberConverter.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.IO;
using BO4E.BO;
using BO4E.meta.LenientConverters;
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using JsonSerializer = System.Text.Json.JsonSerializer;

Expand All @@ -23,4 +24,13 @@ public void TestConverter()
var vertrag = JsonSerializer.Deserialize<Vertrag>(jsonString, options);
Assert.IsNotNull(vertrag);
}

[TestMethod]
[DataRow("{\"versionStruktur\": \"12\"}")]
[DataRow("{\"versionStruktur\": 12}")]
public void Test_Annotation_STJ(string jsonString)
{
var malo = System.Text.Json.JsonSerializer.Deserialize<Marktlokation>(jsonString);
malo.Should().NotBeNull().And.Subject.As<Marktlokation>().VersionStruktur.Should().Be("12");
}
}

0 comments on commit 001f371

Please sign in to comment.