diff --git a/Web/Sample/Synergy.Sample.Web.API.Tests/Infrastructure/SampleTestServer.cs b/Web/Sample/Synergy.Sample.Web.API.Tests/Infrastructure/SampleTestServer.cs
index 3cbded3..23fb0a9 100644
--- a/Web/Sample/Synergy.Sample.Web.API.Tests/Infrastructure/SampleTestServer.cs
+++ b/Web/Sample/Synergy.Sample.Web.API.Tests/Infrastructure/SampleTestServer.cs
@@ -1,6 +1,7 @@
using System.Net.Http;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Testing;
+using Newtonsoft.Json;
using Synergy.Sample.Web.API.Extensions;
using Synergy.Web.Api.Testing;
@@ -8,6 +9,12 @@ namespace Synergy.Sample.Web.API.Tests.Infrastructure
{
public class SampleTestServer : TestServer
{
+ ///
+ public override JsonSerializerSettings SerializationSettings => new()
+ {
+ DateTimeZoneHandling = DateTimeZoneHandling.RoundtripKind
+ };
+
private WebApplicationFactory? webApplicationFactory;
///
diff --git a/Web/Sample/Synergy.Sample.Web.API.Tests/Users/Patterns/S02_E02_GetCreatedUserByLocation.json b/Web/Sample/Synergy.Sample.Web.API.Tests/Users/Patterns/S02_E02_GetCreatedUserByLocation.json
index f821c69..f646315 100644
--- a/Web/Sample/Synergy.Sample.Web.API.Tests/Users/Patterns/S02_E02_GetCreatedUserByLocation.json
+++ b/Web/Sample/Synergy.Sample.Web.API.Tests/Users/Patterns/S02_E02_GetCreatedUserByLocation.json
@@ -25,7 +25,7 @@
"login": {
"value": "marcin@synergy.com"
},
- "created": "2024-05-13T13:19:15.8420304+02:00"
+ "created": "2022-12-15T19:09:56+05:30"
}
}
}
diff --git a/Web/Sample/Synergy.Sample.Web.API.Tests/Users/Users.md b/Web/Sample/Synergy.Sample.Web.API.Tests/Users/Users.md
index 1607584..5c6532e 100644
--- a/Web/Sample/Synergy.Sample.Web.API.Tests/Users/Users.md
+++ b/Web/Sample/Synergy.Sample.Web.API.Tests/Users/Users.md
@@ -115,7 +115,7 @@ Content-Length: 182
"login": {
"value": "marcin@synergy.com"
},
- "created": "2024-05-13T13:19:15.8420304+02:00"
+ "created": "2022-12-15T14:39:56+01:00"
}
}
```
diff --git a/Web/Synergy.Web.Api.Testing/HttpExtensions.cs b/Web/Synergy.Web.Api.Testing/HttpExtensions.cs
index 8625601..679ffb9 100644
--- a/Web/Synergy.Web.Api.Testing/HttpExtensions.cs
+++ b/Web/Synergy.Web.Api.Testing/HttpExtensions.cs
@@ -104,10 +104,8 @@ public static string ToHttpLook(this HttpRequestMessage request, HttpOperation o
var requestBody = request.Content.ReadJson();
if (requestBody != null)
{
- report.Append(requestBody.ToString(
- Formatting.Indented,
- operation.TestServer.Converters()
- )
+ report.Append(
+ Serialize(requestBody, operation.TestServer.SerializationSettings)
);
}
return report.ToString().Trim();
@@ -121,15 +119,20 @@ public static string ToHttpLook(this HttpResponseMessage response, HttpOperation
InsertHeaders(report, response.GetAllHeaders());
var responseBody = response.Content.ReadJson();
if (responseBody != null)
- report.Append(responseBody.ToString(
- Formatting.Indented,
- operation.TestServer.Converters()
- )
+ report.Append(
+ Serialize(responseBody, operation.TestServer.SerializationSettings)
);
return report.ToString().Trim();
}
+ private static string Serialize(JToken json, JsonSerializerSettings settings)
+ => JsonConvert.SerializeObject(
+ json,
+ Formatting.Indented,
+ settings
+ );
+
private static void InsertHeaders(StringBuilder report, IEnumerable>> headers)
{
foreach (var header in headers)