mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 08:11:10 +00:00
Caches JsonSerializerOptions instances in tests
This commit is contained in:
1 parent
c2e00242cc
commit
b2b6f554b7
3 files changed
+6
-8
No files matched your search
+2
-6
@@ -26,6 +26,7 @@ public class GetRolesEndpointTests
|
||||
private readonly IApiHttpClient _mockApiHttpClient;
|
||||
private readonly GetRolesEndpoint _sut;
|
||||
private readonly RoleDtoFixture _roleDtoFixture = new();
|
||||
private readonly JsonSerializerOptions _jsonOptions = new() { PropertyNameCaseInsensitive = true };
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetRolesEndpointTests"/> class.
|
||||
@@ -51,15 +52,10 @@ public class GetRolesEndpointTests
|
||||
// Assert
|
||||
using JsonDocument jsonDocument = JsonDocument.Parse(body);
|
||||
Assert.True(jsonDocument.RootElement.GetProperty("success").GetBoolean());
|
||||
RoleDto[]? returnedRoles = jsonDocument.RootElement.GetProperty("data").Deserialize<RoleDto[]>(CreateCaseInsensitiveOptions());
|
||||
RoleDto[]? returnedRoles = jsonDocument.RootElement.GetProperty("data").Deserialize<RoleDto[]>(_jsonOptions);
|
||||
Assert.Equal(expectedRoles.Select(role => role.RoleName), returnedRoles!.Select(role => role.RoleName));
|
||||
}
|
||||
|
||||
private static JsonSerializerOptions CreateCaseInsensitiveOptions()
|
||||
{
|
||||
return new JsonSerializerOptions { PropertyNameCaseInsensitive = true };
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldRequestRolesFromApi()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user