mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 16: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
+66
@@ -0,0 +1,66 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Fixtures.Core.Responses.FileSystemManagement.Directories;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Directories;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.UnitTests.Responses.FileSystemManagement.Directories;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="DirectoryResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class DirectoryResponseTests
|
||||
{
|
||||
private readonly DirectoryResponseFixture _directoryResponseFixture = new();
|
||||
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void Create_WhenCalled_ShouldReturnValidDirectoryResponse()
|
||||
{
|
||||
// Act
|
||||
DirectoryResponse sut = _directoryResponseFixture.Create();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(sut);
|
||||
Assert.False(string.IsNullOrWhiteSpace(sut.Path));
|
||||
Assert.False(string.IsNullOrWhiteSpace(sut.Name));
|
||||
Assert.NotEmpty(sut.Items);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingDirectoryResponse_ShouldPreserveValues()
|
||||
{
|
||||
// Arrange
|
||||
DirectoryResponse expected = _directoryResponseFixture.Create(itemCount: 2);
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(expected, _jsonOptions);
|
||||
DirectoryResponse? actual = JsonSerializer.Deserialize<DirectoryResponse>(json, _jsonOptions);
|
||||
// Assert
|
||||
Assert.NotNull(actual);
|
||||
Assert.Equivalent(expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Deconstruct_WhenCalled_ShouldReturnAllProperties()
|
||||
{
|
||||
// Arrange
|
||||
DirectoryResponse sut = _directoryResponseFixture.Create(itemCount: 1);
|
||||
|
||||
// Act
|
||||
(string path, string name, System.DateTime dateCreated, System.DateTime dateModified, System.Collections.Generic.List<Lumina.Contracts.DTO.FileSystemManagement.FileSystemItemDto> items) = sut;
|
||||
|
||||
// Assert
|
||||
Assert.Equal(sut.Path, path);
|
||||
Assert.Equal(sut.Name, name);
|
||||
Assert.Equal(sut.DateCreated, dateCreated);
|
||||
Assert.Equal(sut.DateModified, dateModified);
|
||||
Assert.Equal(sut.Items, items);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user