Implements tests for commit 067e9a21d0

This commit is contained in:
BinaryAlley committed 2026-10-28 23:14:47 +02:00
1 parent aeefa9487e
commit a75447062f
18 files changed
+3156

No files matched your search

@@ -0,0 +1,63 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Presentation.Web.Common.DTO.AudioLibrary.MusicLibrary;
using System;
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="MusicShuffleTrackDto"/> class.
/// </summary>
[ExcludeFromCodeCoverage]
public class MusicShuffleTrackDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a new <see cref="MusicShuffleTrackDto"/> instance with randomized test data.
/// </summary>
/// <param name="trackId">Optional. The Id of the track.</param>
/// <param name="title">Optional. The title of the track.</param>
/// <param name="durationInSeconds">Optional. The duration of the track in seconds.</param>
/// <param name="albumId">Optional. The Id of the album the track belongs to.</param>
/// <param name="albumTitle">Optional. The title of the album the track belongs to.</param>
/// <param name="artistId">Optional. The Id of the artist the album belongs to.</param>
/// <param name="coverPath">Optional. The path of the cover of the album.</param>
/// <param name="includeCoverPath">Whether the cover path should be included, or forced to <see langword="null"/>.</param>
/// <returns>A configured <see cref="MusicShuffleTrackDto"/> instance.</returns>
public MusicShuffleTrackDto Create(
Guid? trackId = null,
string? title = null,
int? durationInSeconds = null,
Guid? albumId = null,
string? albumTitle = null,
Guid? artistId = null,
string? coverPath = null,
bool includeCoverPath = true)
{
return new MusicShuffleTrackDto
{
TrackId = trackId ?? _faker.Random.Guid(),
Title = title ?? _faker.Lorem.Sentence(),
DurationInSeconds = durationInSeconds ?? _faker.Random.Int(1, 7200),
AlbumId = albumId ?? _faker.Random.Guid(),
AlbumTitle = albumTitle ?? _faker.Lorem.Sentence(),
ArtistId = artistId ?? _faker.Random.Guid(),
CoverPath = includeCoverPath ? (coverPath ?? _faker.System.FileName("jpg")) : null
};
}
/// <summary>
/// Creates multiple <see cref="MusicShuffleTrackDto"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="MusicShuffleTrackDto"/> instances.</returns>
public List<MusicShuffleTrackDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,58 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Requests.Library.AudioLibrary.MusicLibrary.Tracks;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Library.AudioLibrary.MusicLibrary.Tracks;
/// <summary>
/// Fixture class for the <see cref="ShuffleTracksRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ShuffleTracksRequestFixture
{
/// <summary>
/// Creates a random valid <see cref="ShuffleTracksRequest"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library the tracks are sampled from.</param>
/// <param name="count">Optional. The maximum number of tracks to return.</param>
/// <param name="artistId">Optional. The Id of the artist whose tracks are sampled.</param>
/// <param name="albumId">Optional. The Id of the album whose tracks are sampled.</param>
/// <param name="excludedTrackIds">Optional. The tracks that must not be returned.</param>
/// <param name="includeArtistId">Whether the artist Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAlbumId">Whether the album Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeExcludedTrackIds">Whether the excluded track Ids should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="ShuffleTracksRequest"/>.</returns>
public ShuffleTracksRequest Create(
Guid? libraryId = null,
int? count = null,
Guid? artistId = null,
Guid? albumId = null,
List<Guid>? excludedTrackIds = null,
bool includeArtistId = true,
bool includeAlbumId = true,
bool includeExcludedTrackIds = true)
{
return new ShuffleTracksRequest(
libraryId ?? Guid.NewGuid(),
count ?? Random.Shared.Next(1, 501),
includeArtistId ? (artistId ?? Guid.NewGuid()) : null,
includeAlbumId ? (albumId ?? Guid.NewGuid()) : null,
includeExcludedTrackIds
? (excludedTrackIds ?? [.. Enumerable.Range(0, Random.Shared.Next(0, 3)).Select(_ => Guid.NewGuid())])
: null);
}
/// <summary>
/// Creates a list of <see cref="ShuffleTracksRequest"/> records with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="ShuffleTracksRequest"/> records.</returns>
public List<ShuffleTracksRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}