Merge branch 'refactor/standardize-test-fixtures-and-docs' into feature/add-artwork-provider-and-metadata-aggregation

This commit is contained in:
BinaryAlley committed 2026-08-24 22:56:22 -07:00
commit 4ff184d8a5
388 files changed
+13829 -2814

No files matched your search

@@ -6,6 +6,7 @@ using Lumina.Presentation.Web.Common.Enums.Authorization;
using Lumina.Presentation.Web.Common.Requests.Authorization;
using Lumina.Presentation.Web.Common.Routes;
using Lumina.Presentation.Web.Core.Endpoints.Admin.Authorization.Roles.AddRole;
using Lumina.Presentation.Web.Fixtures.Common.DTO.Authorization;
using Lumina.Presentation.Web.Fixtures.Common.Requests.Authorization;
using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
using Microsoft.AspNetCore.Http;
@@ -29,6 +30,9 @@ public class AddRoleEndpointTests
private readonly IApiHttpClient _mockApiHttpClient;
private readonly AddRoleEndpoint _sut;
private readonly AddRoleRequestFixture _addRoleRequestFixture = new();
private readonly RoleDtoFixture _roleDtoFixture = new();
private readonly PermissionDtoFixture _permissionDtoFixture = new();
private readonly RolePermissionsDtoFixture _rolePermissionsDtoFixture = new();
/// <summary>
/// Initializes a new instance of the <see cref="AddRoleEndpointTests"/> class.
@@ -44,7 +48,7 @@ public class AddRoleEndpointTests
{
// Arrange
AddRoleRequest request = _addRoleRequestFixture.Create();
RolePermissionsDto expectedResponse = new(new RoleDto(Guid.NewGuid(), request.RoleName!), [new PermissionDto(Guid.NewGuid(), AuthorizationPermission.CanViewUsers)]);
RolePermissionsDto expectedResponse = _rolePermissionsDtoFixture.Create(role: _roleDtoFixture.Create(id: Guid.NewGuid(), roleName: request.RoleName!), permissions: [_permissionDtoFixture.Create(id: Guid.NewGuid(), permission: AuthorizationPermission.CanViewUsers)]);
_mockApiHttpClient.PostAsync<RolePermissionsDto, AddRoleRequest>(Arg.Any<string>(), Arg.Any<AddRoleRequest>(), Arg.Any<CancellationToken>())
.Returns(expectedResponse);
@@ -1,15 +1,14 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Presentation.Web.Common.Api;
using Lumina.Presentation.Web.Common.Requests.Themes;
using Lumina.Presentation.Web.Common.Routes;
using Lumina.Presentation.Web.Core.Endpoints.Admin.Themes.DeleteTheme;
using Lumina.Presentation.Web.Core.Themes;
using Lumina.Presentation.Web.Fixtures.Common.Requests.Themes;
using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.HttpResults;
using NSubstitute;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
@@ -25,6 +24,7 @@ public class DeleteThemeEndpointTests
{
private readonly IApiHttpClient _mockApiHttpClient;
private readonly DeleteThemeEndpoint _sut;
private readonly DeleteThemeRequestFixture _deleteThemeRequestFixture = new();
/// <summary>
/// Initializes a new instance of the <see cref="DeleteThemeEndpointTests"/> class.
@@ -43,14 +43,12 @@ public class DeleteThemeEndpointTests
string themeId = "editorial-paper";
// Act
IResult result = await _sut.ExecuteAsync(new DeleteThemeRequest(themeId), CancellationToken.None);
IResult result = await _sut.ExecuteAsync(_deleteThemeRequestFixture.Create(themeId: themeId), CancellationToken.None);
string body = await JsonResultTestHelper.GetResponseBodyAsync(result);
// Assert
using (System.Text.Json.JsonDocument jsonDocument = System.Text.Json.JsonDocument.Parse(body))
{
Assert.True(jsonDocument.RootElement.GetProperty("success").GetBoolean());
}
}
[Fact]
@@ -61,7 +59,7 @@ public class DeleteThemeEndpointTests
string expectedEndpoint = ApiRoutes.Themes.DELETE_THEME.Replace("{themeId}", themeId);
// Act
await _sut.ExecuteAsync(new DeleteThemeRequest(themeId), CancellationToken.None);
await _sut.ExecuteAsync(_deleteThemeRequestFixture.Create(themeId: themeId), CancellationToken.None);
// Assert
await _mockApiHttpClient.Received(1).DeleteAsync(expectedEndpoint, Arg.Any<CancellationToken>());
@@ -74,7 +72,7 @@ public class DeleteThemeEndpointTests
public async Task ExecuteAsync_WhenThemeIdIsBlank_ShouldReturnProblemWithBadRequest(string? themeId)
{
// Act
IResult result = await _sut.ExecuteAsync(new DeleteThemeRequest(themeId), CancellationToken.None);
IResult result = await _sut.ExecuteAsync(_deleteThemeRequestFixture.Create(themeId: themeId), CancellationToken.None);
// Assert
ProblemHttpResult problemResult = Assert.IsType<ProblemHttpResult>(result);
@@ -2,16 +2,15 @@
using FastEndpoints;
using Lumina.Presentation.Web.Common.Api;
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
using Lumina.Presentation.Web.Common.Requests.Themes;
using Lumina.Presentation.Web.Common.Routes;
using Lumina.Presentation.Web.Core.Endpoints.Admin.Themes.DownloadTheme;
using Lumina.Presentation.Web.Core.Themes;
using Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
using Lumina.Presentation.Web.Fixtures.Common.Requests.Themes;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.HttpResults;
using NSubstitute;
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
#endregion
@@ -26,6 +25,8 @@ public class DownloadThemeEndpointTests
{
private readonly IApiHttpClient _mockApiHttpClient;
private readonly DownloadThemeEndpoint _sut;
private readonly GetThemeArchiveRequestFixture _getThemeArchiveRequestFixture = new();
private readonly BlobDataDtoFixture _blobDataDtoFixture = new();
/// <summary>
/// Initializes a new instance of the <see cref="DownloadThemeEndpointTests"/> class.
@@ -43,10 +44,10 @@ public class DownloadThemeEndpointTests
// Arrange
string themeId = "editorial-paper";
_mockApiHttpClient.GetBlobAsync(Arg.Any<string>(), Arg.Any<CancellationToken>())
.Returns(new BlobDataDto { Data = [0x50, 0x4B, 0x03, 0x04], ContentType = "application/zip" });
.Returns(_blobDataDtoFixture.Create(data: [0x50, 0x4B, 0x03, 0x04], contentType: "application/zip"));
// Act
IResult result = await _sut.ExecuteAsync(new GetThemeArchiveRequest(themeId), CancellationToken.None);
IResult result = await _sut.ExecuteAsync(_getThemeArchiveRequestFixture.Create(themeId: themeId), CancellationToken.None);
// Assert
FileStreamHttpResult fileResult = Assert.IsType<FileStreamHttpResult>(result);
@@ -61,10 +62,10 @@ public class DownloadThemeEndpointTests
string themeId = "editorial-paper";
string expectedEndpoint = ApiRoutes.Themes.GET_THEME_ARCHIVE.Replace("{themeId}", themeId);
_mockApiHttpClient.GetBlobAsync(expectedEndpoint, Arg.Any<CancellationToken>())
.Returns(new BlobDataDto { Data = [1, 2, 3], ContentType = "application/zip" });
.Returns(_blobDataDtoFixture.Create(data: [1, 2, 3], contentType: "application/zip"));
// Act
await _sut.ExecuteAsync(new GetThemeArchiveRequest(themeId), CancellationToken.None);
await _sut.ExecuteAsync(_getThemeArchiveRequestFixture.Create(themeId: themeId), CancellationToken.None);
// Assert
await _mockApiHttpClient.Received(1).GetBlobAsync(expectedEndpoint, Arg.Any<CancellationToken>());
@@ -77,7 +78,7 @@ public class DownloadThemeEndpointTests
public async Task ExecuteAsync_WhenThemeIdIsBlank_ShouldReturnProblemWithBadRequest(string? themeId)
{
// Act
IResult result = await _sut.ExecuteAsync(new GetThemeArchiveRequest(themeId), CancellationToken.None);
IResult result = await _sut.ExecuteAsync(_getThemeArchiveRequestFixture.Create(themeId: themeId), CancellationToken.None);
// Assert
ProblemHttpResult problemResult = Assert.IsType<ProblemHttpResult>(result);
@@ -2,15 +2,14 @@
using FastEndpoints;
using Lumina.Presentation.Web.Common.Api;
using Lumina.Presentation.Web.Common.DTO.Themes;
using Lumina.Presentation.Web.Common.Requests.Themes;
using Lumina.Presentation.Web.Common.Routes;
using Lumina.Presentation.Web.Core.Endpoints.Admin.Themes.RestoreTheme;
using Lumina.Presentation.Web.Core.Themes;
using Lumina.Presentation.Web.Fixtures.Common.Requests.Themes;
using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.HttpResults;
using NSubstitute;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
@@ -26,6 +25,7 @@ public class RestoreThemeEndpointTests
{
private readonly IApiHttpClient _mockApiHttpClient;
private readonly RestoreThemeEndpoint _sut;
private readonly RestoreThemeRequestFixture _restoreThemeRequestFixture = new();
/// <summary>
/// Initializes a new instance of the <see cref="RestoreThemeEndpointTests"/> class.
@@ -44,7 +44,7 @@ public class RestoreThemeEndpointTests
string themeId = "editorial-paper";
// Act
IResult result = await _sut.ExecuteAsync(new RestoreThemeRequest(themeId), CancellationToken.None);
IResult result = await _sut.ExecuteAsync(_restoreThemeRequestFixture.Create(themeId: themeId), CancellationToken.None);
string body = await JsonResultTestHelper.GetResponseBodyAsync(result);
// Assert
@@ -62,7 +62,7 @@ public class RestoreThemeEndpointTests
string expectedEndpoint = ApiRoutes.Themes.RESTORE_THEME.Replace("{themeId}", themeId);
// Act
await _sut.ExecuteAsync(new RestoreThemeRequest(themeId), CancellationToken.None);
await _sut.ExecuteAsync(_restoreThemeRequestFixture.Create(themeId: themeId), CancellationToken.None);
// Assert
await _mockApiHttpClient.Received(1).PostAsync<ThemeResponseDto, object>(expectedEndpoint, Arg.Any<object>(), Arg.Any<CancellationToken>());
@@ -75,7 +75,7 @@ public class RestoreThemeEndpointTests
public async Task ExecuteAsync_WhenThemeIdIsBlank_ShouldReturnProblemWithBadRequest(string? themeId)
{
// Act
IResult result = await _sut.ExecuteAsync(new RestoreThemeRequest(themeId), CancellationToken.None);
IResult result = await _sut.ExecuteAsync(_restoreThemeRequestFixture.Create(themeId: themeId), CancellationToken.None);
// Assert
ProblemHttpResult problemResult = Assert.IsType<ProblemHttpResult>(result);
@@ -2,16 +2,15 @@
using FastEndpoints;
using Lumina.Presentation.Web.Common.Api;
using Lumina.Presentation.Web.Common.DTO.Themes;
using Lumina.Presentation.Web.Common.Requests.Themes;
using Lumina.Presentation.Web.Common.Routes;
using Lumina.Presentation.Web.Core.Endpoints.Admin.Themes.SetCurrentTheme;
using Lumina.Presentation.Web.Core.Themes;
using Lumina.Presentation.Web.Fixtures.Common.DTO.Themes;
using Lumina.Presentation.Web.Fixtures.Common.Requests.Themes;
using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.HttpResults;
using NSubstitute;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
@@ -28,6 +27,7 @@ public class SetCurrentThemeEndpointTests
private readonly IApiHttpClient _mockApiHttpClient;
private readonly SetCurrentThemeEndpoint _sut;
private readonly ThemeResponseDtoFixture _themeResponseDtoFixture = new();
private readonly SetCurrentThemeRequestFixture _setCurrentThemeRequestFixture = new();
/// <summary>
/// Initializes a new instance of the <see cref="SetCurrentThemeEndpointTests"/> class.
@@ -48,7 +48,7 @@ public class SetCurrentThemeEndpointTests
.Returns(_themeResponseDtoFixture.Create());
// Act
IResult result = await _sut.ExecuteAsync(new SetCurrentThemeRequest(themeId), CancellationToken.None);
IResult result = await _sut.ExecuteAsync(_setCurrentThemeRequestFixture.Create(themeId: themeId), CancellationToken.None);
string body = await JsonResultTestHelper.GetResponseBodyAsync(result);
// Assert
@@ -68,7 +68,7 @@ public class SetCurrentThemeEndpointTests
public async Task ExecuteAsync_WhenThemeIdIsBlank_ShouldReturnProblemWithBadRequest(string? themeId)
{
// Act
IResult result = await _sut.ExecuteAsync(new SetCurrentThemeRequest(themeId), CancellationToken.None);
IResult result = await _sut.ExecuteAsync(_setCurrentThemeRequestFixture.Create(themeId: themeId), CancellationToken.None);
// Assert
ProblemHttpResult problemResult = Assert.IsType<ProblemHttpResult>(result);
@@ -5,6 +5,7 @@ using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
using Lumina.Presentation.Web.Common.Requests.FileSystemManagement.Directories;
using Lumina.Presentation.Web.Common.Routes;
using Lumina.Presentation.Web.Core.Endpoints.FileSystemManagement.Directories.GetDirectories;
using Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
using Lumina.Presentation.Web.Fixtures.Common.Requests.FileSystemManagement.Directories;
using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
using Microsoft.AspNetCore.Http;
@@ -27,6 +28,7 @@ public class GetDirectoriesEndpointTests
private readonly IApiHttpClient _mockApiHttpClient;
private readonly GetDirectoriesEndpoint _sut;
private readonly GetDirectoriesRequestFixture _getDirectoriesRequestFixture = new();
private readonly DirectoryDtoFixture _directoryDtoFixture = new();
/// <summary>
/// Initializes a new instance of the <see cref="GetDirectoriesEndpointTests"/> class.
@@ -42,7 +44,7 @@ public class GetDirectoriesEndpointTests
{
// Arrange
GetDirectoriesRequest request = _getDirectoriesRequestFixture.Create(path: "/media", includeHiddenElements: true);
DirectoryDto[] expectedDirectories = [new DirectoryDto { Path = "/media/books", Name = "books" }];
DirectoryDto[] expectedDirectories = [_directoryDtoFixture.Create(path: "/media/books", name: "books")];
_mockApiHttpClient.GetAsync<DirectoryDto[]>(Arg.Any<string>(), Arg.Any<CancellationToken>())
.Returns(expectedDirectories);
@@ -5,6 +5,7 @@ using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
using Lumina.Presentation.Web.Common.Requests.FileSystemManagement.Path;
using Lumina.Presentation.Web.Common.Routes;
using Lumina.Presentation.Web.Core.Endpoints.FileSystemManagement.Path.ValidatePath;
using Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
using Lumina.Presentation.Web.Fixtures.Common.Requests.FileSystemManagement.Path;
using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
using Microsoft.AspNetCore.Http;
@@ -27,6 +28,7 @@ public class ValidatePathEndpointTests
private readonly IApiHttpClient _mockApiHttpClient;
private readonly ValidatePathEndpoint _sut;
private readonly ValidatePathRequestFixture _validatePathRequestFixture = new();
private readonly PathValidDtoFixture _pathValidDtoFixture = new();
/// <summary>
/// Initializes a new instance of the <see cref="ValidatePathEndpointTests"/> class.
@@ -43,7 +45,7 @@ public class ValidatePathEndpointTests
// Arrange
ValidatePathRequest request = _validatePathRequestFixture.Create(path: "/media/books");
_mockApiHttpClient.GetAsync<PathValidDto>(Arg.Any<string>(), Arg.Any<CancellationToken>())
.Returns(new PathValidDto(true));
.Returns(_pathValidDtoFixture.Create(isValid: true));
// Act
IResult result = await _sut.ExecuteAsync(request, CancellationToken.None);
@@ -63,7 +65,7 @@ public class ValidatePathEndpointTests
// Arrange
ValidatePathRequest request = _validatePathRequestFixture.Create(path: "C:/invalid|path");
_mockApiHttpClient.GetAsync<PathValidDto>(Arg.Any<string>(), Arg.Any<CancellationToken>())
.Returns(new PathValidDto(false));
.Returns(_pathValidDtoFixture.Create(isValid: false));
// Act
IResult result = await _sut.ExecuteAsync(request, CancellationToken.None);
@@ -6,6 +6,7 @@ using Lumina.Presentation.Web.Common.Enums.Common;
using Lumina.Presentation.Web.Common.Requests.Libraries;
using Lumina.Presentation.Web.Common.Routes;
using Lumina.Presentation.Web.Core.Endpoints.Library.WrittenContentLibrary.BookLibrary.Books.GetLibraryItems;
using Lumina.Presentation.Web.Fixtures.Common.DTO.Libraries;
using Lumina.Presentation.Web.Fixtures.Common.Requests.Libraries;
using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
using Microsoft.AspNetCore.Http;
@@ -29,6 +30,8 @@ public class GetLibraryItemsEndpointTests
private readonly IApiHttpClient _mockApiHttpClient;
private readonly GetLibraryItemsEndpoint _sut;
private readonly GetBooksLiteRequestFixture _getBooksLiteRequestFixture = new();
private readonly PaginatedBookLiteDtoFixture _paginatedBookLiteDtoFixture = new();
private readonly BookLiteDtoFixture _bookLiteDtoFixture = new();
/// <summary>
/// Initializes a new instance of the <see cref="GetLibraryItemsEndpointTests"/> class.
@@ -48,11 +51,11 @@ public class GetLibraryItemsEndpointTests
perPage: 48,
searchTerm: "the hobbit",
filterAlphaKey: "H",
ignoreThePrefixForAlphaPicker: true,
shouldIgnoreThePrefixForAlphaPicker: true,
sortBy: "title",
sortOrder: SortOrder.Ascending);
_mockApiHttpClient.GetAsync<PaginatedBookLiteDto>(Arg.Any<string>(), Arg.Any<CancellationToken>())
.Returns(new PaginatedBookLiteDto());
.Returns(_paginatedBookLiteDtoFixture.Create());
// Act
await _sut.ExecuteAsync(request, CancellationToken.None);
@@ -66,7 +69,7 @@ public class GetLibraryItemsEndpointTests
endpoint.Contains("perPage=48") &&
endpoint.Contains("searchTerm=the%20hobbit") &&
endpoint.Contains("filterAlphaKey=H") &&
endpoint.Contains("ignoreThePrefixForAlphaPicker=True") &&
endpoint.Contains("shouldIgnoreThePrefixForAlphaPicker=True") &&
endpoint.Contains("sortBy=title") &&
endpoint.Contains("sortOrder=Ascending")),
Arg.Any<CancellationToken>());
@@ -78,7 +81,7 @@ public class GetLibraryItemsEndpointTests
// Arrange
GetBooksLiteRequest request = _getBooksLiteRequestFixture.Create();
_mockApiHttpClient.GetAsync<PaginatedBookLiteDto>(Arg.Any<string>(), Arg.Any<CancellationToken>())
.Returns(new PaginatedBookLiteDto());
.Returns(_paginatedBookLiteDtoFixture.Create());
// Act
await _sut.ExecuteAsync(request, CancellationToken.None);
@@ -87,7 +90,7 @@ public class GetLibraryItemsEndpointTests
await _mockApiHttpClient.Received(1).GetAsync<PaginatedBookLiteDto>(
Arg.Is<string>(endpoint =>
endpoint.StartsWith(ApiRoutes.Books.GET_BOOKS_LITE, StringComparison.OrdinalIgnoreCase) &&
endpoint.EndsWith($"libraryId={request.LibraryId}&ignoreThePrefixForAlphaPicker=False", StringComparison.OrdinalIgnoreCase) &&
endpoint.EndsWith($"libraryId={request.LibraryId}&shouldIgnoreThePrefixForAlphaPicker=False", StringComparison.OrdinalIgnoreCase) &&
!endpoint.Contains("currentPage=") &&
!endpoint.Contains("searchTerm=") &&
!endpoint.Contains("sortBy=")),
@@ -99,14 +102,12 @@ public class GetLibraryItemsEndpointTests
{
// Arrange
GetBooksLiteRequest request = _getBooksLiteRequestFixture.Create();
PaginatedBookLiteDto expectedResponse = new()
{
CurrentPage = 1,
PerPage = 48,
Count = 1,
NumberOfPages = 1,
Data = [new BookLiteDto { Id = Guid.NewGuid(), Title = "Test Book" }]
};
PaginatedBookLiteDto expectedResponse = _paginatedBookLiteDtoFixture.Create(
data: [_bookLiteDtoFixture.Create(title: "Test Book")],
currentPage: 1,
perPage: 48,
count: 1,
numberOfPages: 1);
_mockApiHttpClient.GetAsync<PaginatedBookLiteDto>(Arg.Any<string>(), Arg.Any<CancellationToken>())
.Returns(expectedResponse);
@@ -5,19 +5,19 @@ using Lumina.Presentation.Web.Common.DTO.Libraries;
using Lumina.Presentation.Web.Common.DTO.Themes;
using Lumina.Presentation.Web.Common.Http;
using Lumina.Presentation.Web.Common.Primitives;
using Lumina.Presentation.Web.Common.Requests.Library.WrittenContentLibrary.BookLibrary.Books;
using Lumina.Presentation.Web.Common.Routes;
using Lumina.Presentation.Web.Common.Services;
using Lumina.Presentation.Web.Core.Endpoints.Library.WrittenContentLibrary.BookLibrary.Books.Index;
using Lumina.Presentation.Web.Core.Themes;
using Lumina.Presentation.Web.Fixtures.Common.DTO.Libraries;
using Lumina.Presentation.Web.Fixtures.Common.DTO.Themes;
using Lumina.Presentation.Web.Fixtures.Common.Requests.Library.WrittenContentLibrary.BookLibrary.Books;
using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.Extensions.Localization;
using NSubstitute;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
@@ -38,6 +38,8 @@ public class BooksIndexViewEndpointTests
private readonly IStringLocalizer _mockStringLocalizer;
private readonly BooksIndexViewEndpoint _sut;
private readonly LibraryDtoFixture _libraryDtoFixture = new();
private readonly GetBooksViewRequestFixture _getBooksViewRequestFixture = new();
private readonly ThemePageRenderResultDtoFixture _themePageRenderResultDtoFixture = new();
/// <summary>
/// Initializes a new instance of the <see cref="BooksIndexViewEndpointTests"/> class.
@@ -63,7 +65,7 @@ public class BooksIndexViewEndpointTests
_mockUrlService.GetAbsoluteUrl(WebRoutes.Home.INDEX_CULTURED).Returns("http://localhost/en-us");
// Act
IResult result = await _sut.ExecuteAsync(new GetBooksViewRequest(null), CancellationToken.None);
IResult result = await _sut.ExecuteAsync(_getBooksViewRequestFixture.Create(libraryId: null), CancellationToken.None);
// Assert
RedirectHttpResult redirectResult = Assert.IsType<RedirectHttpResult>(result);
@@ -82,10 +84,10 @@ public class BooksIndexViewEndpointTests
_mockUrlService.GetAbsoluteUrl(WebRoutes.Books.GET_LIBRARY_ITEMS).Returns("http://localhost/en-us/library/written-content-library/books-library/books/api-get-library-items");
_mockUrlService.GetAbsoluteUrl(WebRoutes.Settings.GET_USER_SETTINGS).Returns("http://localhost/en-us/tools/settings/api-get-user-settings");
_mockThemePageRenderer.RenderAsync(Arg.Any<ThemePageDto>(), Arg.Any<string?>(), Arg.Any<CancellationToken>())
.Returns(Result.From(new ThemePageRenderResultDto("<section>content</section>", "<script>script</script>")));
.Returns(Result.From(_themePageRenderResultDtoFixture.Create(content: "<section>content</section>", script: "<script>script</script>")));
// Act
IResult result = await _sut.ExecuteAsync(new GetBooksViewRequest(expectedLibrary.Id), CancellationToken.None);
IResult result = await _sut.ExecuteAsync(_getBooksViewRequestFixture.Create(libraryId: expectedLibrary.Id), CancellationToken.None);
// Assert
Assert.IsType<RazorViewResult>(result);
@@ -115,7 +117,7 @@ public class BooksIndexViewEndpointTests
.Returns(Result<ThemePageRenderResultDto>.Failure(Error.Failure("Theme.Render", "The page could not be rendered.")));
// Act
IResult result = await _sut.ExecuteAsync(new GetBooksViewRequest(expectedLibrary.Id), CancellationToken.None);
IResult result = await _sut.ExecuteAsync(_getBooksViewRequestFixture.Create(libraryId: expectedLibrary.Id), CancellationToken.None);
// Assert
Assert.IsType<RazorViewResult>(result);
@@ -1,14 +1,13 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Presentation.Web.Common.Api;
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
using Lumina.Presentation.Web.Common.Requests.Themes;
using Lumina.Presentation.Web.Common.Routes;
using Lumina.Presentation.Web.Core.Endpoints.Themes.ThemeAssets;
using Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
using Lumina.Presentation.Web.Fixtures.Common.Requests.Themes;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.HttpResults;
using NSubstitute;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
@@ -24,6 +23,8 @@ public class ThemeAssetsEndpointTests
{
private readonly IApiHttpClient _mockApiHttpClient;
private readonly ThemeAssetsEndpoint _sut;
private readonly GetThemeAssetRequestFixture _getThemeAssetRequestFixture = new();
private readonly BlobDataDtoFixture _blobDataDtoFixture = new();
/// <summary>
/// Initializes a new instance of the <see cref="ThemeAssetsEndpointTests"/> class.
@@ -39,10 +40,10 @@ public class ThemeAssetsEndpointTests
{
// Arrange
_mockApiHttpClient.GetBlobAsync(Arg.Any<string>(), Arg.Any<CancellationToken>())
.Returns(new BlobDataDto { Data = [1, 2, 3], ContentType = "text/css" });
.Returns(_blobDataDtoFixture.Create(data: [1, 2, 3], contentType: "text/css"));
// Act
IResult result = await _sut.ExecuteAsync(new GetThemeAssetRequest(ThemeId: "editorial-paper", Path: "assets/style.css"), CancellationToken.None);
IResult result = await _sut.ExecuteAsync(_getThemeAssetRequestFixture.Create(themeId: "editorial-paper", path: "assets/style.css"), CancellationToken.None);
// Assert
FileContentHttpResult fileResult = Assert.IsType<FileContentHttpResult>(result);
@@ -57,7 +58,7 @@ public class ThemeAssetsEndpointTests
public async Task ExecuteAsync_WhenAssetPathMissing_ShouldReturnProblem()
{
// Act
IResult result = await _sut.ExecuteAsync(new GetThemeAssetRequest(ThemeId: "editorial-paper", Path: null), CancellationToken.None);
IResult result = await _sut.ExecuteAsync(_getThemeAssetRequestFixture.Create(themeId: "editorial-paper", path: null), CancellationToken.None);
// Assert
ProblemHttpResult problemResult = Assert.IsType<ProblemHttpResult>(result);
@@ -1,7 +1,7 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Presentation.Web.Common.Requests.Tools;
using Lumina.Presentation.Web.Core.Endpoints.Tools.Language.SetLanguage;
using Lumina.Presentation.Web.Fixtures.Common.Requests.Tools;
using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.HttpResults;
@@ -20,6 +20,7 @@ namespace Lumina.Presentation.Web.UnitTests.Core.Endpoints.Tools.Language.SetLan
public class SetLanguageEndpointTests
{
private readonly SetLanguageEndpoint _sut;
private readonly SetLanguageRequestFixture _setLanguageRequestFixture = new();
/// <summary>
/// Initializes a new instance of the <see cref="SetLanguageEndpointTests"/> class.
@@ -36,7 +37,7 @@ public class SetLanguageEndpointTests
TestHttpContextFactory.ConfigureCulture(_sut.HttpContext, "en-us");
// Act
IResult result = await _sut.ExecuteAsync(new SetLanguageRequest("de-DE", null), CancellationToken.None);
IResult result = await _sut.ExecuteAsync(_setLanguageRequestFixture.Create(newCulture: "de-DE"), CancellationToken.None);
// Assert
RedirectHttpResult redirectResult = Assert.IsType<RedirectHttpResult>(result);
@@ -54,7 +55,7 @@ public class SetLanguageEndpointTests
TestHttpContextFactory.ConfigureCulture(_sut.HttpContext, "en-us");
// Act
IResult result = await _sut.ExecuteAsync(new SetLanguageRequest("de-DE", "/en-us/tools/settings"), CancellationToken.None);
IResult result = await _sut.ExecuteAsync(_setLanguageRequestFixture.Create(newCulture: "de-DE", returnUrl: "/en-us/tools/settings"), CancellationToken.None);
// Assert
RedirectHttpResult redirectResult = Assert.IsType<RedirectHttpResult>(result);
@@ -69,7 +70,7 @@ public class SetLanguageEndpointTests
_sut.HttpContext.Request.PathBase = "/lumina";
// Act
IResult result = await _sut.ExecuteAsync(new SetLanguageRequest("fr-FR", "/en-us/tools/settings"), CancellationToken.None);
IResult result = await _sut.ExecuteAsync(_setLanguageRequestFixture.Create(newCulture: "fr-FR", returnUrl: "/en-us/tools/settings"), CancellationToken.None);
// Assert
RedirectHttpResult redirectResult = Assert.IsType<RedirectHttpResult>(result);
@@ -1,15 +1,14 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Presentation.Web.Common.Http;
using Lumina.Presentation.Web.Common.Requests.UsersManagement.Authentication;
using Lumina.Presentation.Web.Common.Routes;
using Lumina.Presentation.Web.Common.Services;
using Lumina.Presentation.Web.Core.Endpoints.UsersManagement.Authentication.Login;
using Lumina.Presentation.Web.Fixtures.Common.Requests.UsersManagement.Authentication;
using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.HttpResults;
using NSubstitute;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Text;
using System.Threading;
@@ -26,6 +25,7 @@ public class LoginViewEndpointTests
{
private readonly IUrlService _mockUrlService;
private readonly LoginViewEndpoint _sut;
private readonly LoginViewRequestFixture _loginViewRequestFixture = new();
/// <summary>
/// Initializes a new instance of the <see cref="LoginViewEndpointTests"/> class.
@@ -45,7 +45,7 @@ public class LoginViewEndpointTests
_mockUrlService.GetAbsoluteUrl(WebRoutes.Home.INDEX_CULTURED).Returns("http://localhost/en-us");
// Act
IResult result = await _sut.ExecuteAsync(new LoginViewRequest(), CancellationToken.None);
IResult result = await _sut.ExecuteAsync(_loginViewRequestFixture.Create(), CancellationToken.None);
// Assert
RedirectHttpResult redirectResult = Assert.IsType<RedirectHttpResult>(result);
@@ -57,7 +57,7 @@ public class LoginViewEndpointTests
public async Task ExecuteAsync_WhenSuperAdminSetupPending_ShouldRedirectToRegisterView()
{
// Arrange
Microsoft.AspNetCore.Http.ISession session = Substitute.For<Microsoft.AspNetCore.Http.ISession>();
ISession session = Substitute.For<ISession>();
byte[] pendingBytes = Encoding.UTF8.GetBytes("true");
#pragma warning disable CS8601 // possible null reference assignment in the NSubstitute out-argument stub
session.TryGetValue(HttpContextItemKeys.PENDING_SUPER_ADMIN_SETUP, out Arg.Any<byte[]>()).Returns(callInfo =>
@@ -70,7 +70,7 @@ public class LoginViewEndpointTests
_mockUrlService.GetAbsoluteUrl(WebRoutes.Authentication.REGISTER_VIEW).Returns("http://localhost/en-us/auth/register");
// Act
IResult result = await _sut.ExecuteAsync(new LoginViewRequest(), CancellationToken.None);
IResult result = await _sut.ExecuteAsync(_loginViewRequestFixture.Create(), CancellationToken.None);
// Assert
RedirectHttpResult redirectResult = Assert.IsType<RedirectHttpResult>(result);
@@ -85,7 +85,7 @@ public class LoginViewEndpointTests
TestHttpContextFactory.ConfigureSession(_sut.HttpContext, TestHttpContextFactory.CreateSession());
// Act
IResult result = await _sut.ExecuteAsync(new LoginViewRequest(), CancellationToken.None);
IResult result = await _sut.ExecuteAsync(_loginViewRequestFixture.Create(), CancellationToken.None);
// Assert
Assert.IsType<RazorViewResult>(result);
@@ -6,6 +6,7 @@ using Lumina.Presentation.Web.Common.Responses.UsersManagement;
using Lumina.Presentation.Web.Common.Routes;
using Lumina.Presentation.Web.Core.Endpoints.UsersManagement.Authentication.RecoverPassword;
using Lumina.Presentation.Web.Fixtures.Common.Requests.UsersManagement;
using Lumina.Presentation.Web.Fixtures.Common.Responses.UsersManagement;
using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
using Microsoft.AspNetCore.Http;
using NSubstitute;
@@ -26,6 +27,7 @@ public class RecoverPasswordEndpointTests
private readonly IApiHttpClient _mockApiHttpClient;
private readonly RecoverPasswordEndpoint _sut;
private readonly RecoverPasswordRequestFixture _recoverPasswordRequestFixture = new();
private readonly RecoverPasswordResponseFixture _recoverPasswordResponseFixture = new();
/// <summary>
/// Initializes a new instance of the <see cref="RecoverPasswordEndpointTests"/> class.
@@ -41,7 +43,7 @@ public class RecoverPasswordEndpointTests
{
// Arrange
RecoverPasswordRequest request = _recoverPasswordRequestFixture.Create();
RecoverPasswordResponse expectedResponse = new(true);
RecoverPasswordResponse expectedResponse = _recoverPasswordResponseFixture.Create(isPasswordReset: true);
_mockApiHttpClient.PostAsync<RecoverPasswordResponse, RecoverPasswordRequest>(Arg.Any<string>(), Arg.Any<RecoverPasswordRequest>(), Arg.Any<CancellationToken>())
.Returns(expectedResponse);
@@ -6,6 +6,7 @@ using Lumina.Presentation.Web.Common.Responses.UsersManagement;
using Lumina.Presentation.Web.Common.Routes;
using Lumina.Presentation.Web.Core.Endpoints.UsersManagement.Authentication.Register;
using Lumina.Presentation.Web.Fixtures.Common.Requests.UsersManagement;
using Lumina.Presentation.Web.Fixtures.Common.Responses.UsersManagement;
using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
using Microsoft.AspNetCore.Http;
using NSubstitute;
@@ -26,6 +27,7 @@ public class RegisterEndpointTests
private readonly IApiHttpClient _mockApiHttpClient;
private readonly RegisterEndpoint _sut;
private readonly RegisterRequestFixture _registerRequestFixture = new();
private readonly RegisterResponseFixture _registerResponseFixture = new();
/// <summary>
/// Initializes a new instance of the <see cref="RegisterEndpointTests"/> class.
@@ -42,7 +44,7 @@ public class RegisterEndpointTests
// Arrange
RegisterRequest request = _registerRequestFixture.Create(registrationType: "Admin");
_mockApiHttpClient.PostAsync<RegisterResponse, RegisterRequest>(Arg.Any<string>(), Arg.Any<RegisterRequest>(), Arg.Any<CancellationToken>())
.Returns(new RegisterResponse(request.Username, null));
.Returns(_registerResponseFixture.Create(username: request.Username));
// Act
IResult result = await _sut.ExecuteAsync(request, CancellationToken.None);
@@ -63,7 +65,7 @@ public class RegisterEndpointTests
// Arrange
RegisterRequest request = _registerRequestFixture.Create(registrationType: "User");
_mockApiHttpClient.PostAsync<RegisterResponse, RegisterRequest>(Arg.Any<string>(), Arg.Any<RegisterRequest>(), Arg.Any<CancellationToken>())
.Returns(new RegisterResponse(request.Username, null));
.Returns(_registerResponseFixture.Create(username: request.Username));
// Act
IResult result = await _sut.ExecuteAsync(request, CancellationToken.None);
@@ -11,7 +11,6 @@ using Lumina.Presentation.Web.Fixtures.Common.DTO.Themes;
using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.ViewEngines;
@@ -46,6 +45,9 @@ public class ThemeLayoutRendererTests
private readonly IView _mockAudioPlayerView;
private readonly IView _mockScriptsView;
private readonly IView _mockNavMenuView;
private readonly ThemeResponseDtoFixture _themeResponseDtoFixture = new();
private readonly ThemeTemplateResponseDtoFixture _themeTemplateResponseDtoFixture = new();
private readonly ThemeLayoutPageDtoFixture _themeLayoutPageDtoFixture = new();
private readonly ThemeLayoutRenderer _sut;
/// <summary>
@@ -90,9 +92,9 @@ public class ThemeLayoutRendererTests
{
// Arrange
_mockHttpContextAccessor.HttpContext.Returns(TestHttpContextFactory.Create(user: TestHttpContextFactory.CreateAuthenticatedUser()));
ThemeResponseDto theme = new ThemeResponseDtoFixture().Create(themeId: "editorial");
ThemeResponseDto theme = _themeResponseDtoFixture.Create(themeId: "editorial");
SetupRenderDocuments(theme, layoutTemplate: "{{title}}|{{assetBase}}|{{{appHead}}}|{{{nav}}}|{{{content}}}|{{{audioPlayer}}}|{{{appScripts}}}|{{{scripts}}}|{{mainStyle}}", navTemplate: "nav:{{siteName}}");
ThemeLayoutPageDto page = new("My Page", "<main>", "<page-script>");
ThemeLayoutPageDto page = _themeLayoutPageDtoFixture.Create(title: "My Page", content: "<main>", script: "<page-script>");
// Act
Result<string> result = await _sut.RenderAsync(page, "editorial", CancellationToken.None);
@@ -107,9 +109,9 @@ public class ThemeLayoutRendererTests
{
// Arrange
_mockHttpContextAccessor.HttpContext.Returns(TestHttpContextFactory.Create(user: null));
ThemeResponseDto theme = new ThemeResponseDtoFixture().Create(themeId: "editorial");
ThemeResponseDto theme = _themeResponseDtoFixture.Create(themeId: "editorial");
SetupRenderDocuments(theme, layoutTemplate: "{{title}}|{{assetBase}}|{{{appHead}}}|{{{nav}}}|{{{content}}}|{{{audioPlayer}}}|{{{appScripts}}}|{{{scripts}}}|{{mainStyle}}", navTemplate: "nav:{{siteName}}");
ThemeLayoutPageDto page = new("My Page", "<main>", "<page-script>");
ThemeLayoutPageDto page = _themeLayoutPageDtoFixture.Create(title: "My Page", content: "<main>", script: "<page-script>");
// Act
Result<string> result = await _sut.RenderAsync(page, "editorial", CancellationToken.None);
@@ -124,9 +126,9 @@ public class ThemeLayoutRendererTests
{
// Arrange
_mockHttpContextAccessor.HttpContext.Returns(TestHttpContextFactory.Create(user: null));
ThemeResponseDto theme = new ThemeResponseDtoFixture().Create(themeId: "editorial");
ThemeResponseDto theme = _themeResponseDtoFixture.Create(themeId: "editorial");
SetupRenderDocuments(theme, layoutTemplate: "{{title}}|{{{nav}}}", navTemplate: "{{#unclosed}}");
ThemeLayoutPageDto page = new("My Page", "<main>", string.Empty);
ThemeLayoutPageDto page = _themeLayoutPageDtoFixture.Create(title: "My Page", content: "<main>", script: string.Empty);
// Act
Result<string> result = await _sut.RenderAsync(page, "editorial", CancellationToken.None);
@@ -142,9 +144,9 @@ public class ThemeLayoutRendererTests
{
// Arrange
_mockHttpContextAccessor.HttpContext.Returns(TestHttpContextFactory.Create(user: null));
ThemeResponseDto theme = new ThemeResponseDtoFixture().Create(themeId: "editorial");
ThemeResponseDto theme = _themeResponseDtoFixture.Create(themeId: "editorial");
SetupRenderDocuments(theme, layoutTemplate: "{{title}}", navTemplate: "nav:{{siteName}}");
ThemeLayoutPageDto page = new("My Page", "<main>", string.Empty);
ThemeLayoutPageDto page = _themeLayoutPageDtoFixture.Create(title: "My Page", content: "<main>", script: string.Empty);
string layoutEndpoint = ApiRoutes.Themes.GET_THEME_TEMPLATE
.Replace("{themeId}", "editorial")
.Replace("{*pageKey}", "shared/layout");
@@ -160,6 +162,12 @@ public class ThemeLayoutRendererTests
await _mockApiHttpClient.Received(1).GetAsync<ThemeTemplateResponseDto>(navEndpoint, Arg.Any<CancellationToken>());
}
/// <summary>
/// Stubs the API responses that return the layout and navigation menu templates of the given theme.
/// </summary>
/// <param name="theme">The theme whose layout and navigation menu templates are stubbed.</param>
/// <param name="layoutTemplate">The template returned for the layout document.</param>
/// <param name="navTemplate">The template returned for the navigation menu document.</param>
private void SetupRenderDocuments(ThemeResponseDto theme, string layoutTemplate, string navTemplate)
{
string layoutEndpoint = ApiRoutes.Themes.GET_THEME_TEMPLATE
@@ -169,11 +177,16 @@ public class ThemeLayoutRendererTests
.Replace("{themeId}", theme.ThemeId)
.Replace("{*pageKey}", "shared/nav-menu");
_mockApiHttpClient.GetAsync<ThemeTemplateResponseDto>(layoutEndpoint, Arg.Any<CancellationToken>())
.Returns(new ThemeTemplateResponseDto(theme, layoutTemplate));
.Returns(_themeTemplateResponseDtoFixture.Create(theme: theme, template: layoutTemplate));
_mockApiHttpClient.GetAsync<ThemeTemplateResponseDto>(navEndpoint, Arg.Any<CancellationToken>())
.Returns(new ThemeTemplateResponseDto(theme, navTemplate));
.Returns(_themeTemplateResponseDtoFixture.Create(theme: theme, template: navTemplate));
}
/// <summary>
/// Creates a substitute view that renders the given markup.
/// </summary>
/// <param name="markup">The markup rendered by the view.</param>
/// <returns>The created substitute view.</returns>
private static IView CreateView(string markup)
{
IView view = Substitute.For<IView>();
@@ -186,6 +199,10 @@ public class ThemeLayoutRendererTests
return view;
}
/// <summary>
/// Creates a substitute string localizer that returns a string prefixed with "Localized-".
/// </summary>
/// <returns>The created substitute string localizer.</returns>
private static IStringLocalizer CreateLocalizer()
{
IStringLocalizer localizer = Substitute.For<IStringLocalizer>();
@@ -6,7 +6,6 @@ using Lumina.Presentation.Web.Common.Routes;
using Lumina.Presentation.Web.Core.Themes;
using Lumina.Presentation.Web.Fixtures.Common.DTO.Themes;
using NSubstitute;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
@@ -24,6 +23,7 @@ public class ThemePageRendererTests
private readonly ThemePageRenderer _sut;
private readonly ThemeResponseDtoFixture _themeResponseDtoFixture = new();
private readonly ThemePageDtoFixture _themePageDtoFixture = new();
private readonly ThemeTemplateResponseDtoFixture _themeTemplateResponseDtoFixture = new();
/// <summary>
/// Initializes a new instance of the <see cref="ThemePageRendererTests"/> class.
@@ -46,7 +46,7 @@ public class ThemePageRendererTests
.Replace("{themeId}", "editorial-paper")
.Replace("{*pageKey}", pageKey);
_mockApiHttpClient.GetAsync<ThemeTemplateResponseDto>(expectedEndpoint, Arg.Any<CancellationToken>())
.Returns(new ThemeTemplateResponseDto(theme, template));
.Returns(_themeTemplateResponseDtoFixture.Create(theme: theme, template: template));
ThemePageDto model = _themePageDtoFixture.Create(pageKey: pageKey, title: "Home");
// Act
@@ -74,7 +74,7 @@ public class ThemePageRendererTests
_mockApiHttpClient.GetAsync<ThemeResponseDto>(ApiRoutes.Themes.GET_CURRENT_THEME, Arg.Any<CancellationToken>())
.Returns(currentTheme);
_mockApiHttpClient.GetAsync<ThemeTemplateResponseDto>(expectedEndpoint, Arg.Any<CancellationToken>())
.Returns(new ThemeTemplateResponseDto(currentTheme, "{{title}}"));
.Returns(_themeTemplateResponseDtoFixture.Create(theme: currentTheme, template: "{{title}}"));
ThemePageDto model = _themePageDtoFixture.Create(pageKey: pageKey, title: "Home");
// Act
@@ -97,7 +97,7 @@ public class ThemePageRendererTests
.Replace("{themeId}", "editorial-paper")
.Replace("{*pageKey}", pageKey);
_mockApiHttpClient.GetAsync<ThemeTemplateResponseDto>(expectedEndpoint, Arg.Any<CancellationToken>())
.Returns(new ThemeTemplateResponseDto(theme, "{{#unclosed}}"));
.Returns(_themeTemplateResponseDtoFixture.Create(theme: theme, template: "{{#unclosed}}"));
ThemePageDto model = _themePageDtoFixture.Create(pageKey: pageKey, title: "Home");
// Act
@@ -1,13 +1,12 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Api;
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
using Lumina.Presentation.Web.Common.DTO.Themes;
using Lumina.Presentation.Web.Common.Enums.Themes;
using Lumina.Presentation.Web.Common.Routes;
using Lumina.Presentation.Web.Core.Themes;
using Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
using Lumina.Presentation.Web.Fixtures.Common.DTO.Themes;
using NSubstitute;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
@@ -28,6 +27,7 @@ public class ThemeServiceTests
private readonly ThemeResponseDtoFixture _themeResponseDtoFixture = new();
private readonly ThemeSettingsResponseDtoFixture _themeSettingsResponseDtoFixture = new();
private readonly ThemeTemplateResponseDtoFixture _themeTemplateResponseDtoFixture = new();
private readonly BlobDataDtoFixture _blobDataDtoFixture = new();
/// <summary>
/// Initializes a new instance of the <see cref="ThemeServiceTests"/> class.
@@ -226,7 +226,7 @@ public class ThemeServiceTests
string themeId = "editorial-paper";
byte[] data = [0x50, 0x4B, 0x03, 0x04];
_mockApiHttpClient.GetBlobAsync(Arg.Any<string>(), Arg.Any<CancellationToken>())
.Returns(new BlobDataDto { Data = data, ContentType = "application/zip" });
.Returns(_blobDataDtoFixture.Create(data: data, contentType: "application/zip"));
string expectedEndpoint = ApiRoutes.Themes.GET_THEME_ARCHIVE.Replace("{themeId}", themeId);
// Act