mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 15:11:10 +00:00
Removes the redundant contract and enumeration tests
This commit is contained in:
1 parent
4dce426b38
commit
dc2692e208
127 files changed
-6721
No files matched your search
@@ -1,68 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.DTO.Authentication;
|
||||
using Lumina.Contracts.Fixtures.Core.DTO.Authentication;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Authorization;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.UnitTests.DTO.Authentication;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="PermissionDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PermissionDtoTests
|
||||
{
|
||||
private readonly PermissionDtoFixture _permissionDtoFixture = new();
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingPermission_ShouldPreserveValues()
|
||||
{
|
||||
// Arrange
|
||||
PermissionDto expected = _permissionDtoFixture.Create(permissionName: AuthorizationPermission.CanViewUsers);
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(expected, _jsonOptions);
|
||||
PermissionDto? actual = JsonSerializer.Deserialize<PermissionDto>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(actual);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Serialize_WhenSerializingPermission_ShouldSerializeEnumAsCamelCaseString()
|
||||
{
|
||||
// Arrange
|
||||
PermissionDto sut = _permissionDtoFixture.Create(permissionName: AuthorizationPermission.CanDeleteUsers);
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(sut, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.Contains("\"PermissionName\":\"canDeleteUsers\"", json, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Equality_WhenTwoInstancesHaveSameValues_ShouldBeEqual()
|
||||
{
|
||||
// Arrange
|
||||
Guid id = Guid.NewGuid();
|
||||
PermissionDto first = _permissionDtoFixture.Create(id: id, permissionName: AuthorizationPermission.CanRegisterUsers);
|
||||
PermissionDto second = _permissionDtoFixture.Create(id: id, permissionName: AuthorizationPermission.CanRegisterUsers);
|
||||
|
||||
// Act
|
||||
bool areEqual = first == second;
|
||||
|
||||
// Assert
|
||||
Assert.True(areEqual);
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.DTO.Authentication;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.UnitTests.DTO.Authentication;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="RoleDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class RoleDtoTests
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingRole_ShouldPreserveValues()
|
||||
{
|
||||
// Arrange
|
||||
Guid id = Guid.NewGuid();
|
||||
RoleDto expected = new(id, "Admin");
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(expected, _jsonOptions);
|
||||
RoleDto? actual = JsonSerializer.Deserialize<RoleDto>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(actual);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Equality_WhenTwoInstancesHaveSameValues_ShouldBeEqual()
|
||||
{
|
||||
// Arrange
|
||||
Guid id = Guid.NewGuid();
|
||||
RoleDto first = new(id, "Admin");
|
||||
RoleDto second = new(id, "Admin");
|
||||
|
||||
// Act
|
||||
bool areEqual = first == second;
|
||||
|
||||
// Assert
|
||||
Assert.True(areEqual);
|
||||
}
|
||||
}
|
||||
-27
@@ -18,33 +18,6 @@ public class LibraryFilterDtoTests
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void LibraryFilterDto_WhenConstructed_ShouldRequireLibraryId()
|
||||
{
|
||||
// Act
|
||||
LibraryFilterDto sut = new() { LibraryId = Guid.NewGuid(), SearchTerm = "test" };
|
||||
|
||||
// Assert
|
||||
Assert.NotEqual(Guid.Empty, sut.LibraryId);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingWithLibraryIdAndSearchTerm_ShouldPreserveValues()
|
||||
{
|
||||
// Arrange
|
||||
Guid libraryId = Guid.NewGuid();
|
||||
LibraryFilterDto expected = new() { LibraryId = libraryId, SearchTerm = "fantasy" };
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(expected, _jsonOptions);
|
||||
LibraryFilterDto? actual = JsonSerializer.Deserialize<LibraryFilterDto>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(actual);
|
||||
Assert.Equal(expected.LibraryId, actual.LibraryId);
|
||||
Assert.Equal(expected.SearchTerm, actual.SearchTerm);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenDeserializingJsonWithoutLibraryId_ShouldThrowJsonException()
|
||||
{
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.UnitTests.DTO.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="GenreDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GenreDtoTests
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingGenre_ShouldPreserveName()
|
||||
{
|
||||
// Arrange
|
||||
GenreDto expected = new("Science Fiction");
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(expected, _jsonOptions);
|
||||
GenreDto? actual = JsonSerializer.Deserialize<GenreDto>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(actual);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Equality_WhenTwoInstancesHaveSameValues_ShouldBeEqual()
|
||||
{
|
||||
// Arrange
|
||||
GenreDto first = new("Fantasy");
|
||||
GenreDto second = new("Fantasy");
|
||||
|
||||
// Act
|
||||
bool areEqual = first == second;
|
||||
|
||||
// Assert
|
||||
Assert.True(areEqual);
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.UnitTests.DTO.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="LanguageInfoDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LanguageInfoDtoTests
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingFullyPopulatedLanguageInfo_ShouldPreserveValues()
|
||||
{
|
||||
// Arrange
|
||||
LanguageInfoDto expected = new("en", "English", "English");
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(expected, _jsonOptions);
|
||||
LanguageInfoDto? actual = JsonSerializer.Deserialize<LanguageInfoDto>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(actual);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Equality_WhenTwoInstancesHaveSameValues_ShouldBeEqual()
|
||||
{
|
||||
// Arrange
|
||||
LanguageInfoDto first = new("fr", "French", "Français");
|
||||
LanguageInfoDto second = new("fr", "French", "Français");
|
||||
|
||||
// Act
|
||||
bool areEqual = first == second;
|
||||
|
||||
// Assert
|
||||
Assert.True(areEqual);
|
||||
}
|
||||
}
|
||||
-22
@@ -1,7 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.DTO.Common.Pagination;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.UnitTests.DTO.Common.Pagination;
|
||||
@@ -12,11 +11,6 @@ namespace Lumina.Contracts.UnitTests.DTO.Common.Pagination;
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PaginationDataDtoTests
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void CurrentPage_WhenNotSet_ShouldDefaultToOne()
|
||||
{
|
||||
@@ -98,20 +92,4 @@ public class PaginationDataDtoTests
|
||||
// Assert
|
||||
Assert.Equal(25, sut.PerPage);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingValidPaginationData_ShouldPreserveValues()
|
||||
{
|
||||
// Arrange
|
||||
PaginationDataDto expected = new() { CurrentPage = 3, PerPage = 50 };
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(expected, _jsonOptions);
|
||||
PaginationDataDto? actual = JsonSerializer.Deserialize<PaginationDataDto>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(actual);
|
||||
Assert.Equal(expected.CurrentPage, actual.CurrentPage);
|
||||
Assert.Equal(expected.PerPage, actual.PerPage);
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Common;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.UnitTests.DTO.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="ReleaseInfoDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ReleaseInfoDtoTests
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingFullyPopulatedReleaseInfo_ShouldPreserveValues()
|
||||
{
|
||||
// Arrange
|
||||
DateOnly originalReleaseDate = new(2005, 6, 15);
|
||||
DateOnly reReleaseDate = new(2015, 9, 1);
|
||||
ReleaseInfoDto expected = new(
|
||||
originalReleaseDate,
|
||||
2005,
|
||||
reReleaseDate,
|
||||
2015,
|
||||
ReleaseCountry.US,
|
||||
"Revised Edition"
|
||||
);
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(expected, _jsonOptions);
|
||||
ReleaseInfoDto? actual = JsonSerializer.Deserialize<ReleaseInfoDto>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(actual);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingEmptyReleaseInfo_ShouldPreserveNullValues()
|
||||
{
|
||||
// Arrange
|
||||
ReleaseInfoDto expected = new(null, null, null, null, null, null);
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(expected, _jsonOptions);
|
||||
ReleaseInfoDto? actual = JsonSerializer.Deserialize<ReleaseInfoDto>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(actual);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Equality_WhenTwoInstancesHaveSameValues_ShouldBeEqual()
|
||||
{
|
||||
// Arrange
|
||||
ReleaseInfoDto first = new(new DateOnly(2005, 6, 15), 2005, null, null, ReleaseCountry.US, null);
|
||||
ReleaseInfoDto second = new(new DateOnly(2005, 6, 15), 2005, null, null, ReleaseCountry.US, null);
|
||||
|
||||
// Act
|
||||
bool areEqual = first == second;
|
||||
|
||||
// Assert
|
||||
Assert.True(areEqual);
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.UnitTests.DTO.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="TagDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class TagDtoTests
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingTag_ShouldPreserveName()
|
||||
{
|
||||
// Arrange
|
||||
TagDto expected = new("bestseller");
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(expected, _jsonOptions);
|
||||
TagDto? actual = JsonSerializer.Deserialize<TagDto>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(actual);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Equality_WhenTwoInstancesHaveSameValues_ShouldBeEqual()
|
||||
{
|
||||
// Arrange
|
||||
TagDto first = new("award-winning");
|
||||
TagDto second = new("award-winning");
|
||||
|
||||
// Act
|
||||
bool areEqual = first == second;
|
||||
|
||||
// Assert
|
||||
Assert.True(areEqual);
|
||||
}
|
||||
}
|
||||
-63
@@ -1,63 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.DTO.FileSystemManagement;
|
||||
using Lumina.Contracts.Fixtures.Core.DTO.FileSystemManagement;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.UnitTests.DTO.FileSystemManagement;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="FileSystemItemDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class FileSystemItemDtoTests
|
||||
{
|
||||
private readonly FileSystemItemDtoFixture _fileSystemItemDtoFixture = new();
|
||||
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void Create_WhenCalled_ShouldReturnValidFileSystemItemDto()
|
||||
{
|
||||
// Act
|
||||
FileSystemItemDto sut = _fileSystemItemDtoFixture.Create();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(sut);
|
||||
Assert.False(string.IsNullOrWhiteSpace(sut.Path));
|
||||
Assert.False(string.IsNullOrWhiteSpace(sut.Name));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingFileSystemItem_ShouldPreserveValues()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemItemDto expected = _fileSystemItemDtoFixture.Create();
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(expected, _jsonOptions);
|
||||
FileSystemItemDto? actual = JsonSerializer.Deserialize<FileSystemItemDto>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(actual);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Equality_WhenTwoInstancesHaveSameValues_ShouldBeEqual()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemItemDto first = _fileSystemItemDtoFixture.Create();
|
||||
FileSystemItemDto second = first with { };
|
||||
|
||||
// Act
|
||||
bool areEqual = first == second;
|
||||
|
||||
// Assert
|
||||
Assert.True(areEqual);
|
||||
}
|
||||
}
|
||||
-54
@@ -1,54 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.DTO.MediaContributors;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaContributors;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.UnitTests.DTO.MediaContributors;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="MediaContributorDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaContributorDtoTests
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingContributor_ShouldPreserveValues()
|
||||
{
|
||||
// Arrange
|
||||
MediaContributorDto expected = new(
|
||||
new MediaContributorNameDto("John Smith", "Johnathan Smith"),
|
||||
MediaContributorRole.Author
|
||||
);
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(expected, _jsonOptions);
|
||||
MediaContributorDto? actual = JsonSerializer.Deserialize<MediaContributorDto>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(actual);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingContributorWithoutNameOrRole_ShouldPreserveNullValues()
|
||||
{
|
||||
// Arrange
|
||||
MediaContributorDto expected = new(null, null);
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(expected, _jsonOptions);
|
||||
MediaContributorDto? actual = JsonSerializer.Deserialize<MediaContributorDto>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(actual);
|
||||
Assert.Null(actual.Name);
|
||||
Assert.Null(actual.Role);
|
||||
}
|
||||
}
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.DTO.MediaContributors;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.UnitTests.DTO.MediaContributors;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="MediaContributorNameDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaContributorNameDtoTests
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingName_ShouldPreserveValues()
|
||||
{
|
||||
// Arrange
|
||||
MediaContributorNameDto expected = new("John Smith", "Johnathan Smith");
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(expected, _jsonOptions);
|
||||
MediaContributorNameDto? actual = JsonSerializer.Deserialize<MediaContributorNameDto>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(actual);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Equality_WhenTwoInstancesHaveSameValues_ShouldBeEqual()
|
||||
{
|
||||
// Arrange
|
||||
MediaContributorNameDto first = new("John Smith", null);
|
||||
MediaContributorNameDto second = new("John Smith", null);
|
||||
|
||||
// Act
|
||||
bool areEqual = first == second;
|
||||
|
||||
// Assert
|
||||
Assert.True(areEqual);
|
||||
}
|
||||
}
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.DTO.MediaLibrary.Management;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.UnitTests.DTO.MediaLibrary.Management;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="LibraryContentLocationDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryContentLocationDtoTests
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingContentLocation_ShouldPreservePath()
|
||||
{
|
||||
// Arrange
|
||||
LibraryContentLocationDto expected = new(@"C:\Media\Books");
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(expected, _jsonOptions);
|
||||
LibraryContentLocationDto? actual = JsonSerializer.Deserialize<LibraryContentLocationDto>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(actual);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Equality_WhenTwoInstancesHaveSameValues_ShouldBeEqual()
|
||||
{
|
||||
// Arrange
|
||||
LibraryContentLocationDto first = new(@"/media/books");
|
||||
LibraryContentLocationDto second = new(@"/media/books");
|
||||
|
||||
// Act
|
||||
bool areEqual = first == second;
|
||||
|
||||
// Assert
|
||||
Assert.True(areEqual);
|
||||
}
|
||||
}
|
||||
-111
@@ -1,111 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using Lumina.Contracts.DTO.MediaContributors;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaContributors;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.UnitTests.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="BookMetadataDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class BookMetadataDtoTests
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingFullyPopulatedMetadata_ShouldPreserveValues()
|
||||
{
|
||||
// Arrange
|
||||
BookMetadataDto expected = new(
|
||||
"Dune",
|
||||
"Dune",
|
||||
"A science fiction novel.",
|
||||
new ReleaseInfoDto(new DateOnly(1965, 8, 1), 1965, null, null, ReleaseCountry.US, null),
|
||||
[new GenreDto("Science Fiction")],
|
||||
[new TagDto("classic")],
|
||||
new LanguageInfoDto("en", "English", "English"),
|
||||
null,
|
||||
"Chilton Books",
|
||||
412,
|
||||
BookFormat.Hardcover,
|
||||
"First Edition",
|
||||
1,
|
||||
new BookSeriesDto("Dune Chronicles"),
|
||||
"B0006C7V9I",
|
||||
"12345",
|
||||
"68008446",
|
||||
"ocm01234567",
|
||||
"OL12345W",
|
||||
"lccn123",
|
||||
"abc123",
|
||||
"1234567890",
|
||||
"id12345",
|
||||
[new IsbnDto("978-0-306-40615-7", IsbnFormat.Isbn13)],
|
||||
[new MediaContributorDto(new MediaContributorNameDto("Frank Herbert", "Frank Herbert"), MediaContributorRole.Author)],
|
||||
[new BookRatingDto(4.5m, 5m, BookRatingSource.Goodreads, 1000)],
|
||||
"https://example.com/dune.jpg"
|
||||
);
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(expected, _jsonOptions);
|
||||
BookMetadataDto? actual = JsonSerializer.Deserialize<BookMetadataDto>(json, _jsonOptions);
|
||||
// Assert
|
||||
Assert.NotNull(actual);
|
||||
Assert.Equivalent(expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Serialize_WhenSerializingMetadata_ShouldSerializeFormatAsCamelCaseString()
|
||||
{
|
||||
// Arrange
|
||||
BookMetadataDto sut = new(
|
||||
"Dune",
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
BookFormat.Paperback,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
);
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(sut, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.Contains("\"Format\":\"paperback\"", json, StringComparison.Ordinal);
|
||||
}
|
||||
}
|
||||
-32
@@ -6,8 +6,6 @@ using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.UnitTests.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
@@ -18,36 +16,6 @@ namespace Lumina.Contracts.UnitTests.DTO.MediaLibrary.WrittenContentLibrary.Book
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class BookMetadataLookupDtoTests
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingLookupWithAllValues_ShouldPreserveValues()
|
||||
{
|
||||
// Arrange
|
||||
Guid libraryId = Guid.NewGuid();
|
||||
BookMetadataLookupDto expected = new(
|
||||
libraryId,
|
||||
@"C:\Media\Books\dune.epub",
|
||||
"978-0-306-40615-7",
|
||||
"OL12345W",
|
||||
"Dune",
|
||||
"Frank Herbert",
|
||||
"en"
|
||||
);
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(expected, _jsonOptions);
|
||||
BookMetadataLookupDto? actual = JsonSerializer.Deserialize<BookMetadataLookupDto>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(actual);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_WhenOmittingOptionalParameters_ShouldUseNullDefaults()
|
||||
{
|
||||
|
||||
-62
@@ -4,8 +4,6 @@ using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary.Book
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.UnitTests.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
@@ -18,24 +16,6 @@ public class BookRatingDtoTests
|
||||
{
|
||||
private readonly BookRatingDtoFixture _bookRatingDtoFixture = new();
|
||||
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void Create_WhenCalled_ShouldReturnValidBookRatingDto()
|
||||
{
|
||||
// Act
|
||||
BookRatingDto sut = _bookRatingDtoFixture.Create();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(sut);
|
||||
Assert.True(sut.Value.HasValue);
|
||||
Assert.True(sut.MaxValue.HasValue);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Create_WhenOmittingOptionalProperties_ShouldReturnNullSourceAndVoteCount()
|
||||
{
|
||||
@@ -46,46 +26,4 @@ public class BookRatingDtoTests
|
||||
Assert.Null(sut.Source);
|
||||
Assert.Null(sut.VoteCount);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingRating_ShouldPreserveValues()
|
||||
{
|
||||
// Arrange
|
||||
BookRatingDto expected = _bookRatingDtoFixture.Create(source: BookRatingSource.Goodreads);
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(expected, _jsonOptions);
|
||||
BookRatingDto? actual = JsonSerializer.Deserialize<BookRatingDto>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(actual);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Serialize_WhenSerializingRating_ShouldSerializeSourceAsCamelCaseString()
|
||||
{
|
||||
// Arrange
|
||||
BookRatingDto sut = _bookRatingDtoFixture.Create(source: BookRatingSource.OpenLibrary);
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(sut, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.Contains("\"Source\":\"openLibrary\"", json, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Equality_WhenTwoInstancesHaveSameValues_ShouldBeEqual()
|
||||
{
|
||||
// Arrange
|
||||
BookRatingDto first = _bookRatingDtoFixture.Create(value: 4, maxValue: 5, source: BookRatingSource.User, voteCount: 10);
|
||||
BookRatingDto second = _bookRatingDtoFixture.Create(value: 4, maxValue: 5, source: BookRatingSource.User, voteCount: 10);
|
||||
|
||||
// Act
|
||||
bool areEqual = first == second;
|
||||
|
||||
// Assert
|
||||
Assert.True(areEqual);
|
||||
}
|
||||
}
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.UnitTests.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="BookSeriesDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class BookSeriesDtoTests
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingSeries_ShouldPreserveTitle()
|
||||
{
|
||||
// Arrange
|
||||
BookSeriesDto expected = new("The Wheel of Time");
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(expected, _jsonOptions);
|
||||
BookSeriesDto? actual = JsonSerializer.Deserialize<BookSeriesDto>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(actual);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Equality_WhenTwoInstancesHaveSameValues_ShouldBeEqual()
|
||||
{
|
||||
// Arrange
|
||||
BookSeriesDto first = new("Dune");
|
||||
BookSeriesDto second = new("Dune");
|
||||
|
||||
// Act
|
||||
bool areEqual = first == second;
|
||||
|
||||
// Assert
|
||||
Assert.True(areEqual);
|
||||
}
|
||||
}
|
||||
-61
@@ -4,8 +4,6 @@ using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary.Book
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.UnitTests.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
@@ -18,23 +16,6 @@ public class IsbnDtoTests
|
||||
{
|
||||
private readonly IsbnDtoFixture _isbnDtoFixture = new();
|
||||
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void Create_WhenCalled_ShouldReturnValidIsbnDto()
|
||||
{
|
||||
// Act
|
||||
IsbnDto sut = _isbnDtoFixture.Create();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(sut);
|
||||
Assert.False(string.IsNullOrWhiteSpace(sut.Value));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Create_WhenFormatIsIsbn10_ShouldReturnIsbn10Value()
|
||||
{
|
||||
@@ -45,46 +26,4 @@ public class IsbnDtoTests
|
||||
Assert.Equal(IsbnFormat.Isbn10, sut.Format);
|
||||
Assert.Contains("-", sut.Value, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingIsbn_ShouldPreserveValues()
|
||||
{
|
||||
// Arrange
|
||||
IsbnDto expected = _isbnDtoFixture.Create(format: IsbnFormat.Isbn13);
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(expected, _jsonOptions);
|
||||
IsbnDto? actual = JsonSerializer.Deserialize<IsbnDto>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(actual);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Serialize_WhenSerializingIsbn_ShouldSerializeFormatAsCamelCaseString()
|
||||
{
|
||||
// Arrange
|
||||
IsbnDto sut = _isbnDtoFixture.Create(format: IsbnFormat.Isbn13);
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(sut, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.Contains("\"Format\":\"isbn13\"", json, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Equality_WhenTwoInstancesHaveSameValues_ShouldBeEqual()
|
||||
{
|
||||
// Arrange
|
||||
IsbnDto first = _isbnDtoFixture.Create(value: "978-0-306-40615-7", format: IsbnFormat.Isbn13);
|
||||
IsbnDto second = _isbnDtoFixture.Create(value: "978-0-306-40615-7", format: IsbnFormat.Isbn13);
|
||||
|
||||
// Act
|
||||
bool areEqual = first == second;
|
||||
|
||||
// Assert
|
||||
Assert.True(areEqual);
|
||||
}
|
||||
}
|
||||
-49
@@ -1,49 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
|
||||
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.UnitTests.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="ReadingDocumentDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ReadingDocumentDtoTests
|
||||
{
|
||||
private readonly ReadingDocumentDtoFixture _fixture = new();
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void Create_WhenCalled_ShouldReturnValidReadingDocumentDto()
|
||||
{
|
||||
// Act
|
||||
ReadingDocumentDto sut = _fixture.Create();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(sut);
|
||||
Assert.False(string.IsNullOrWhiteSpace(sut.Title));
|
||||
Assert.NotEmpty(sut.Spine);
|
||||
Assert.NotNull(sut.Resources);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingReadingDocumentDto_ShouldPreserveValues()
|
||||
{
|
||||
// Arrange
|
||||
ReadingDocumentDto expected = _fixture.Create();
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(expected, _jsonOptions);
|
||||
ReadingDocumentDto? actual = JsonSerializer.Deserialize<ReadingDocumentDto>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(actual);
|
||||
Assert.Equivalent(expected, actual);
|
||||
}
|
||||
}
|
||||
-32
@@ -3,7 +3,6 @@ using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Readin
|
||||
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.UnitTests.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
|
||||
@@ -15,22 +14,6 @@ namespace Lumina.Contracts.UnitTests.DTO.MediaLibrary.WrittenContentLibrary.Book
|
||||
public class ReadingResourceDataDtoTests
|
||||
{
|
||||
private readonly ReadingResourceDataDtoFixture _fixture = new();
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void Create_WhenCalled_ShouldReturnValidReadingResourceDataDto()
|
||||
{
|
||||
// Act
|
||||
ReadingResourceDataDto sut = _fixture.Create();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(sut);
|
||||
Assert.NotEmpty(sut.Data);
|
||||
Assert.False(string.IsNullOrWhiteSpace(sut.MimeType));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Create_WhenProvidedData_ShouldPreserveIt()
|
||||
@@ -44,19 +27,4 @@ public class ReadingResourceDataDtoTests
|
||||
// Assert
|
||||
Assert.Equal(data, sut.Data);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingReadingResourceDataDto_ShouldPreserveValues()
|
||||
{
|
||||
// Arrange
|
||||
ReadingResourceDataDto expected = _fixture.Create();
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(expected, _jsonOptions);
|
||||
ReadingResourceDataDto? actual = JsonSerializer.Deserialize<ReadingResourceDataDto>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(actual);
|
||||
Assert.Equivalent(expected, actual);
|
||||
}
|
||||
}
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
|
||||
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.UnitTests.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="ReadingResourceInfoDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ReadingResourceInfoDtoTests
|
||||
{
|
||||
private readonly ReadingResourceInfoDtoFixture _fixture = new();
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void Create_WhenCalled_ShouldReturnValidReadingResourceInfoDto()
|
||||
{
|
||||
// Act
|
||||
ReadingResourceInfoDto sut = _fixture.Create();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(sut);
|
||||
Assert.False(string.IsNullOrWhiteSpace(sut.RelativeFilePath));
|
||||
Assert.False(string.IsNullOrWhiteSpace(sut.MimeType));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingReadingResourceInfoDto_ShouldPreserveValues()
|
||||
{
|
||||
// Arrange
|
||||
ReadingResourceInfoDto expected = _fixture.Create();
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(expected, _jsonOptions);
|
||||
ReadingResourceInfoDto? actual = JsonSerializer.Deserialize<ReadingResourceInfoDto>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(actual);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
}
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
|
||||
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.UnitTests.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="ReadingSectionDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ReadingSectionDtoTests
|
||||
{
|
||||
private readonly ReadingSectionDtoFixture _fixture = new();
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void Create_WhenCalled_ShouldReturnValidReadingSectionDto()
|
||||
{
|
||||
// Act
|
||||
ReadingSectionDto sut = _fixture.Create();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(sut);
|
||||
Assert.False(string.IsNullOrWhiteSpace(sut.LocationRef));
|
||||
Assert.False(string.IsNullOrWhiteSpace(sut.ContentHtml));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingReadingSectionDto_ShouldPreserveValues()
|
||||
{
|
||||
// Arrange
|
||||
ReadingSectionDto expected = _fixture.Create();
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(expected, _jsonOptions);
|
||||
ReadingSectionDto? actual = JsonSerializer.Deserialize<ReadingSectionDto>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(actual);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
}
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
|
||||
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.UnitTests.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="ReadingSpineItemDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ReadingSpineItemDtoTests
|
||||
{
|
||||
private readonly ReadingSpineItemDtoFixture _fixture = new();
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void Create_WhenCalled_ShouldReturnValidReadingSpineItemDto()
|
||||
{
|
||||
// Act
|
||||
ReadingSpineItemDto sut = _fixture.Create();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(sut);
|
||||
Assert.False(string.IsNullOrWhiteSpace(sut.LocationRef));
|
||||
Assert.False(string.IsNullOrWhiteSpace(sut.RelativeSectionFilePath));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingReadingSpineItemDto_ShouldPreserveValues()
|
||||
{
|
||||
// Arrange
|
||||
ReadingSpineItemDto expected = _fixture.Create();
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(expected, _jsonOptions);
|
||||
ReadingSpineItemDto? actual = JsonSerializer.Deserialize<ReadingSpineItemDto>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(actual);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
}
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
|
||||
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.UnitTests.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="ReadingTocEntryDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ReadingTocEntryDtoTests
|
||||
{
|
||||
private readonly ReadingTocEntryDtoFixture _fixture = new();
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void Create_WhenCalled_ShouldReturnValidReadingTocEntryDto()
|
||||
{
|
||||
// Act
|
||||
ReadingTocEntryDto sut = _fixture.Create();
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(sut);
|
||||
Assert.False(string.IsNullOrWhiteSpace(sut.Label));
|
||||
Assert.False(string.IsNullOrWhiteSpace(sut.LocationRef));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingReadingTocEntryDto_ShouldPreserveValues()
|
||||
{
|
||||
// Arrange
|
||||
ReadingTocEntryDto expected = _fixture.Create();
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(expected, _jsonOptions);
|
||||
ReadingTocEntryDto? actual = JsonSerializer.Deserialize<ReadingTocEntryDto>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(actual);
|
||||
Assert.Equivalent(expected, actual);
|
||||
}
|
||||
}
|
||||
-74
@@ -1,74 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.UnitTests.DTO.MediaLibrary.WrittenContentLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="WrittenContentMetadataDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class WrittenContentMetadataDtoTests
|
||||
{
|
||||
private readonly JsonSerializerOptions _jsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingFullyPopulatedMetadata_ShouldPreserveValues()
|
||||
{
|
||||
// Arrange
|
||||
WrittenContentMetadataDto expected = new(
|
||||
"Dune",
|
||||
"Dune",
|
||||
"A science fiction novel.",
|
||||
new ReleaseInfoDto(new DateOnly(1965, 8, 1), 1965, null, null, ReleaseCountry.US, null),
|
||||
[new GenreDto("Science Fiction")],
|
||||
[new TagDto("classic")],
|
||||
new LanguageInfoDto("en", "English", "English"),
|
||||
null,
|
||||
"Chilton Books",
|
||||
412
|
||||
);
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(expected, _jsonOptions);
|
||||
WrittenContentMetadataDto? actual = JsonSerializer.Deserialize<WrittenContentMetadataDto>(json, _jsonOptions);
|
||||
// Assert
|
||||
Assert.NotNull(actual);
|
||||
Assert.Equivalent(expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RoundTrip_WhenSerializingMetadataWithoutOptionalValues_ShouldPreserveNullValues()
|
||||
{
|
||||
// Arrange
|
||||
WrittenContentMetadataDto expected = new(
|
||||
"Title",
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
);
|
||||
|
||||
// Act
|
||||
string json = JsonSerializer.Serialize(expected, _jsonOptions);
|
||||
WrittenContentMetadataDto? actual = JsonSerializer.Deserialize<WrittenContentMetadataDto>(json, _jsonOptions);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(actual);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user