mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 09:11:10 +00:00
Hardens test assertions and adds missing test coverage.
This commit is contained in:
1 parent
6b86fd5805
commit
1189bbaf36
489 files changed
+39982
-512
No files matched your search
+58
@@ -0,0 +1,58 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.Authorization;
|
||||
using Lumina.Contracts.Requests.Authorization;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.UnitTests.Requests.Authorization;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="GetAuthorizationRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetAuthorizationRequestTests
|
||||
{
|
||||
private readonly GetAuthorizationRequestFixture _getAuthorizationRequestFixture = new();
|
||||
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void Create_WhenCalled_ShouldReturnValidGetAuthorizationRequest()
|
||||
{
|
||||
// Act
|
||||
GetAuthorizationRequest sut = _getAuthorizationRequestFixture.Create();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(sut);
|
||||
Assert.True(sut.UserId.HasValue);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_WhenPassingNullUserId_ShouldReturnNullUserId()
|
||||
{
|
||||
// Act
|
||||
GetAuthorizationRequest sut = new(UserId: null);
|
||||
|
||||
// Assert
|
||||
Assert.Null(sut.UserId);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingGetAuthorizationRequest_ShouldPreserveValues()
|
||||
{
|
||||
// Arrange
|
||||
GetAuthorizationRequest expected = _getAuthorizationRequestFixture.Create();
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(expected, _jsonOptions);
|
||||
GetAuthorizationRequest? actual = JsonSerializer.Deserialize<GetAuthorizationRequest>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(actual);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user