mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 17:11:10 +00:00
Adds favorites and aligns playlist and favorite pagination
This commit is contained in:
1 parent
2e9f7d8496
commit
525ac1348d
193 files changed
+10944
-643
No files matched your search
-55
@@ -1,55 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PaginatedMusicAlbumLiteDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PaginatedMusicAlbumLiteDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly MusicAlbumLiteDtoFixture _musicAlbumLiteDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="PaginatedMusicAlbumLiteDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="data">Optional. The collection of lightweight album elements.</param>
|
||||
/// <param name="currentPage">Optional. The current page number in the paginated collection.</param>
|
||||
/// <param name="perPage">Optional. The number of items to include per page.</param>
|
||||
/// <param name="count">Optional. The total number of elements available in the result set.</param>
|
||||
/// <param name="numberOfPages">Optional. The total number of pages available.</param>
|
||||
/// <returns>A configured <see cref="PaginatedMusicAlbumLiteDto"/> instance.</returns>
|
||||
public PaginatedMusicAlbumLiteDto Create(
|
||||
IReadOnlyList<MusicAlbumLiteDto>? data = null,
|
||||
int? currentPage = null,
|
||||
int? perPage = null,
|
||||
int? count = null,
|
||||
int? numberOfPages = null)
|
||||
{
|
||||
return new PaginatedMusicAlbumLiteDto
|
||||
{
|
||||
Data = data ?? [.. _musicAlbumLiteDtoFixture.CreateMany(_faker.Random.Number(1, 3))],
|
||||
CurrentPage = currentPage ?? _faker.Random.Int(1, 10),
|
||||
PerPage = perPage ?? _faker.Random.Int(1, 100),
|
||||
Count = count ?? _faker.Random.Int(0, 1000),
|
||||
NumberOfPages = numberOfPages ?? _faker.Random.Int(1, 100)
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="PaginatedMusicAlbumLiteDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PaginatedMusicAlbumLiteDto"/> instances.</returns>
|
||||
public List<PaginatedMusicAlbumLiteDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PaginatedMusicArtistLiteDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PaginatedMusicArtistLiteDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly MusicArtistLiteDtoFixture _musicArtistLiteDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="PaginatedMusicArtistLiteDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="data">Optional. The collection of lightweight artist elements.</param>
|
||||
/// <param name="currentPage">Optional. The current page number in the paginated collection.</param>
|
||||
/// <param name="perPage">Optional. The number of items to include per page.</param>
|
||||
/// <param name="count">Optional. The total number of elements available in the result set.</param>
|
||||
/// <param name="numberOfPages">Optional. The total number of pages available.</param>
|
||||
/// <returns>A configured <see cref="PaginatedMusicArtistLiteDto"/> instance.</returns>
|
||||
public PaginatedMusicArtistLiteDto Create(
|
||||
IReadOnlyList<MusicArtistLiteDto>? data = null,
|
||||
int? currentPage = null,
|
||||
int? perPage = null,
|
||||
int? count = null,
|
||||
int? numberOfPages = null)
|
||||
{
|
||||
return new PaginatedMusicArtistLiteDto
|
||||
{
|
||||
Data = data ?? [.. _musicArtistLiteDtoFixture.CreateMany(_faker.Random.Number(1, 3))],
|
||||
CurrentPage = currentPage ?? _faker.Random.Int(1, 10),
|
||||
PerPage = perPage ?? _faker.Random.Int(1, 100),
|
||||
Count = count ?? _faker.Random.Int(0, 1000),
|
||||
NumberOfPages = numberOfPages ?? _faker.Random.Int(1, 100)
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="PaginatedMusicArtistLiteDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PaginatedMusicArtistLiteDto"/> instances.</returns>
|
||||
public List<PaginatedMusicArtistLiteDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PaginatedMusicTrackLiteDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PaginatedMusicTrackLiteDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly MusicTrackLiteDtoFixture _musicTrackLiteDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="PaginatedMusicTrackLiteDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="data">Optional. The collection of lightweight track elements.</param>
|
||||
/// <param name="currentPage">Optional. The current page number in the paginated collection.</param>
|
||||
/// <param name="perPage">Optional. The number of items to include per page.</param>
|
||||
/// <param name="count">Optional. The total number of elements available in the result set.</param>
|
||||
/// <param name="numberOfPages">Optional. The total number of pages available.</param>
|
||||
/// <returns>A configured <see cref="PaginatedMusicTrackLiteDto"/> instance.</returns>
|
||||
public PaginatedMusicTrackLiteDto Create(
|
||||
IReadOnlyList<MusicTrackLiteDto>? data = null,
|
||||
int? currentPage = null,
|
||||
int? perPage = null,
|
||||
int? count = null,
|
||||
int? numberOfPages = null)
|
||||
{
|
||||
return new PaginatedMusicTrackLiteDto
|
||||
{
|
||||
Data = data ?? [.. _musicTrackLiteDtoFixture.CreateMany(_faker.Random.Number(1, 3))],
|
||||
CurrentPage = currentPage ?? _faker.Random.Int(1, 10),
|
||||
PerPage = perPage ?? _faker.Random.Int(1, 100),
|
||||
Count = count ?? _faker.Random.Int(0, 1000),
|
||||
NumberOfPages = numberOfPages ?? _faker.Random.Int(1, 100)
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="PaginatedMusicTrackLiteDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PaginatedMusicTrackLiteDto"/> instances.</returns>
|
||||
public List<PaginatedMusicTrackLiteDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+19
-20
@@ -1,53 +1,52 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Libraries;
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PaginatedBookLiteDto"/> class.
|
||||
/// Fixture class for the <see cref="PaginatedDto{T}"/> class.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the elements of the page.</typeparam>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PaginatedBookLiteDtoFixture
|
||||
public class PaginatedDtoFixture<T>
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="PaginatedBookLiteDto"/> instance with randomized test data.
|
||||
/// Creates a new <see cref="PaginatedDto{T}"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="data">Optional collection of lightweight book elements.</param>
|
||||
/// <param name="data">Optional collection of elements of the page.</param>
|
||||
/// <param name="currentPage">Optional current page number in a paginated collection.</param>
|
||||
/// <param name="perPage">Optional number of items to include per page in paginated results.</param>
|
||||
/// <param name="count">Optional total number of elements available in the paginated result set.</param>
|
||||
/// <param name="numberOfPages">Optional total number of pages based on the elements available and per page.</param>
|
||||
/// <returns>A configured <see cref="PaginatedBookLiteDto"/> instance.</returns>
|
||||
public PaginatedBookLiteDto Create(
|
||||
IReadOnlyList<BookLiteDto>? data = null,
|
||||
/// <returns>A configured <see cref="PaginatedDto{T}"/> instance.</returns>
|
||||
public PaginatedDto<T> Create(
|
||||
IReadOnlyList<T>? data = null,
|
||||
int? currentPage = null,
|
||||
int? perPage = null,
|
||||
int? count = null,
|
||||
int? numberOfPages = null)
|
||||
{
|
||||
return new PaginatedBookLiteDto
|
||||
{
|
||||
Data = data ?? [],
|
||||
CurrentPage = currentPage ?? _faker.Random.Int(1, 10),
|
||||
PerPage = perPage ?? _faker.Random.Int(1, 100),
|
||||
Count = count ?? _faker.Random.Int(0, 1000),
|
||||
NumberOfPages = numberOfPages ?? _faker.Random.Int(1, 100)
|
||||
};
|
||||
return new PaginatedDto<T>(
|
||||
Data: data is null ? [] : [.. data],
|
||||
CurrentPage: currentPage ?? _faker.Random.Int(1, 10),
|
||||
PerPage: perPage ?? _faker.Random.Int(1, 100),
|
||||
Count: count ?? _faker.Random.Int(0, 1000),
|
||||
NumberOfPages: numberOfPages ?? _faker.Random.Int(1, 100));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="PaginatedBookLiteDto"/> instances with randomized test data.
|
||||
/// Creates multiple <see cref="PaginatedDto{T}"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PaginatedBookLiteDto"/> instances.</returns>
|
||||
public List<PaginatedBookLiteDto> CreateMany(int count = 3)
|
||||
/// <returns>List of configured <see cref="PaginatedDto{T}"/> instances.</returns>
|
||||
public List<PaginatedDto<T>> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
+12
-3
@@ -2,6 +2,7 @@
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Playlists;
|
||||
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
|
||||
using Lumina.Application.Common.DTO.Pagination;
|
||||
using Lumina.Application.Common.DTO.Playlists;
|
||||
using Lumina.Application.Common.Infrastructure.Authentication;
|
||||
using Lumina.Application.Common.Infrastructure.Time;
|
||||
@@ -189,12 +190,20 @@ public class PlaylistRepositoryTests
|
||||
Assert.Equal(orderedTracks.Count, storedPlaylist.EntryCount);
|
||||
Assert.Equal(1L, storedPlaylist.Version);
|
||||
Assert.Equal(updatedOnUtc, storedPlaylist.UpdatedOnUtc);
|
||||
// A window read reports the stored count of the whole playlist while materializing only the requested window.
|
||||
Result<PlaylistDetailsDto?> detailsResult = await sut.GetDetailsForUserAsync(playlist.Id, userId, offset: 0, limit: 2, CancellationToken.None);
|
||||
// A paginated read reports the count of the whole playlist while materializing only the requested page.
|
||||
Result<PlaylistDetailsDto?> detailsResult = await sut.GetDetailsForUserAsync(
|
||||
playlist.Id,
|
||||
userId,
|
||||
new PaginationDataDto { CurrentPage = 1, PerPage = 2 },
|
||||
CancellationToken.None);
|
||||
Assert.False(detailsResult.IsFailure);
|
||||
Assert.NotNull(detailsResult.Value);
|
||||
Assert.Equal(orderedTracks.Count, detailsResult.Value!.Playlist.EntryCount);
|
||||
Assert.Equal(2, detailsResult.Value.Entries.Count);
|
||||
Assert.Equal(orderedTracks.Count, detailsResult.Value.Entries.Count);
|
||||
Assert.Equal(2, detailsResult.Value.Entries.Data.Count);
|
||||
Assert.Equal(1, detailsResult.Value.Entries.CurrentPage);
|
||||
Assert.Equal(2, detailsResult.Value.Entries.PerPage);
|
||||
Assert.Equal((int)Math.Ceiling(orderedTracks.Count / 2d), detailsResult.Value.Entries.NumberOfPages);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
+4
-2
@@ -1,7 +1,9 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Core.Endpoints.Library.AudioLibrary.MusicLibrary.Albums.GetArtistAlbums;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
|
||||
using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
|
||||
using System;
|
||||
@@ -22,7 +24,7 @@ namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Library.AudioL
|
||||
public class GetArtistAlbumsEndpointTests : IClassFixture<LuminaWebFactory>
|
||||
{
|
||||
private readonly LuminaWebFactory _apiFactory;
|
||||
private readonly PaginatedMusicAlbumLiteDtoFixture _paginatedMusicAlbumLiteDtoFixture = new();
|
||||
private readonly PaginatedDtoFixture<MusicAlbumLiteDto> _paginatedMusicAlbumLiteDtoFixture = new();
|
||||
private readonly MusicAlbumLiteDtoFixture _musicAlbumLiteDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
@@ -41,7 +43,7 @@ public class GetArtistAlbumsEndpointTests : IClassFixture<LuminaWebFactory>
|
||||
_apiFactory.ApiClientStub.Reset();
|
||||
Guid libraryId = Guid.NewGuid();
|
||||
Guid artistId = Guid.NewGuid();
|
||||
PaginatedMusicAlbumLiteDto expectedResponse = _paginatedMusicAlbumLiteDtoFixture.Create(data: [_musicAlbumLiteDtoFixture.Create(title: "Test Album")]);
|
||||
PaginatedDto<MusicAlbumLiteDto> expectedResponse = _paginatedMusicAlbumLiteDtoFixture.Create(data: [_musicAlbumLiteDtoFixture.Create(title: "Test Album")]);
|
||||
string expectedEndpoint = $"libraries/{libraryId}/artists/{artistId}/albums/lite?currentPage=1&perPage=20";
|
||||
_apiFactory.ApiClientStub.RegisterGetResponse(expectedEndpoint, expectedResponse);
|
||||
AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
|
||||
|
||||
+3
-1
@@ -1,7 +1,9 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Core.Endpoints.Library.AudioLibrary.MusicLibrary.Artists.GetMusicArtists;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
|
||||
using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
|
||||
using System;
|
||||
@@ -22,7 +24,7 @@ namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Library.AudioL
|
||||
public class GetMusicArtistsEndpointTests : IClassFixture<LuminaWebFactory>
|
||||
{
|
||||
private readonly LuminaWebFactory _apiFactory;
|
||||
private readonly PaginatedMusicArtistLiteDtoFixture _paginatedMusicArtistLiteDtoFixture = new();
|
||||
private readonly PaginatedDtoFixture<MusicArtistLiteDto> _paginatedMusicArtistLiteDtoFixture = new();
|
||||
private readonly MusicArtistLiteDtoFixture _musicArtistLiteDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
|
||||
+4
-2
@@ -1,7 +1,9 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Core.Endpoints.Library.AudioLibrary.MusicLibrary.Tracks.GetAlbumTracks;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
|
||||
using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
|
||||
using System;
|
||||
@@ -22,7 +24,7 @@ namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Library.AudioL
|
||||
public class GetAlbumTracksEndpointTests : IClassFixture<LuminaWebFactory>
|
||||
{
|
||||
private readonly LuminaWebFactory _apiFactory;
|
||||
private readonly PaginatedMusicTrackLiteDtoFixture _paginatedMusicTrackLiteDtoFixture = new();
|
||||
private readonly PaginatedDtoFixture<MusicTrackLiteDto> _paginatedMusicTrackLiteDtoFixture = new();
|
||||
private readonly MusicTrackLiteDtoFixture _musicTrackLiteDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
@@ -42,7 +44,7 @@ public class GetAlbumTracksEndpointTests : IClassFixture<LuminaWebFactory>
|
||||
Guid libraryId = Guid.NewGuid();
|
||||
Guid artistId = Guid.NewGuid();
|
||||
Guid albumId = Guid.NewGuid();
|
||||
PaginatedMusicTrackLiteDto expectedResponse = _paginatedMusicTrackLiteDtoFixture.Create(data: [_musicTrackLiteDtoFixture.Create(title: "Test Track")]);
|
||||
PaginatedDto<MusicTrackLiteDto> expectedResponse = _paginatedMusicTrackLiteDtoFixture.Create(data: [_musicTrackLiteDtoFixture.Create(title: "Test Track")]);
|
||||
string expectedEndpoint = $"libraries/{libraryId}/artists/{artistId}/albums/{albumId}/tracks/lite?currentPage=1&perPage=20";
|
||||
_apiFactory.ApiClientStub.RegisterGetResponse(expectedEndpoint, expectedResponse);
|
||||
AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
|
||||
|
||||
+4
-2
@@ -1,6 +1,8 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||
using Lumina.Presentation.Web.Core.Endpoints.Library.WrittenContentLibrary.BookLibrary.Books.GetLibraryItems;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.DTO.Libraries;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
|
||||
using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
|
||||
@@ -22,7 +24,7 @@ namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Library.Writte
|
||||
public class GetLibraryItemsEndpointTests : IClassFixture<LuminaWebFactory>
|
||||
{
|
||||
private readonly LuminaWebFactory _apiFactory;
|
||||
private readonly PaginatedBookLiteDtoFixture _paginatedBookLiteDtoFixture = new();
|
||||
private readonly PaginatedDtoFixture<BookLiteDto> _paginatedBookLiteDtoFixture = new();
|
||||
private readonly BookLiteDtoFixture _bookLiteDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
@@ -41,7 +43,7 @@ public class GetLibraryItemsEndpointTests : IClassFixture<LuminaWebFactory>
|
||||
_apiFactory.ApiClientStub.Reset();
|
||||
Guid libraryId = Guid.NewGuid();
|
||||
string searchTerm = "Harry";
|
||||
PaginatedBookLiteDto expectedResponse = _paginatedBookLiteDtoFixture.Create(data: [_bookLiteDtoFixture.Create(title: "Harry Potter")]);
|
||||
PaginatedDto<BookLiteDto> expectedResponse = _paginatedBookLiteDtoFixture.Create(data: [_bookLiteDtoFixture.Create(title: "Harry Potter")]);
|
||||
string expectedEndpoint = $"libraries/{libraryId}/books/lite?currentPage=1&perPage=20&searchTerm={searchTerm}&shouldIgnoreThePrefixForAlphaPicker=True";
|
||||
_apiFactory.ApiClientStub.RegisterGetResponse(expectedEndpoint, expectedResponse);
|
||||
AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
|
||||
|
||||
+3
-1
@@ -1,6 +1,8 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Presentation.Web.Core.Endpoints.Library.AudioLibrary.MusicLibrary.Albums.GetArtistAlbums;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
|
||||
using Lumina.Presentation.Web.SecurityTests.Common.Setup;
|
||||
using System;
|
||||
@@ -20,7 +22,7 @@ namespace Lumina.Presentation.Web.SecurityTests.Core.Endpoints.Library.AudioLibr
|
||||
public class GetArtistAlbumsEndpointTests : IClassFixture<LuminaWebFactory>
|
||||
{
|
||||
private readonly LuminaWebFactory _apiFactory;
|
||||
private readonly PaginatedMusicAlbumLiteDtoFixture _paginatedMusicAlbumLiteDtoFixture = new();
|
||||
private readonly PaginatedDtoFixture<MusicAlbumLiteDto> _paginatedMusicAlbumLiteDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetArtistAlbumsEndpointTests"/> class.
|
||||
|
||||
+3
-1
@@ -1,6 +1,8 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Presentation.Web.Core.Endpoints.Library.AudioLibrary.MusicLibrary.Artists.GetMusicArtists;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
|
||||
using Lumina.Presentation.Web.SecurityTests.Common.Setup;
|
||||
using System;
|
||||
@@ -20,7 +22,7 @@ namespace Lumina.Presentation.Web.SecurityTests.Core.Endpoints.Library.AudioLibr
|
||||
public class GetMusicArtistsEndpointTests : IClassFixture<LuminaWebFactory>
|
||||
{
|
||||
private readonly LuminaWebFactory _apiFactory;
|
||||
private readonly PaginatedMusicArtistLiteDtoFixture _paginatedMusicArtistLiteDtoFixture = new();
|
||||
private readonly PaginatedDtoFixture<MusicArtistLiteDto> _paginatedMusicArtistLiteDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetMusicArtistsEndpointTests"/> class.
|
||||
|
||||
+3
-1
@@ -1,6 +1,8 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Presentation.Web.Core.Endpoints.Library.AudioLibrary.MusicLibrary.Tracks.GetAlbumTracks;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
|
||||
using Lumina.Presentation.Web.SecurityTests.Common.Setup;
|
||||
using System;
|
||||
@@ -20,7 +22,7 @@ namespace Lumina.Presentation.Web.SecurityTests.Core.Endpoints.Library.AudioLibr
|
||||
public class GetAlbumTracksEndpointTests : IClassFixture<LuminaWebFactory>
|
||||
{
|
||||
private readonly LuminaWebFactory _apiFactory;
|
||||
private readonly PaginatedMusicTrackLiteDtoFixture _paginatedMusicTrackLiteDtoFixture = new();
|
||||
private readonly PaginatedDtoFixture<MusicTrackLiteDto> _paginatedMusicTrackLiteDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetAlbumTracksEndpointTests"/> class.
|
||||
|
||||
+3
-1
@@ -1,5 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||
using Lumina.Presentation.Web.Core.Endpoints.Library.WrittenContentLibrary.BookLibrary.Books.GetLibraryItems;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.DTO.Libraries;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
|
||||
using Lumina.Presentation.Web.SecurityTests.Common.Setup;
|
||||
@@ -17,7 +19,7 @@ namespace Lumina.Presentation.Web.SecurityTests.Core.Endpoints.Library.WrittenCo
|
||||
public class GetLibraryItemsEndpointTests : IClassFixture<LuminaWebFactory>
|
||||
{
|
||||
private readonly LuminaWebFactory _apiFactory;
|
||||
private readonly PaginatedBookLiteDtoFixture _paginatedBookLiteDtoFixture = new();
|
||||
private readonly PaginatedDtoFixture<BookLiteDto> _paginatedBookLiteDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetLibraryItemsEndpointTests"/> class.
|
||||
|
||||
+15
-13
@@ -2,10 +2,12 @@
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.Requests.Library.AudioLibrary.MusicLibrary.Albums;
|
||||
using Lumina.Presentation.Web.Common.Routes;
|
||||
using Lumina.Presentation.Web.Core.Endpoints.Library.AudioLibrary.MusicLibrary.Albums.GetArtistAlbums;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.Requests.Library.AudioLibrary.MusicLibrary.Albums;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
@@ -28,7 +30,7 @@ public class GetArtistAlbumsEndpointTests
|
||||
private readonly IApiHttpClient _mockApiHttpClient;
|
||||
private readonly GetArtistAlbumsEndpoint _sut;
|
||||
private readonly GetArtistAlbumsLiteRequestFixture _getArtistAlbumsLiteRequestFixture = new();
|
||||
private readonly PaginatedMusicAlbumLiteDtoFixture _paginatedMusicAlbumLiteDtoFixture = new();
|
||||
private readonly PaginatedDtoFixture<MusicAlbumLiteDto> _paginatedMusicAlbumLiteDtoFixture = new();
|
||||
private readonly MusicAlbumLiteDtoFixture _musicAlbumLiteDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
@@ -45,14 +47,14 @@ public class GetArtistAlbumsEndpointTests
|
||||
{
|
||||
// Arrange
|
||||
GetArtistAlbumsLiteRequest request = _getArtistAlbumsLiteRequestFixture.Create(currentPage: 2, perPage: 48);
|
||||
_mockApiHttpClient.GetAsync<PaginatedMusicAlbumLiteDto>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
_mockApiHttpClient.GetAsync<PaginatedDto<MusicAlbumLiteDto>>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
.Returns(_paginatedMusicAlbumLiteDtoFixture.Create());
|
||||
|
||||
// Act
|
||||
await _sut.ExecuteAsync(request, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
await _mockApiHttpClient.Received(1).GetAsync<PaginatedMusicAlbumLiteDto>(
|
||||
await _mockApiHttpClient.Received(1).GetAsync<PaginatedDto<MusicAlbumLiteDto>>(
|
||||
Arg.Is<string>(endpoint => endpoint == $"{BuildExpectedEndpoint(request.LibraryId, Guid.Parse(request.ArtistId))}?currentPage=2&perPage=48"),
|
||||
Arg.Any<CancellationToken>());
|
||||
}
|
||||
@@ -62,14 +64,14 @@ public class GetArtistAlbumsEndpointTests
|
||||
{
|
||||
// Arrange
|
||||
GetArtistAlbumsLiteRequest request = _getArtistAlbumsLiteRequestFixture.Create();
|
||||
_mockApiHttpClient.GetAsync<PaginatedMusicAlbumLiteDto>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
_mockApiHttpClient.GetAsync<PaginatedDto<MusicAlbumLiteDto>>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
.Returns(_paginatedMusicAlbumLiteDtoFixture.Create());
|
||||
|
||||
// Act
|
||||
await _sut.ExecuteAsync(request, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
await _mockApiHttpClient.Received(1).GetAsync<PaginatedMusicAlbumLiteDto>(
|
||||
await _mockApiHttpClient.Received(1).GetAsync<PaginatedDto<MusicAlbumLiteDto>>(
|
||||
Arg.Is<string>(endpoint => endpoint == BuildExpectedEndpoint(request.LibraryId, Guid.Parse(request.ArtistId))),
|
||||
Arg.Any<CancellationToken>());
|
||||
}
|
||||
@@ -79,14 +81,14 @@ public class GetArtistAlbumsEndpointTests
|
||||
{
|
||||
// Arrange
|
||||
GetArtistAlbumsLiteRequest request = _getArtistAlbumsLiteRequestFixture.Create(currentPage: 3);
|
||||
_mockApiHttpClient.GetAsync<PaginatedMusicAlbumLiteDto>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
_mockApiHttpClient.GetAsync<PaginatedDto<MusicAlbumLiteDto>>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
.Returns(_paginatedMusicAlbumLiteDtoFixture.Create());
|
||||
|
||||
// Act
|
||||
await _sut.ExecuteAsync(request, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
await _mockApiHttpClient.Received(1).GetAsync<PaginatedMusicAlbumLiteDto>(
|
||||
await _mockApiHttpClient.Received(1).GetAsync<PaginatedDto<MusicAlbumLiteDto>>(
|
||||
Arg.Is<string>(endpoint => endpoint == $"{BuildExpectedEndpoint(request.LibraryId, Guid.Parse(request.ArtistId))}?currentPage=3"),
|
||||
Arg.Any<CancellationToken>());
|
||||
}
|
||||
@@ -96,14 +98,14 @@ public class GetArtistAlbumsEndpointTests
|
||||
{
|
||||
// Arrange
|
||||
GetArtistAlbumsLiteRequest request = _getArtistAlbumsLiteRequestFixture.Create(perPage: 24);
|
||||
_mockApiHttpClient.GetAsync<PaginatedMusicAlbumLiteDto>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
_mockApiHttpClient.GetAsync<PaginatedDto<MusicAlbumLiteDto>>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
.Returns(_paginatedMusicAlbumLiteDtoFixture.Create());
|
||||
|
||||
// Act
|
||||
await _sut.ExecuteAsync(request, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
await _mockApiHttpClient.Received(1).GetAsync<PaginatedMusicAlbumLiteDto>(
|
||||
await _mockApiHttpClient.Received(1).GetAsync<PaginatedDto<MusicAlbumLiteDto>>(
|
||||
Arg.Is<string>(endpoint => endpoint == $"{BuildExpectedEndpoint(request.LibraryId, Guid.Parse(request.ArtistId))}?perPage=24"),
|
||||
Arg.Any<CancellationToken>());
|
||||
}
|
||||
@@ -113,14 +115,14 @@ public class GetArtistAlbumsEndpointTests
|
||||
{
|
||||
// Arrange
|
||||
GetArtistAlbumsLiteRequest request = _getArtistAlbumsLiteRequestFixture.Create(artistId: "not-a-guid", currentPage: 1, perPage: 20);
|
||||
_mockApiHttpClient.GetAsync<PaginatedMusicAlbumLiteDto>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
_mockApiHttpClient.GetAsync<PaginatedDto<MusicAlbumLiteDto>>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
.Returns(_paginatedMusicAlbumLiteDtoFixture.Create());
|
||||
|
||||
// Act
|
||||
await _sut.ExecuteAsync(request, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
await _mockApiHttpClient.Received(1).GetAsync<PaginatedMusicAlbumLiteDto>(
|
||||
await _mockApiHttpClient.Received(1).GetAsync<PaginatedDto<MusicAlbumLiteDto>>(
|
||||
Arg.Is<string>(endpoint => endpoint == $"{BuildExpectedEndpoint(request.LibraryId, Guid.Empty)}?currentPage=1&perPage=20"),
|
||||
Arg.Any<CancellationToken>());
|
||||
}
|
||||
@@ -130,13 +132,13 @@ public class GetArtistAlbumsEndpointTests
|
||||
{
|
||||
// Arrange
|
||||
GetArtistAlbumsLiteRequest request = _getArtistAlbumsLiteRequestFixture.Create();
|
||||
PaginatedMusicAlbumLiteDto expectedResponse = _paginatedMusicAlbumLiteDtoFixture.Create(
|
||||
PaginatedDto<MusicAlbumLiteDto> expectedResponse = _paginatedMusicAlbumLiteDtoFixture.Create(
|
||||
data: [_musicAlbumLiteDtoFixture.Create(title: "Test Album")],
|
||||
currentPage: 1,
|
||||
perPage: 20,
|
||||
count: 1,
|
||||
numberOfPages: 1);
|
||||
_mockApiHttpClient.GetAsync<PaginatedMusicAlbumLiteDto>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
_mockApiHttpClient.GetAsync<PaginatedDto<MusicAlbumLiteDto>>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
.Returns(expectedResponse);
|
||||
|
||||
// Act
|
||||
|
||||
+15
-13
@@ -2,11 +2,13 @@
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.Enums.Common;
|
||||
using Lumina.Presentation.Web.Common.Requests.Library.AudioLibrary.MusicLibrary.Artists;
|
||||
using Lumina.Presentation.Web.Common.Routes;
|
||||
using Lumina.Presentation.Web.Core.Endpoints.Library.AudioLibrary.MusicLibrary.Artists.GetMusicArtists;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.Requests.Library.AudioLibrary.MusicLibrary.Artists;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
@@ -29,7 +31,7 @@ public class GetMusicArtistsEndpointTests
|
||||
private readonly IApiHttpClient _mockApiHttpClient;
|
||||
private readonly GetMusicArtistsEndpoint _sut;
|
||||
private readonly GetMusicArtistsLiteRequestFixture _getMusicArtistsLiteRequestFixture = new();
|
||||
private readonly PaginatedMusicArtistLiteDtoFixture _paginatedMusicArtistLiteDtoFixture = new();
|
||||
private readonly PaginatedDtoFixture<MusicArtistLiteDto> _paginatedMusicArtistLiteDtoFixture = new();
|
||||
private readonly MusicArtistLiteDtoFixture _musicArtistLiteDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
@@ -58,7 +60,7 @@ public class GetMusicArtistsEndpointTests
|
||||
shouldIgnoreThePrefixForAlphaPicker: true,
|
||||
sortBy: SORT_BY,
|
||||
sortOrder: SortOrder.Descending);
|
||||
_mockApiHttpClient.GetAsync<PaginatedMusicArtistLiteDto>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
_mockApiHttpClient.GetAsync<PaginatedDto<MusicArtistLiteDto>>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
.Returns(_paginatedMusicArtistLiteDtoFixture.Create());
|
||||
string expectedEndpoint = $"{BuildExpectedEndpoint(libraryId)}?currentPage=2&perPage=48" +
|
||||
$"&searchTerm={Uri.EscapeDataString(SEARCH_TERM)}" +
|
||||
@@ -71,7 +73,7 @@ public class GetMusicArtistsEndpointTests
|
||||
await _sut.ExecuteAsync(request, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
await _mockApiHttpClient.Received(1).GetAsync<PaginatedMusicArtistLiteDto>(
|
||||
await _mockApiHttpClient.Received(1).GetAsync<PaginatedDto<MusicArtistLiteDto>>(
|
||||
Arg.Is<string>(endpoint => endpoint == expectedEndpoint),
|
||||
Arg.Any<CancellationToken>());
|
||||
}
|
||||
@@ -89,7 +91,7 @@ public class GetMusicArtistsEndpointTests
|
||||
includeFilterAlphaKey: false,
|
||||
includeSortBy: false,
|
||||
includeSortOrder: false);
|
||||
_mockApiHttpClient.GetAsync<PaginatedMusicArtistLiteDto>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
_mockApiHttpClient.GetAsync<PaginatedDto<MusicArtistLiteDto>>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
.Returns(_paginatedMusicArtistLiteDtoFixture.Create());
|
||||
string expectedEndpoint = $"{BuildExpectedEndpoint(libraryId)}?shouldIgnoreThePrefixForAlphaPicker=False";
|
||||
|
||||
@@ -97,7 +99,7 @@ public class GetMusicArtistsEndpointTests
|
||||
await _sut.ExecuteAsync(request, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
await _mockApiHttpClient.Received(1).GetAsync<PaginatedMusicArtistLiteDto>(
|
||||
await _mockApiHttpClient.Received(1).GetAsync<PaginatedDto<MusicArtistLiteDto>>(
|
||||
Arg.Is<string>(endpoint => endpoint == expectedEndpoint),
|
||||
Arg.Any<CancellationToken>());
|
||||
}
|
||||
@@ -116,7 +118,7 @@ public class GetMusicArtistsEndpointTests
|
||||
includeFilterAlphaKey: false,
|
||||
includeSortBy: false,
|
||||
includeSortOrder: false);
|
||||
_mockApiHttpClient.GetAsync<PaginatedMusicArtistLiteDto>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
_mockApiHttpClient.GetAsync<PaginatedDto<MusicArtistLiteDto>>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
.Returns(_paginatedMusicArtistLiteDtoFixture.Create());
|
||||
string expectedEndpoint = $"{BuildExpectedEndpoint(libraryId)}?searchTerm={Uri.EscapeDataString(SEARCH_TERM)}&shouldIgnoreThePrefixForAlphaPicker=False";
|
||||
|
||||
@@ -124,7 +126,7 @@ public class GetMusicArtistsEndpointTests
|
||||
await _sut.ExecuteAsync(request, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
await _mockApiHttpClient.Received(1).GetAsync<PaginatedMusicArtistLiteDto>(
|
||||
await _mockApiHttpClient.Received(1).GetAsync<PaginatedDto<MusicArtistLiteDto>>(
|
||||
Arg.Is<string>(endpoint => endpoint == expectedEndpoint),
|
||||
Arg.Any<CancellationToken>());
|
||||
}
|
||||
@@ -142,7 +144,7 @@ public class GetMusicArtistsEndpointTests
|
||||
includeCurrentPage: false,
|
||||
includePerPage: false,
|
||||
includeSortOrder: false);
|
||||
_mockApiHttpClient.GetAsync<PaginatedMusicArtistLiteDto>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
_mockApiHttpClient.GetAsync<PaginatedDto<MusicArtistLiteDto>>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
.Returns(_paginatedMusicArtistLiteDtoFixture.Create());
|
||||
string expectedEndpoint = $"{BuildExpectedEndpoint(libraryId)}?shouldIgnoreThePrefixForAlphaPicker=False";
|
||||
|
||||
@@ -150,7 +152,7 @@ public class GetMusicArtistsEndpointTests
|
||||
await _sut.ExecuteAsync(request, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
await _mockApiHttpClient.Received(1).GetAsync<PaginatedMusicArtistLiteDto>(
|
||||
await _mockApiHttpClient.Received(1).GetAsync<PaginatedDto<MusicArtistLiteDto>>(
|
||||
Arg.Is<string>(endpoint => endpoint == expectedEndpoint),
|
||||
Arg.Any<CancellationToken>());
|
||||
}
|
||||
@@ -168,7 +170,7 @@ public class GetMusicArtistsEndpointTests
|
||||
includeFilterAlphaKey: false,
|
||||
includeSortBy: false,
|
||||
includeSortOrder: false);
|
||||
_mockApiHttpClient.GetAsync<PaginatedMusicArtistLiteDto>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
_mockApiHttpClient.GetAsync<PaginatedDto<MusicArtistLiteDto>>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
.Returns(_paginatedMusicArtistLiteDtoFixture.Create());
|
||||
string expectedEndpoint = $"{BuildExpectedEndpoint(libraryId)}?currentPage=3&shouldIgnoreThePrefixForAlphaPicker=False";
|
||||
|
||||
@@ -176,7 +178,7 @@ public class GetMusicArtistsEndpointTests
|
||||
await _sut.ExecuteAsync(request, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
await _mockApiHttpClient.Received(1).GetAsync<PaginatedMusicArtistLiteDto>(
|
||||
await _mockApiHttpClient.Received(1).GetAsync<PaginatedDto<MusicArtistLiteDto>>(
|
||||
Arg.Is<string>(endpoint => endpoint == expectedEndpoint),
|
||||
Arg.Any<CancellationToken>());
|
||||
}
|
||||
@@ -186,13 +188,13 @@ public class GetMusicArtistsEndpointTests
|
||||
{
|
||||
// Arrange
|
||||
GetMusicArtistsLiteRequest request = _getMusicArtistsLiteRequestFixture.Create();
|
||||
PaginatedMusicArtistLiteDto expectedResponse = _paginatedMusicArtistLiteDtoFixture.Create(
|
||||
PaginatedDto<MusicArtistLiteDto> expectedResponse = _paginatedMusicArtistLiteDtoFixture.Create(
|
||||
data: [_musicArtistLiteDtoFixture.Create(name: "Test Artist")],
|
||||
currentPage: 1,
|
||||
perPage: 20,
|
||||
count: 1,
|
||||
numberOfPages: 1);
|
||||
_mockApiHttpClient.GetAsync<PaginatedMusicArtistLiteDto>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
_mockApiHttpClient.GetAsync<PaginatedDto<MusicArtistLiteDto>>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
.Returns(expectedResponse);
|
||||
|
||||
// Act
|
||||
|
||||
+19
-17
@@ -2,10 +2,12 @@
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.Requests.Library.AudioLibrary.MusicLibrary.Tracks;
|
||||
using Lumina.Presentation.Web.Common.Routes;
|
||||
using Lumina.Presentation.Web.Core.Endpoints.Library.AudioLibrary.MusicLibrary.Tracks.GetAlbumTracks;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.DTO.AudioLibrary.MusicLibrary;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.Requests.Library.AudioLibrary.MusicLibrary.Tracks;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
@@ -28,7 +30,7 @@ public class GetAlbumTracksEndpointTests
|
||||
private readonly IApiHttpClient _mockApiHttpClient;
|
||||
private readonly GetAlbumTracksEndpoint _sut;
|
||||
private readonly GetAlbumTracksLiteRequestFixture _getAlbumTracksLiteRequestFixture = new();
|
||||
private readonly PaginatedMusicTrackLiteDtoFixture _paginatedMusicTrackLiteDtoFixture = new();
|
||||
private readonly PaginatedDtoFixture<MusicTrackLiteDto> _paginatedMusicTrackLiteDtoFixture = new();
|
||||
private readonly MusicTrackLiteDtoFixture _musicTrackLiteDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
@@ -45,14 +47,14 @@ public class GetAlbumTracksEndpointTests
|
||||
{
|
||||
// Arrange
|
||||
GetAlbumTracksLiteRequest request = _getAlbumTracksLiteRequestFixture.Create(currentPage: 2, perPage: 48);
|
||||
_mockApiHttpClient.GetAsync<PaginatedMusicTrackLiteDto>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
_mockApiHttpClient.GetAsync<PaginatedDto<MusicTrackLiteDto>>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
.Returns(_paginatedMusicTrackLiteDtoFixture.Create());
|
||||
|
||||
// Act
|
||||
await _sut.ExecuteAsync(request, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
await _mockApiHttpClient.Received(1).GetAsync<PaginatedMusicTrackLiteDto>(
|
||||
await _mockApiHttpClient.Received(1).GetAsync<PaginatedDto<MusicTrackLiteDto>>(
|
||||
Arg.Is<string>(endpoint => endpoint == $"{BuildExpectedEndpoint(request.LibraryId, Guid.Parse(request.ArtistId), Guid.Parse(request.AlbumId))}?currentPage=2&perPage=48"),
|
||||
Arg.Any<CancellationToken>());
|
||||
}
|
||||
@@ -62,14 +64,14 @@ public class GetAlbumTracksEndpointTests
|
||||
{
|
||||
// Arrange
|
||||
GetAlbumTracksLiteRequest request = _getAlbumTracksLiteRequestFixture.Create();
|
||||
_mockApiHttpClient.GetAsync<PaginatedMusicTrackLiteDto>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
_mockApiHttpClient.GetAsync<PaginatedDto<MusicTrackLiteDto>>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
.Returns(_paginatedMusicTrackLiteDtoFixture.Create());
|
||||
|
||||
// Act
|
||||
await _sut.ExecuteAsync(request, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
await _mockApiHttpClient.Received(1).GetAsync<PaginatedMusicTrackLiteDto>(
|
||||
await _mockApiHttpClient.Received(1).GetAsync<PaginatedDto<MusicTrackLiteDto>>(
|
||||
Arg.Is<string>(endpoint => endpoint == BuildExpectedEndpoint(request.LibraryId, Guid.Parse(request.ArtistId), Guid.Parse(request.AlbumId))),
|
||||
Arg.Any<CancellationToken>());
|
||||
}
|
||||
@@ -79,14 +81,14 @@ public class GetAlbumTracksEndpointTests
|
||||
{
|
||||
// Arrange
|
||||
GetAlbumTracksLiteRequest request = _getAlbumTracksLiteRequestFixture.Create(currentPage: 3);
|
||||
_mockApiHttpClient.GetAsync<PaginatedMusicTrackLiteDto>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
_mockApiHttpClient.GetAsync<PaginatedDto<MusicTrackLiteDto>>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
.Returns(_paginatedMusicTrackLiteDtoFixture.Create());
|
||||
|
||||
// Act
|
||||
await _sut.ExecuteAsync(request, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
await _mockApiHttpClient.Received(1).GetAsync<PaginatedMusicTrackLiteDto>(
|
||||
await _mockApiHttpClient.Received(1).GetAsync<PaginatedDto<MusicTrackLiteDto>>(
|
||||
Arg.Is<string>(endpoint => endpoint == $"{BuildExpectedEndpoint(request.LibraryId, Guid.Parse(request.ArtistId), Guid.Parse(request.AlbumId))}?currentPage=3"),
|
||||
Arg.Any<CancellationToken>());
|
||||
}
|
||||
@@ -96,14 +98,14 @@ public class GetAlbumTracksEndpointTests
|
||||
{
|
||||
// Arrange
|
||||
GetAlbumTracksLiteRequest request = _getAlbumTracksLiteRequestFixture.Create(perPage: 24);
|
||||
_mockApiHttpClient.GetAsync<PaginatedMusicTrackLiteDto>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
_mockApiHttpClient.GetAsync<PaginatedDto<MusicTrackLiteDto>>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
.Returns(_paginatedMusicTrackLiteDtoFixture.Create());
|
||||
|
||||
// Act
|
||||
await _sut.ExecuteAsync(request, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
await _mockApiHttpClient.Received(1).GetAsync<PaginatedMusicTrackLiteDto>(
|
||||
await _mockApiHttpClient.Received(1).GetAsync<PaginatedDto<MusicTrackLiteDto>>(
|
||||
Arg.Is<string>(endpoint => endpoint == $"{BuildExpectedEndpoint(request.LibraryId, Guid.Parse(request.ArtistId), Guid.Parse(request.AlbumId))}?perPage=24"),
|
||||
Arg.Any<CancellationToken>());
|
||||
}
|
||||
@@ -113,14 +115,14 @@ public class GetAlbumTracksEndpointTests
|
||||
{
|
||||
// Arrange
|
||||
GetAlbumTracksLiteRequest request = _getAlbumTracksLiteRequestFixture.Create(artistId: "not-a-guid", currentPage: 1, perPage: 20);
|
||||
_mockApiHttpClient.GetAsync<PaginatedMusicTrackLiteDto>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
_mockApiHttpClient.GetAsync<PaginatedDto<MusicTrackLiteDto>>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
.Returns(_paginatedMusicTrackLiteDtoFixture.Create());
|
||||
|
||||
// Act
|
||||
await _sut.ExecuteAsync(request, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
await _mockApiHttpClient.Received(1).GetAsync<PaginatedMusicTrackLiteDto>(
|
||||
await _mockApiHttpClient.Received(1).GetAsync<PaginatedDto<MusicTrackLiteDto>>(
|
||||
Arg.Is<string>(endpoint => endpoint == $"{BuildExpectedEndpoint(request.LibraryId, Guid.Empty, Guid.Parse(request.AlbumId))}?currentPage=1&perPage=20"),
|
||||
Arg.Any<CancellationToken>());
|
||||
}
|
||||
@@ -130,14 +132,14 @@ public class GetAlbumTracksEndpointTests
|
||||
{
|
||||
// Arrange
|
||||
GetAlbumTracksLiteRequest request = _getAlbumTracksLiteRequestFixture.Create(albumId: "' OR '1'='1", currentPage: 1, perPage: 20);
|
||||
_mockApiHttpClient.GetAsync<PaginatedMusicTrackLiteDto>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
_mockApiHttpClient.GetAsync<PaginatedDto<MusicTrackLiteDto>>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
.Returns(_paginatedMusicTrackLiteDtoFixture.Create());
|
||||
|
||||
// Act
|
||||
await _sut.ExecuteAsync(request, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
await _mockApiHttpClient.Received(1).GetAsync<PaginatedMusicTrackLiteDto>(
|
||||
await _mockApiHttpClient.Received(1).GetAsync<PaginatedDto<MusicTrackLiteDto>>(
|
||||
Arg.Is<string>(endpoint => endpoint == $"{BuildExpectedEndpoint(request.LibraryId, Guid.Parse(request.ArtistId), Guid.Empty)}?currentPage=1&perPage=20"),
|
||||
Arg.Any<CancellationToken>());
|
||||
}
|
||||
@@ -147,14 +149,14 @@ public class GetAlbumTracksEndpointTests
|
||||
{
|
||||
// Arrange
|
||||
GetAlbumTracksLiteRequest request = _getAlbumTracksLiteRequestFixture.Create(artistId: string.Empty, albumId: string.Empty, currentPage: 1, perPage: 20);
|
||||
_mockApiHttpClient.GetAsync<PaginatedMusicTrackLiteDto>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
_mockApiHttpClient.GetAsync<PaginatedDto<MusicTrackLiteDto>>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
.Returns(_paginatedMusicTrackLiteDtoFixture.Create());
|
||||
|
||||
// Act
|
||||
await _sut.ExecuteAsync(request, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
await _mockApiHttpClient.Received(1).GetAsync<PaginatedMusicTrackLiteDto>(
|
||||
await _mockApiHttpClient.Received(1).GetAsync<PaginatedDto<MusicTrackLiteDto>>(
|
||||
Arg.Is<string>(endpoint => endpoint == $"{BuildExpectedEndpoint(request.LibraryId, Guid.Empty, Guid.Empty)}?currentPage=1&perPage=20"),
|
||||
Arg.Any<CancellationToken>());
|
||||
}
|
||||
@@ -164,13 +166,13 @@ public class GetAlbumTracksEndpointTests
|
||||
{
|
||||
// Arrange
|
||||
GetAlbumTracksLiteRequest request = _getAlbumTracksLiteRequestFixture.Create();
|
||||
PaginatedMusicTrackLiteDto expectedResponse = _paginatedMusicTrackLiteDtoFixture.Create(
|
||||
PaginatedDto<MusicTrackLiteDto> expectedResponse = _paginatedMusicTrackLiteDtoFixture.Create(
|
||||
data: [_musicTrackLiteDtoFixture.Create(title: "Test Track")],
|
||||
currentPage: 1,
|
||||
perPage: 20,
|
||||
count: 1,
|
||||
numberOfPages: 1);
|
||||
_mockApiHttpClient.GetAsync<PaginatedMusicTrackLiteDto>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
_mockApiHttpClient.GetAsync<PaginatedDto<MusicTrackLiteDto>>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
.Returns(expectedResponse);
|
||||
|
||||
// Act
|
||||
|
||||
+9
-7
@@ -1,11 +1,13 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||
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.Common;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.DTO.Libraries;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.Requests.Libraries;
|
||||
using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
|
||||
@@ -30,7 +32,7 @@ public class GetLibraryItemsEndpointTests
|
||||
private readonly IApiHttpClient _mockApiHttpClient;
|
||||
private readonly GetLibraryItemsEndpoint _sut;
|
||||
private readonly GetBooksLiteRequestFixture _getBooksLiteRequestFixture = new();
|
||||
private readonly PaginatedBookLiteDtoFixture _paginatedBookLiteDtoFixture = new();
|
||||
private readonly PaginatedDtoFixture<BookLiteDto> _paginatedBookLiteDtoFixture = new();
|
||||
private readonly BookLiteDtoFixture _bookLiteDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
@@ -54,14 +56,14 @@ public class GetLibraryItemsEndpointTests
|
||||
shouldIgnoreThePrefixForAlphaPicker: true,
|
||||
sortBy: "title",
|
||||
sortOrder: SortOrder.Ascending);
|
||||
_mockApiHttpClient.GetAsync<PaginatedBookLiteDto>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
_mockApiHttpClient.GetAsync<PaginatedDto<BookLiteDto>>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
.Returns(_paginatedBookLiteDtoFixture.Create());
|
||||
|
||||
// Act
|
||||
await _sut.ExecuteAsync(request, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
await _mockApiHttpClient.Received(1).GetAsync<PaginatedBookLiteDto>(
|
||||
await _mockApiHttpClient.Received(1).GetAsync<PaginatedDto<BookLiteDto>>(
|
||||
Arg.Is<string>(endpoint =>
|
||||
endpoint.StartsWith(ApiRoutes.Books.GET_BOOKS_LITE.Replace("{libraryId}", request.LibraryId.ToString()), StringComparison.OrdinalIgnoreCase) &&
|
||||
endpoint.Contains("currentPage=2") &&
|
||||
@@ -79,14 +81,14 @@ public class GetLibraryItemsEndpointTests
|
||||
{
|
||||
// Arrange
|
||||
GetBooksLiteRequest request = _getBooksLiteRequestFixture.Create();
|
||||
_mockApiHttpClient.GetAsync<PaginatedBookLiteDto>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
_mockApiHttpClient.GetAsync<PaginatedDto<BookLiteDto>>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
.Returns(_paginatedBookLiteDtoFixture.Create());
|
||||
|
||||
// Act
|
||||
await _sut.ExecuteAsync(request, CancellationToken.None);
|
||||
|
||||
// Assert
|
||||
await _mockApiHttpClient.Received(1).GetAsync<PaginatedBookLiteDto>(
|
||||
await _mockApiHttpClient.Received(1).GetAsync<PaginatedDto<BookLiteDto>>(
|
||||
Arg.Is<string>(endpoint =>
|
||||
endpoint.StartsWith(ApiRoutes.Books.GET_BOOKS_LITE.Replace("{libraryId}", request.LibraryId.ToString()), StringComparison.OrdinalIgnoreCase) &&
|
||||
endpoint.EndsWith("?shouldIgnoreThePrefixForAlphaPicker=False", StringComparison.OrdinalIgnoreCase) &&
|
||||
@@ -101,13 +103,13 @@ public class GetLibraryItemsEndpointTests
|
||||
{
|
||||
// Arrange
|
||||
GetBooksLiteRequest request = _getBooksLiteRequestFixture.Create();
|
||||
PaginatedBookLiteDto expectedResponse = _paginatedBookLiteDtoFixture.Create(
|
||||
PaginatedDto<BookLiteDto> 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>())
|
||||
_mockApiHttpClient.GetAsync<PaginatedDto<BookLiteDto>>(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
.Returns(expectedResponse);
|
||||
|
||||
// Act
|
||||
|
||||
Reference in new issue
Block a user