Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: date time testing #50

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]));
}
}
}