mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-02 17:11:10 +00:00
Adds tests for the book reading feature
This commit is contained in:
1 parent
f7ccdf3d1c
commit
3a3c0c047c
192 files changed
+14104
-342
No files matched your search
+49
@@ -0,0 +1,49 @@
|
||||
#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);
|
||||
}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
|
||||
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;
|
||||
|
||||
/// <summary>
|
||||
/// Contains unit tests for the <see cref="ReadingResourceDataDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
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()
|
||||
{
|
||||
// Arrange
|
||||
byte[] data = Guid.NewGuid().ToByteArray();
|
||||
|
||||
// Act
|
||||
ReadingResourceDataDto sut = _fixture.Create(data: data);
|
||||
|
||||
// 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
@@ -0,0 +1,48 @@
|
||||
#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
@@ -0,0 +1,48 @@
|
||||
#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
@@ -0,0 +1,48 @@
|
||||
#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
@@ -0,0 +1,48 @@
|
||||
#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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user