Skip to content

Commit

Permalink
fix: tests for date/date-only changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
gkocak-scottlogic authored and ColinEberhardt committed Mar 29, 2023
1 parent f5f852b commit 04aaa1b
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions tests/FeaturesTests/Response.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,17 @@ public void CheckDateValueProperty(string propertyName, string expectedPropValue
{
var propInfo = _actual.Data.GetType().GetProperty(propertyName);
Assert.NotNull(propInfo);
Assert.Equal(DateTime.Parse(expectedPropValue).ToUniversalTime(), propInfo.GetValue(_actual.Data));
Assert.IsType<DateTime>(propInfo.GetValue(_actual.Data));
// Currently, we use DateTime type representation for both date and date-time.
// Until this behaviour changes, differentiate them on expected value and convert to DateOnly if necessary.
if (expectedPropValue.Contains("T"))
{
Assert.Equal(DateTime.Parse(expectedPropValue).ToUniversalTime(), propInfo.GetValue(_actual.Data));
}
else
{
Assert.Equal(DateOnly.Parse(expectedPropValue), DateOnly.FromDateTime(propInfo.GetValue(_actual.Data)));
}
}

[And(@"the response should be equal to (""[\w\s]+"")")]
Expand Down Expand Up @@ -145,7 +155,9 @@ public void CheckResponseDateDictionaryProperties(string propertyName, string ex
{
var actual = _actual.Data as Dictionary<string, DateTime>;
Assert.NotNull(actual);
Assert.Equal(DateTime.Parse(expectedPropValue).ToUniversalTime(), actual[propertyName]);
// Currently, we use DateTime type representation for both date and date-time.
// Until this behaviour changes, differentiate them on expected value and convert to DateOnly if necessary.
Assert.Equal(DateOnly.Parse(expectedPropValue), DateOnly.FromDateTime(actual[propertyName]));
}
}
}

0 comments on commit 04aaa1b

Please sign in to comment.