Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
FreddyFox892 committed Nov 25, 2024
1 parent 98b13e8 commit ebdfebb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
8 changes: 7 additions & 1 deletion BO4E/Marktkommunikation/ZeitabhaengigeBeziehung.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,17 @@ public class ZeitabhaengigeBeziehung

/// <summary>
/// exklusives Ende, hier darf nur das Mavimale Enddatum eingetragen werden, sofern bekannt. Anderen Falls ist das Feld null.
/// The maximum end date is NULL, this means DateTimeOffset.MaxValue is converted to null.
/// </summary>
[JsonPropertyName("gueltigBis")]
[JsonPropertyOrder(2)]
[Newtonsoft.Json.JsonProperty(PropertyName = "gueltigBis", Order = 2)]
public DateTimeOffset? GueltigBis { get; set; } = null;
public DateTimeOffset? GueltigBis
{
get => _infiniteTime;
set => _infiniteTime = (value == DateTimeOffset.MaxValue) ? null : value;
}
private DateTimeOffset? _infiniteTime;

/// <summary>
/// e.g.
Expand Down
20 changes: 20 additions & 0 deletions BO4ETestProject/TestLinkExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,24 @@ public void Test_Zeitabhaengig_To_Links_with_Null_Until()
actual.Should().ContainKey("x").WhoseValue.Should().HaveCount(2);
actual.Should().ContainKey("foo").WhoseValue.Should().HaveCount(2);
}

[TestMethod]
public void Test_inifinteTime_is_null()
{
ZeitabhaengigeBeziehung timeMax = new ZeitabhaengigeBeziehung()
{
ParentId = "x",
ChildId = "y",
GueltigVon = DateTimeOffset.MinValue,
GueltigBis = DateTimeOffset.MaxValue,
};
ZeitabhaengigeBeziehung nullTime = new ZeitabhaengigeBeziehung()
{
ParentId = "x",
ChildId = "y",
GueltigVon = DateTimeOffset.MinValue,
GueltigBis = null,
};
timeMax.Should().BeEquivalentTo(nullTime);
}
}

0 comments on commit ebdfebb

Please sign in to comment.