mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 18:21:10 +00:00
Standardizes test conventions and documentation
This commit is contained in:
1 parent
7aeed04255
commit
f42dc709de
190 files changed
+2180
-2814
No files matched your search
+1
-2
@@ -6,7 +6,6 @@ using Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.Management;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.Management;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.Library.Management.AddLibrary;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.HttpResults;
|
||||
@@ -104,7 +103,7 @@ public class AddLibraryEndpointTests
|
||||
command.CoverImage == request.CoverImage &&
|
||||
command.IsEnabled == request.IsEnabled &&
|
||||
command.IsLocked == request.IsLocked &&
|
||||
command.DownloadMetadataFromWeb == request.DownloadMetadataFromWeb &&
|
||||
command.CanDownloadMetadataFromWeb == request.CanDownloadMetadataFromWeb &&
|
||||
command.ShouldSaveMetadataInMediaDirectories == request.ShouldSaveMetadataInMediaDirectories &&
|
||||
command.ShouldSkipUnchangedDirectoriesDuringScan == request.ShouldSkipUnchangedDirectoriesDuringScan),
|
||||
Arg.Is(cancellationToken));
|
||||
|
||||
+4
-2
@@ -1,6 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Commands.ScanLibraries;
|
||||
using Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.Management;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.Library.Management.ScanLibraries;
|
||||
@@ -25,6 +26,7 @@ public class ScanLibrariesEndpointTests
|
||||
{
|
||||
private readonly ICommandHandler<ScanLibrariesCommand, Result<IEnumerable<MediaLibraryScanResponse>>> _mockHandler;
|
||||
private readonly ScanLibrariesEndpoint _sut;
|
||||
private readonly MediaLibraryScanResponseFixture _mediaLibraryScanResponseFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ScanLibrariesEndpointTests"/> class.
|
||||
@@ -42,8 +44,8 @@ public class ScanLibrariesEndpointTests
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
IEnumerable<MediaLibraryScanResponse> expectedResponses =
|
||||
[
|
||||
new MediaLibraryScanResponse(Guid.NewGuid(), Guid.NewGuid()),
|
||||
new MediaLibraryScanResponse(Guid.NewGuid(), Guid.NewGuid())
|
||||
_mediaLibraryScanResponseFixture.Create(),
|
||||
_mediaLibraryScanResponseFixture.Create()
|
||||
];
|
||||
_mockHandler.HandleAsync(Arg.Any<ScanLibrariesCommand>(), Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(expectedResponses));
|
||||
|
||||
+5
-3
@@ -2,6 +2,7 @@
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Commands.ScanLibrary;
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.Management;
|
||||
using Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.Management;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.Management;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
@@ -26,6 +27,7 @@ public class ScanLibraryEndpointTests
|
||||
private readonly ICommandHandler<ScanLibraryCommand, Result<MediaLibraryScanResponse>> _mockHandler;
|
||||
private readonly ScanLibraryEndpoint _sut;
|
||||
private readonly ScanLibraryRequestFixture _scanLibraryRequestFixture = new();
|
||||
private readonly MediaLibraryScanResponseFixture _mediaLibraryScanResponseFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ScanLibraryEndpointTests"/> class.
|
||||
@@ -42,7 +44,7 @@ public class ScanLibraryEndpointTests
|
||||
// Arrange
|
||||
ScanLibraryRequest request = _scanLibraryRequestFixture.Create();
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
MediaLibraryScanResponse expectedResponse = new(Guid.NewGuid(), request.Id);
|
||||
MediaLibraryScanResponse expectedResponse = _mediaLibraryScanResponseFixture.Create(libraryId: request.Id);
|
||||
_mockHandler.HandleAsync(Arg.Any<ScanLibraryCommand>(), Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(expectedResponse));
|
||||
|
||||
@@ -87,7 +89,7 @@ public class ScanLibraryEndpointTests
|
||||
ScanLibraryRequest request = _scanLibraryRequestFixture.Create();
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
_mockHandler.HandleAsync(Arg.Any<ScanLibraryCommand>(), Arg.Any<CancellationToken>())
|
||||
.Returns(Result.From(new MediaLibraryScanResponse(Guid.NewGuid(), request.Id)));
|
||||
.Returns(Result.From(_mediaLibraryScanResponseFixture.Create(libraryId: request.Id)));
|
||||
|
||||
// Act
|
||||
await _sut.ExecuteAsync(request, cancellationToken);
|
||||
@@ -113,7 +115,7 @@ public class ScanLibraryEndpointTests
|
||||
operationStarted.SetResult(true);
|
||||
await cancellationRequested.Task;
|
||||
callInfo.Arg<CancellationToken>().ThrowIfCancellationRequested();
|
||||
return Result.From(new MediaLibraryScanResponse(Guid.NewGuid(), request.Id));
|
||||
return Result.From(_mediaLibraryScanResponseFixture.Create(libraryId: request.Id));
|
||||
}, callInfo.Arg<CancellationToken>()));
|
||||
|
||||
// Act
|
||||
|
||||
+1
-2
@@ -6,7 +6,6 @@ using Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.Management;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.Management;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.Library.Management.UpdateLibrary;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.HttpResults;
|
||||
@@ -106,7 +105,7 @@ public class UpdateLibraryEndpointTests
|
||||
command.CoverImage == request.CoverImage &&
|
||||
command.IsEnabled == request.IsEnabled &&
|
||||
command.IsLocked == request.IsLocked &&
|
||||
command.DownloadMetadataFromWeb == request.DownloadMetadataFromWeb &&
|
||||
command.CanDownloadMetadataFromWeb == request.CanDownloadMetadataFromWeb &&
|
||||
command.ShouldSaveMetadataInMediaDirectories == request.ShouldSaveMetadataInMediaDirectories &&
|
||||
command.ShouldSkipUnchangedDirectoriesDuringScan == request.ShouldSkipUnchangedDirectoriesDuringScan),
|
||||
Arg.Is(cancellationToken));
|
||||
|
||||
+3
-1
@@ -1,5 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.Library.WrittenContentLibrary.BookLibrary.Books.GetBook;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
@@ -19,12 +20,13 @@ namespace Lumina.Presentation.Api.UnitTests.Core.Endpoints.Library.WrittenConten
|
||||
public class GetBookEndpointTests
|
||||
{
|
||||
private readonly GetBookEndpoint _sut = Factory.Create<GetBookEndpoint>();
|
||||
private readonly GetBookRequestFixture _getBookRequestFixture = new();
|
||||
|
||||
[Fact]
|
||||
public async Task ExecuteAsync_WhenCalled_ShouldReturnOkResult()
|
||||
{
|
||||
// Arrange
|
||||
GetBookRequest request = new(Guid.NewGuid().ToString());
|
||||
GetBookRequest request = _getBookRequestFixture.Create(id: Guid.NewGuid().ToString());
|
||||
CancellationToken cancellationToken = CancellationToken.None;
|
||||
|
||||
// Act
|
||||
|
||||
+5
-12
@@ -2,15 +2,14 @@
|
||||
using FastEndpoints;
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Queries.GetBooks;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary;
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Contracts.Fixtures.Responses.Common;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Contracts.Responses.Common;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.Library.WrittenContentLibrary.BookLibrary.Books.GetBooks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.HttpResults;
|
||||
@@ -34,6 +33,7 @@ public class GetBooksEndpointTests
|
||||
private readonly GetBooksEndpoint _sut;
|
||||
private readonly GetBooksRequestFixture _getBooksRequestFixture = new();
|
||||
private readonly BookResponseFixture _bookResponseFixture = new();
|
||||
private readonly PaginatedResponseFixture<BookResponse> _paginatedResponseFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetBooksEndpointTests"/> class.
|
||||
@@ -171,19 +171,12 @@ public class GetBooksEndpointTests
|
||||
/// </summary>
|
||||
/// <param name="bookCount">The number of book responses to include in the data collection.</param>
|
||||
/// <returns>A configured paginated response instance.</returns>
|
||||
private static PaginatedResponse<BookResponse> CreatePaginatedResponse(int bookCount, BookResponseFixture bookResponseFixture)
|
||||
private PaginatedResponse<BookResponse> CreatePaginatedResponse(int bookCount, BookResponseFixture bookResponseFixture)
|
||||
{
|
||||
List<BookResponse> books = [];
|
||||
for (int index = 0; index < bookCount; index++)
|
||||
books.Add(bookResponseFixture.Create());
|
||||
|
||||
return new PaginatedResponse<BookResponse>
|
||||
{
|
||||
Data = books,
|
||||
CurrentPage = 1,
|
||||
PerPage = 10,
|
||||
Count = bookCount,
|
||||
NumberOfPages = bookCount > 0 ? 1 : 0
|
||||
};
|
||||
return _paginatedResponseFixture.Create(data: books, currentPage: 1, perPage: 10, count: bookCount, numberOfPages: bookCount > 0 ? 1 : 0);
|
||||
}
|
||||
}
|
||||
+12
-15
@@ -3,11 +3,13 @@ using FastEndpoints;
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Queries.GetBooksLite;
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Contracts.Fixtures.Responses.Common;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Contracts.Responses.Common;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.Library.WrittenContentLibrary.BookLibrary.Books.GetBooksLite;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.HttpResults;
|
||||
@@ -30,6 +32,8 @@ public class GetBooksLiteEndpointTests
|
||||
private readonly IQueryHandler<GetBooksLiteQuery, Result<PaginatedResponse<BookLiteResponse>>> _mockHandler;
|
||||
private readonly GetBooksLiteEndpoint _sut;
|
||||
private readonly GetBooksLiteRequestFixture _getBooksLiteRequestFixture = new();
|
||||
private readonly BookLiteResponseFixture _bookLiteResponseFixture = new();
|
||||
private readonly PaginatedResponseFixture<BookLiteResponse> _paginatedResponseFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetBooksLiteEndpointTests"/> class.
|
||||
@@ -167,24 +171,17 @@ public class GetBooksLiteEndpointTests
|
||||
/// </summary>
|
||||
/// <param name="bookCount">The number of book responses to include in the data collection.</param>
|
||||
/// <returns>A configured paginated response instance.</returns>
|
||||
private static PaginatedResponse<BookLiteResponse> CreatePaginatedResponse(int bookCount)
|
||||
private PaginatedResponse<BookLiteResponse> CreatePaginatedResponse(int bookCount)
|
||||
{
|
||||
List<BookLiteResponse> books = [];
|
||||
for (int index = 0; index < bookCount; index++)
|
||||
books.Add(new BookLiteResponse(
|
||||
Id: Guid.NewGuid(),
|
||||
Title: "Test Book",
|
||||
ReleaseYear: 2001,
|
||||
CoverPath: null
|
||||
books.Add(_bookLiteResponseFixture.Create(
|
||||
id: Guid.NewGuid(),
|
||||
title: "Test Book",
|
||||
releaseYear: 2001,
|
||||
coverPath: null
|
||||
));
|
||||
|
||||
return new PaginatedResponse<BookLiteResponse>
|
||||
{
|
||||
Data = books,
|
||||
CurrentPage = 1,
|
||||
PerPage = 10,
|
||||
Count = bookCount,
|
||||
NumberOfPages = bookCount > 0 ? 1 : 0
|
||||
};
|
||||
return _paginatedResponseFixture.Create(data: books, currentPage: 1, perPage: 10, count: bookCount, numberOfPages: bookCount > 0 ? 1 : 0);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user