mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 17:11:10 +00:00
Aligns the test fixture field names with their types and tidies the remaining tests
This commit is contained in:
1 parent
95e771191e
commit
a514335a10
99 files changed
+1523
-1499
No files matched your search
+3
-3
@@ -27,7 +27,7 @@ public class GetBookReadersEndpointTests
|
||||
{
|
||||
private readonly IApiHttpClient _mockApiHttpClient;
|
||||
private readonly GetBookReadersEndpoint _sut;
|
||||
private readonly GetBookReadersRequestFixture _requestFixture = new();
|
||||
private readonly GetBookReadersRequestFixture _getBookReadersRequestFixture = new();
|
||||
private readonly LibraryBookReaderDtoFixture _libraryBookReaderDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
@@ -43,7 +43,7 @@ public class GetBookReadersEndpointTests
|
||||
public async Task ExecuteAsync_WhenSuccessful_ShouldReturnSuccessJsonWithBookReaders()
|
||||
{
|
||||
// Arrange
|
||||
GetBookReadersRequest request = _requestFixture.Create();
|
||||
GetBookReadersRequest request = _getBookReadersRequestFixture.Create();
|
||||
LibraryBookReaderDto[] readers = [.. _libraryBookReaderDtoFixture.CreateMany(2)];
|
||||
_mockApiHttpClient.GetAsync<LibraryBookReaderDto[]>(ApiRoutes.Libraries.GET_LIBRARY_BOOK_READERS.Replace("{libraryId}", request.LibraryId.ToString()), Arg.Any<CancellationToken>())
|
||||
.Returns(readers);
|
||||
@@ -62,7 +62,7 @@ public class GetBookReadersEndpointTests
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldRequestBookReadersFromApi()
|
||||
{
|
||||
// Arrange
|
||||
GetBookReadersRequest request = _requestFixture.Create();
|
||||
GetBookReadersRequest request = _getBookReadersRequestFixture.Create();
|
||||
LibraryBookReaderDto[] readers = [.. _libraryBookReaderDtoFixture.CreateMany(2)];
|
||||
_mockApiHttpClient.GetAsync<LibraryBookReaderDto[]>(ApiRoutes.Libraries.GET_LIBRARY_BOOK_READERS.Replace("{libraryId}", request.LibraryId.ToString()), Arg.Any<CancellationToken>())
|
||||
.Returns(readers);
|
||||
|
||||
+8
-8
@@ -26,8 +26,8 @@ public class GetLibraryPathTemplatePartsEndpointTests
|
||||
{
|
||||
private readonly IApiHttpClient _mockApiHttpClient;
|
||||
private readonly GetLibraryPathTemplatePartsEndpoint _sut;
|
||||
private readonly GetLibraryPathTemplatePartsRequestFixture _requestFixture = new();
|
||||
private readonly LibraryPathTemplateCatalogDtoFixture _catalogDtoFixture = new();
|
||||
private readonly GetLibraryPathTemplatePartsRequestFixture _getLibraryPathTemplatePartsRequestFixture = new();
|
||||
private readonly LibraryPathTemplateCatalogDtoFixture _libraryPathTemplateCatalogDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetLibraryPathTemplatePartsEndpointTests"/> class.
|
||||
@@ -42,8 +42,8 @@ public class GetLibraryPathTemplatePartsEndpointTests
|
||||
public async Task ExecuteAsync_WhenSuccessful_ShouldReturnSuccessJsonWithCatalog()
|
||||
{
|
||||
// Arrange
|
||||
GetLibraryPathTemplatePartsRequest request = _requestFixture.Create();
|
||||
LibraryPathTemplateCatalogDto catalog = _catalogDtoFixture.Create();
|
||||
GetLibraryPathTemplatePartsRequest request = _getLibraryPathTemplatePartsRequestFixture.Create();
|
||||
LibraryPathTemplateCatalogDto catalog = _libraryPathTemplateCatalogDtoFixture.Create();
|
||||
_mockApiHttpClient.GetAsync<LibraryPathTemplateCatalogDto>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
.Returns(catalog);
|
||||
|
||||
@@ -77,8 +77,8 @@ public class GetLibraryPathTemplatePartsEndpointTests
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldRequestCatalogFromApiWithSubstitutedLibraryType()
|
||||
{
|
||||
// Arrange
|
||||
GetLibraryPathTemplatePartsRequest request = _requestFixture.Create(libraryType: "Music");
|
||||
LibraryPathTemplateCatalogDto catalog = _catalogDtoFixture.Create();
|
||||
GetLibraryPathTemplatePartsRequest request = _getLibraryPathTemplatePartsRequestFixture.Create(libraryType: "Music");
|
||||
LibraryPathTemplateCatalogDto catalog = _libraryPathTemplateCatalogDtoFixture.Create();
|
||||
_mockApiHttpClient.GetAsync<LibraryPathTemplateCatalogDto>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
.Returns(catalog);
|
||||
|
||||
@@ -95,8 +95,8 @@ public class GetLibraryPathTemplatePartsEndpointTests
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldForwardCancellationTokenToApi()
|
||||
{
|
||||
// Arrange
|
||||
GetLibraryPathTemplatePartsRequest request = _requestFixture.Create();
|
||||
LibraryPathTemplateCatalogDto catalog = _catalogDtoFixture.Create();
|
||||
GetLibraryPathTemplatePartsRequest request = _getLibraryPathTemplatePartsRequestFixture.Create();
|
||||
LibraryPathTemplateCatalogDto catalog = _libraryPathTemplateCatalogDtoFixture.Create();
|
||||
CancellationTokenSource cancellationTokenSource = new();
|
||||
CancellationToken cancellationToken = cancellationTokenSource.Token;
|
||||
_mockApiHttpClient.GetAsync<LibraryPathTemplateCatalogDto>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
|
||||
+3
-3
@@ -26,7 +26,7 @@ public class SetBookReaderEnabledEndpointTests
|
||||
{
|
||||
private readonly IApiHttpClient _mockApiHttpClient;
|
||||
private readonly SetBookReaderEnabledEndpoint _sut;
|
||||
private readonly SetBookReaderEnabledRequestFixture _requestFixture = new();
|
||||
private readonly SetBookReaderEnabledRequestFixture _setBookReaderEnabledRequestFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SetBookReaderEnabledEndpointTests"/> class.
|
||||
@@ -41,7 +41,7 @@ public class SetBookReaderEnabledEndpointTests
|
||||
public async Task ExecuteAsync_WhenSuccessful_ShouldReturnSuccessJson()
|
||||
{
|
||||
// Arrange
|
||||
SetBookReaderEnabledRequest request = _requestFixture.Create();
|
||||
SetBookReaderEnabledRequest request = _setBookReaderEnabledRequestFixture.Create();
|
||||
_mockApiHttpClient.PutAsync<EmptyRequest, SetBookReaderEnabledRequest>(Arg.Any<string>(), Arg.Any<SetBookReaderEnabledRequest>(), Arg.Any<CancellationToken>())
|
||||
.Returns(new EmptyRequest());
|
||||
|
||||
@@ -58,7 +58,7 @@ public class SetBookReaderEnabledEndpointTests
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldSendBookReaderEnabledChangeToApi()
|
||||
{
|
||||
// Arrange
|
||||
SetBookReaderEnabledRequest request = _requestFixture.Create();
|
||||
SetBookReaderEnabledRequest request = _setBookReaderEnabledRequestFixture.Create();
|
||||
_mockApiHttpClient.PutAsync<EmptyRequest, SetBookReaderEnabledRequest>(Arg.Any<string>(), Arg.Any<SetBookReaderEnabledRequest>(), Arg.Any<CancellationToken>())
|
||||
.Returns(new EmptyRequest());
|
||||
string expectedEndpoint = ApiRoutes.Libraries.SET_LIBRARY_BOOK_READER_ENABLED
|
||||
|
||||
+4
-4
@@ -28,7 +28,7 @@ public class GetReadingAvailabilityEndpointTests
|
||||
private readonly IApiHttpClient _mockApiHttpClient;
|
||||
private readonly GetReadingAvailabilityEndpoint _sut;
|
||||
private readonly ReadingAvailabilityDtoFixture _readingAvailabilityDtoFixture = new();
|
||||
private readonly GetBookReadingAvailabilityRequestFixture _requestFixture = new();
|
||||
private readonly GetBookReadingAvailabilityRequestFixture _getBookReadingAvailabilityRequestFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetReadingAvailabilityEndpointTests"/> class.
|
||||
@@ -43,7 +43,7 @@ public class GetReadingAvailabilityEndpointTests
|
||||
public async Task ExecuteAsync_WhenBookIsAvailable_ShouldReturnSuccessJson()
|
||||
{
|
||||
// Arrange
|
||||
GetBookReadingAvailabilityRequest request = _requestFixture.Create();
|
||||
GetBookReadingAvailabilityRequest request = _getBookReadingAvailabilityRequestFixture.Create();
|
||||
ReadingAvailabilityDto availability = _readingAvailabilityDtoFixture.Create(bookId: request.BookId, isAvailable: true);
|
||||
_mockApiHttpClient.GetAsync<ReadingAvailabilityDto>(ApiRoutes.Books.GET_BOOK_READING_AVAILABILITY.Replace("{libraryId}", request.LibraryId.ToString()).Replace("{bookId}", request.BookId.ToString()), Arg.Any<CancellationToken>())
|
||||
.Returns(availability);
|
||||
@@ -62,7 +62,7 @@ public class GetReadingAvailabilityEndpointTests
|
||||
public async Task ExecuteAsync_WhenBookIsNotAvailable_ShouldReturnUnavailableJsonWithErrorCode()
|
||||
{
|
||||
// Arrange
|
||||
GetBookReadingAvailabilityRequest request = _requestFixture.Create();
|
||||
GetBookReadingAvailabilityRequest request = _getBookReadingAvailabilityRequestFixture.Create();
|
||||
ReadingAvailabilityDto availability = _readingAvailabilityDtoFixture.Create(bookId: request.BookId, isAvailable: false, errorCode: "ReaderDisabled");
|
||||
_mockApiHttpClient.GetAsync<ReadingAvailabilityDto>(ApiRoutes.Books.GET_BOOK_READING_AVAILABILITY.Replace("{libraryId}", request.LibraryId.ToString()).Replace("{bookId}", request.BookId.ToString()), Arg.Any<CancellationToken>())
|
||||
.Returns(availability);
|
||||
@@ -81,7 +81,7 @@ public class GetReadingAvailabilityEndpointTests
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldRequestReadingAvailabilityFromApi()
|
||||
{
|
||||
// Arrange
|
||||
GetBookReadingAvailabilityRequest request = _requestFixture.Create();
|
||||
GetBookReadingAvailabilityRequest request = _getBookReadingAvailabilityRequestFixture.Create();
|
||||
ReadingAvailabilityDto availability = _readingAvailabilityDtoFixture.Create(bookId: request.BookId, isAvailable: true);
|
||||
_mockApiHttpClient.GetAsync<ReadingAvailabilityDto>(ApiRoutes.Books.GET_BOOK_READING_AVAILABILITY.Replace("{libraryId}", request.LibraryId.ToString()).Replace("{bookId}", request.BookId.ToString()), Arg.Any<CancellationToken>())
|
||||
.Returns(availability);
|
||||
|
||||
+6
-6
@@ -30,7 +30,7 @@ public class GetReadingManifestEndpointTests
|
||||
{
|
||||
private readonly IApiHttpClient _mockApiHttpClient;
|
||||
private readonly GetReadingManifestEndpoint _sut;
|
||||
private readonly GetBookReadingManifestRequestFixture _requestFixture = new();
|
||||
private readonly GetBookReadingManifestRequestFixture _getBookReadingManifestRequestFixture = new();
|
||||
private readonly ReadingManifestDtoFixture _readingManifestDtoFixture = new();
|
||||
private readonly ProblemDetailsDtoFixture _problemDetailsDtoFixture = new();
|
||||
|
||||
@@ -47,7 +47,7 @@ public class GetReadingManifestEndpointTests
|
||||
public async Task ExecuteAsync_WhenSuccessful_ShouldReturnSuccessJsonWithManifest()
|
||||
{
|
||||
// Arrange
|
||||
GetBookReadingManifestRequest request = _requestFixture.Create();
|
||||
GetBookReadingManifestRequest request = _getBookReadingManifestRequestFixture.Create();
|
||||
ReadingManifestDto manifest = _readingManifestDtoFixture.Create();
|
||||
_mockApiHttpClient.GetAsync<ReadingManifestDto>(ApiRoutes.Books.GET_BOOK_READING_MANIFEST.Replace("{libraryId}", request.LibraryId.ToString()).Replace("{bookId}", request.BookId.ToString()), Arg.Any<CancellationToken>())
|
||||
.Returns(manifest);
|
||||
@@ -66,7 +66,7 @@ public class GetReadingManifestEndpointTests
|
||||
public async Task ExecuteAsync_WhenApiReturnsNoReaderAvailable_ShouldReturnDistinctErrorCodeJson()
|
||||
{
|
||||
// Arrange
|
||||
GetBookReadingManifestRequest request = _requestFixture.Create();
|
||||
GetBookReadingManifestRequest request = _getBookReadingManifestRequestFixture.Create();
|
||||
_mockApiHttpClient.GetAsync<ReadingManifestDto>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
.Returns<Task<ReadingManifestDto>>(_ => throw new ApiException(_problemDetailsDtoFixture.Create(detail: "NoReaderAvailable"), HttpStatusCode.NotFound));
|
||||
|
||||
@@ -84,7 +84,7 @@ public class GetReadingManifestEndpointTests
|
||||
public async Task ExecuteAsync_WhenApiReturnsReaderDisabled_ShouldReturnDistinctErrorCodeJson()
|
||||
{
|
||||
// Arrange
|
||||
GetBookReadingManifestRequest request = _requestFixture.Create();
|
||||
GetBookReadingManifestRequest request = _getBookReadingManifestRequestFixture.Create();
|
||||
_mockApiHttpClient.GetAsync<ReadingManifestDto>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
.Returns<Task<ReadingManifestDto>>(_ => throw new ApiException(_problemDetailsDtoFixture.Create(detail: "ReaderDisabled"), HttpStatusCode.NotFound));
|
||||
|
||||
@@ -102,7 +102,7 @@ public class GetReadingManifestEndpointTests
|
||||
public async Task ExecuteAsync_WhenApiReturnsUnrelatedError_ShouldRethrow()
|
||||
{
|
||||
// Arrange
|
||||
GetBookReadingManifestRequest request = _requestFixture.Create();
|
||||
GetBookReadingManifestRequest request = _getBookReadingManifestRequestFixture.Create();
|
||||
_mockApiHttpClient.GetAsync<ReadingManifestDto>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
.Returns<Task<ReadingManifestDto>>(_ => throw new ApiException(_problemDetailsDtoFixture.Create(detail: "BookNotFound"), HttpStatusCode.NotFound));
|
||||
|
||||
@@ -117,7 +117,7 @@ public class GetReadingManifestEndpointTests
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldRequestReadingManifestFromApi()
|
||||
{
|
||||
// Arrange
|
||||
GetBookReadingManifestRequest request = _requestFixture.Create();
|
||||
GetBookReadingManifestRequest request = _getBookReadingManifestRequestFixture.Create();
|
||||
ReadingManifestDto manifest = _readingManifestDtoFixture.Create();
|
||||
_mockApiHttpClient.GetAsync<ReadingManifestDto>(ApiRoutes.Books.GET_BOOK_READING_MANIFEST.Replace("{libraryId}", request.LibraryId.ToString()).Replace("{bookId}", request.BookId.ToString()), Arg.Any<CancellationToken>())
|
||||
.Returns(manifest);
|
||||
|
||||
+3
-3
@@ -26,7 +26,7 @@ public class GetReadingResourceEndpointTests
|
||||
{
|
||||
private readonly IApiHttpClient _mockApiHttpClient;
|
||||
private readonly GetReadingResourceEndpoint _sut;
|
||||
private readonly GetBookReadingResourceRequestFixture _requestFixture = new();
|
||||
private readonly GetBookReadingResourceRequestFixture _getBookReadingResourceRequestFixture = new();
|
||||
private readonly BlobDataDtoFixture _blobDataDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
@@ -42,7 +42,7 @@ public class GetReadingResourceEndpointTests
|
||||
public async Task ExecuteAsync_WhenSuccessful_ShouldReturnBytesResultWithResourceData()
|
||||
{
|
||||
// Arrange
|
||||
GetBookReadingResourceRequest request = _requestFixture.Create();
|
||||
GetBookReadingResourceRequest request = _getBookReadingResourceRequestFixture.Create();
|
||||
BlobDataDto blob = _blobDataDtoFixture.Create(contentType: "image/png");
|
||||
_mockApiHttpClient.GetBlobAsync(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
.Returns(blob);
|
||||
@@ -60,7 +60,7 @@ public class GetReadingResourceEndpointTests
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldRequestReadingResourceFromApi()
|
||||
{
|
||||
// Arrange
|
||||
GetBookReadingResourceRequest request = _requestFixture.Create();
|
||||
GetBookReadingResourceRequest request = _getBookReadingResourceRequestFixture.Create();
|
||||
BlobDataDto blob = _blobDataDtoFixture.Create();
|
||||
_mockApiHttpClient.GetBlobAsync(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
.Returns(blob);
|
||||
|
||||
+3
-3
@@ -27,7 +27,7 @@ public class GetReadingSectionEndpointTests
|
||||
{
|
||||
private readonly IApiHttpClient _mockApiHttpClient;
|
||||
private readonly GetReadingSectionEndpoint _sut;
|
||||
private readonly GetBookReadingSectionRequestFixture _requestFixture = new();
|
||||
private readonly GetBookReadingSectionRequestFixture _getBookReadingSectionRequestFixture = new();
|
||||
private readonly ReadingSectionDtoFixture _readingSectionDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
@@ -43,7 +43,7 @@ public class GetReadingSectionEndpointTests
|
||||
public async Task ExecuteAsync_WhenSuccessful_ShouldReturnSuccessJsonWithSection()
|
||||
{
|
||||
// Arrange
|
||||
GetBookReadingSectionRequest request = _requestFixture.Create();
|
||||
GetBookReadingSectionRequest request = _getBookReadingSectionRequestFixture.Create();
|
||||
ReadingSectionDto section = _readingSectionDtoFixture.Create(locationRef: request.LocationRef);
|
||||
_mockApiHttpClient.GetAsync<ReadingSectionDto>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
.Returns(section);
|
||||
@@ -62,7 +62,7 @@ public class GetReadingSectionEndpointTests
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldRequestReadingSectionFromApi()
|
||||
{
|
||||
// Arrange
|
||||
GetBookReadingSectionRequest request = _requestFixture.Create();
|
||||
GetBookReadingSectionRequest request = _getBookReadingSectionRequestFixture.Create();
|
||||
ReadingSectionDto section = _readingSectionDtoFixture.Create(locationRef: request.LocationRef);
|
||||
_mockApiHttpClient.GetAsync<ReadingSectionDto>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
.Returns(section);
|
||||
|
||||
+2
-2
@@ -21,7 +21,7 @@ namespace Lumina.Presentation.Web.UnitTests.Core.Endpoints.Library.WrittenConten
|
||||
public class ReadViewEndpointTests
|
||||
{
|
||||
private readonly ReadViewEndpoint _sut = Factory.Create<ReadViewEndpoint>();
|
||||
private readonly ReadBookViewRequestFixture _requestFixture = new();
|
||||
private readonly ReadBookViewRequestFixture _readBookViewRequestFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ReadViewEndpointTests"/> class.
|
||||
@@ -36,7 +36,7 @@ public class ReadViewEndpointTests
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldReturnTheReadRazorView()
|
||||
{
|
||||
// Arrange
|
||||
ReadBookViewRequest request = _requestFixture.Create();
|
||||
ReadBookViewRequest request = _readBookViewRequestFixture.Create();
|
||||
|
||||
// Act
|
||||
IResult result = await _sut.ExecuteAsync(request, CancellationToken.None);
|
||||
|
||||
Reference in new issue
Block a user