mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 13:11:10 +00:00
Adds music stack test coverage and fixes playlist cache and stream error handling
This commit is contained in:
1 parent
394f6b510c
commit
aba803b106
197 files changed
+29081
-34
No files matched your search
+41
@@ -0,0 +1,41 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="TrackAccessSummaryDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class TrackAccessSummaryDtoFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="TrackAccessSummaryDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="trackCount">Optional. The number of distinct requested tracks that exist.</param>
|
||||
/// <param name="libraryIds">Optional. The Ids of the media libraries that contain those tracks. Defaults to a single random library.</param>
|
||||
/// <returns>The created <see cref="TrackAccessSummaryDto"/>.</returns>
|
||||
public TrackAccessSummaryDto Create(
|
||||
int? trackCount = null,
|
||||
IReadOnlyList<Guid>? libraryIds = null)
|
||||
{
|
||||
return new TrackAccessSummaryDto(
|
||||
trackCount ?? 1,
|
||||
libraryIds ?? [Guid.NewGuid()]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="TrackAccessSummaryDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="TrackAccessSummaryDto"/> instances.</returns>
|
||||
public List<TrackAccessSummaryDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="TrackStreamDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class TrackStreamDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="TrackStreamDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="path">Optional. The file system path of the track.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the media library the track belongs to.</param>
|
||||
/// <param name="albumId">Optional. The Id of the album the track belongs to.</param>
|
||||
/// <param name="artistId">Optional. The Id of the artist that owns the album the track belongs to.</param>
|
||||
/// <param name="container">Optional. The container of the audio file of the track.</param>
|
||||
/// <param name="audioCodec">Optional. The audio codec used by the audio file of the track.</param>
|
||||
/// <param name="durationInSeconds">Optional. The duration of the audio of the track, in seconds.</param>
|
||||
/// <param name="sampleRate">Optional. The sample rate of the audio of the track, in Hz.</param>
|
||||
/// <param name="channels">Optional. The number of audio channels of the track.</param>
|
||||
/// <param name="bitDepth">Optional. The bit depth of the audio of the track.</param>
|
||||
/// <param name="bitrate">Optional. The bitrate of the audio of the track, in kbps.</param>
|
||||
/// <param name="includeContainer">Whether the container should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeAudioCodec">Whether the audio codec should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeBitDepth">Whether the bit depth should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeBitrate">Whether the bitrate should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="TrackStreamDto"/>.</returns>
|
||||
public TrackStreamDto Create(
|
||||
string? path = null,
|
||||
Guid? libraryId = null,
|
||||
Guid? albumId = null,
|
||||
Guid? artistId = null,
|
||||
string? container = null,
|
||||
string? audioCodec = null,
|
||||
int? durationInSeconds = null,
|
||||
int? sampleRate = null,
|
||||
int? channels = null,
|
||||
int? bitDepth = null,
|
||||
int? bitrate = null,
|
||||
bool includeContainer = true,
|
||||
bool includeAudioCodec = true,
|
||||
bool includeBitDepth = true,
|
||||
bool includeBitrate = true)
|
||||
{
|
||||
return new TrackStreamDto(
|
||||
path ?? Path.Combine(_faker.System.DirectoryPath(), _faker.System.FileName("flac")),
|
||||
libraryId ?? Guid.NewGuid(),
|
||||
albumId ?? Guid.NewGuid(),
|
||||
artistId ?? Guid.NewGuid(),
|
||||
includeContainer ? (container ?? _faker.PickRandom("FLAC", "MP3", "OGG", "MP4", "AAC", "WAV")) : null,
|
||||
includeAudioCodec ? (audioCodec ?? _faker.PickRandom("FLAC", "MP3", "AAC", "ALAC", "PCM")) : null,
|
||||
durationInSeconds ?? _faker.Random.Int(1, 3600),
|
||||
sampleRate ?? _faker.PickRandom(44100, 48000, 96000),
|
||||
channels ?? _faker.PickRandom(1, 2, 6),
|
||||
includeBitDepth ? (bitDepth ?? _faker.Random.Int(8, 32)) : null,
|
||||
includeBitrate ? (bitrate ?? _faker.Random.Int(96, 1411)) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="TrackStreamDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="TrackStreamDto"/> instances.</returns>
|
||||
public List<TrackStreamDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DTO.Playlists;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistBulkAddResultDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistBulkAddResultDtoFixture
|
||||
{
|
||||
private const long MAXIMUM_RANDOM_POSITION = 1_000_000_000L;
|
||||
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PlaylistBulkAddResultDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="firstPosition">Optional. The sparse order key of the first appended entry. Defaults to a bounded random key.</param>
|
||||
/// <param name="addedCount">Optional. The number of entries appended. Defaults to a bounded random count.</param>
|
||||
/// <returns>The created <see cref="PlaylistBulkAddResultDto"/>.</returns>
|
||||
public PlaylistBulkAddResultDto Create(
|
||||
long? firstPosition = null,
|
||||
int? addedCount = null)
|
||||
{
|
||||
return new PlaylistBulkAddResultDto(
|
||||
firstPosition ?? _faker.Random.Long(0, MAXIMUM_RANDOM_POSITION),
|
||||
addedCount ?? _faker.Random.Int(0, 1_000));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="PlaylistBulkAddResultDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PlaylistBulkAddResultDto"/> instances.</returns>
|
||||
public List<PlaylistBulkAddResultDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DTO.Playlists;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Playlists;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistSummaryDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistSummaryDtoFixture
|
||||
{
|
||||
private const int MAXIMUM_ENTRY_COUNT = 10_000;
|
||||
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PlaylistSummaryDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the playlist.</param>
|
||||
/// <param name="name">Optional. The name of the playlist.</param>
|
||||
/// <param name="description">Optional. The description of the playlist.</param>
|
||||
/// <param name="type">Optional. The kind of media the playlist holds. Defaults to the only supported kind.</param>
|
||||
/// <param name="entryCount">Optional. The number of entries of the playlist. Defaults to a bounded random count.</param>
|
||||
/// <param name="createdOnUtc">Optional. The date and time when the playlist was created.</param>
|
||||
/// <param name="updatedOnUtc">Optional. The date and time when the playlist was last updated.</param>
|
||||
/// <param name="includeDescription">Whether the description should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeUpdatedOnUtc">Whether the update date and time should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="PlaylistSummaryDto"/>.</returns>
|
||||
public PlaylistSummaryDto Create(
|
||||
Guid? id = null,
|
||||
string? name = null,
|
||||
string? description = null,
|
||||
PlaylistType? type = null,
|
||||
int? entryCount = null,
|
||||
DateTime? createdOnUtc = null,
|
||||
DateTime? updatedOnUtc = null,
|
||||
bool includeDescription = true,
|
||||
bool includeUpdatedOnUtc = false)
|
||||
{
|
||||
return new PlaylistSummaryDto(
|
||||
id ?? _faker.Random.Guid(),
|
||||
name ?? _faker.Lorem.Sentence(3),
|
||||
includeDescription ? (description ?? _faker.Lorem.Sentence()) : null,
|
||||
type ?? PlaylistType.Music,
|
||||
entryCount ?? _faker.Random.Int(0, MAXIMUM_ENTRY_COUNT),
|
||||
createdOnUtc ?? _faker.Date.Past(),
|
||||
includeUpdatedOnUtc ? (updatedOnUtc ?? _faker.Date.Recent()) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="PlaylistSummaryDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PlaylistSummaryDto"/> instances.</returns>
|
||||
public List<PlaylistSummaryDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -39,6 +39,7 @@ public class TrackEntityFixture
|
||||
/// <param name="title">Optional. The title of the track.</param>
|
||||
/// <param name="container">Optional. The container of the audio file of the track.</param>
|
||||
/// <param name="trackNumber">Optional. The number of the track on its disc.</param>
|
||||
/// <param name="discNumber">Optional. The number of the disc the track belongs to.</param>
|
||||
/// <param name="originalReleaseDate">Optional. The original release date of the track.</param>
|
||||
/// <param name="originalReleaseYear">Optional. The original release year of the track.</param>
|
||||
/// <param name="reReleaseDate">Optional. The re-release date of the track.</param>
|
||||
@@ -66,6 +67,7 @@ public class TrackEntityFixture
|
||||
string? title = null,
|
||||
string? container = null,
|
||||
int? trackNumber = null,
|
||||
int? discNumber = null,
|
||||
DateOnly? originalReleaseDate = null,
|
||||
int? originalReleaseYear = null,
|
||||
DateOnly? reReleaseDate = null,
|
||||
@@ -136,7 +138,7 @@ public class TrackEntityFixture
|
||||
.RuleFor(x => x.ReplayGainAlbumPeak, f => includeReplayGain ? (replayGainAlbumPeak ?? f.Random.Decimal(0m, 1.5m)) : null)
|
||||
.RuleFor(x => x.Bitrate, Random.Shared.Next(96, 1411))
|
||||
.RuleFor(x => x.TrackNumber, f => trackNumber ?? f.Random.Int(1, 20))
|
||||
.RuleFor(x => x.DiscNumber, Random.Shared.Next(1, 3))
|
||||
.RuleFor(x => x.DiscNumber, discNumber ?? Random.Shared.Next(1, 3))
|
||||
.RuleFor(x => x.Script, f => f.Random.String2(f.Random.Number(1, 50)))
|
||||
.RuleFor(x => x.Key, f => f.PickRandom<MusicKey>())
|
||||
.RuleFor(x => x.Bpm, Random.Shared.Next(40, 240))
|
||||
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks.Queries.GetTrackStream;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks.Queries.GetTrackStream;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetTrackStreamQuery"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetTrackStreamQueryFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid query to get the audio file of a track, for streaming.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">Optional. The Id of the media library the track belongs to.</param>
|
||||
/// <param name="artistId">Optional. The Id of the artist the album of the track belongs to.</param>
|
||||
/// <param name="albumId">Optional. The Id of the album the track belongs to.</param>
|
||||
/// <param name="trackId">Optional. The Id of the track whose audio file is streamed.</param>
|
||||
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</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="includeTrackId">Whether the track Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="GetTrackStreamQuery"/>.</returns>
|
||||
public GetTrackStreamQuery Create(
|
||||
string? libraryId = null,
|
||||
string? artistId = null,
|
||||
string? albumId = null,
|
||||
string? trackId = null,
|
||||
bool includeLibraryId = true,
|
||||
bool includeArtistId = true,
|
||||
bool includeAlbumId = true,
|
||||
bool includeTrackId = true)
|
||||
{
|
||||
return new GetTrackStreamQuery(
|
||||
includeLibraryId ? (libraryId ?? Guid.NewGuid().ToString()) : null,
|
||||
includeArtistId ? (artistId ?? Guid.NewGuid().ToString()) : null,
|
||||
includeAlbumId ? (albumId ?? Guid.NewGuid().ToString()) : null,
|
||||
includeTrackId ? (trackId ?? Guid.NewGuid().ToString()) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetTrackStreamQuery"/> instances.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="GetTrackStreamQuery"/> instances.</returns>
|
||||
public List<GetTrackStreamQuery> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.Playlists.Commands.AddPlaylistEntries;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.Playlists.Commands.AddPlaylistEntries;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="AddPlaylistEntriesCommand"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AddPlaylistEntriesCommandFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="AddPlaylistEntriesCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="playlistId">Optional. The Id of the playlist, taken from the route.</param>
|
||||
/// <param name="trackIds">Optional. The Ids of the tracks to add, in order.</param>
|
||||
/// <param name="trackCount">Optional. The number of random track Ids to generate when <paramref name="trackIds"/> is not supplied.</param>
|
||||
/// <param name="includePlaylistId">Whether the playlist Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeTrackIds">Whether the track Ids should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="AddPlaylistEntriesCommand"/>.</returns>
|
||||
public AddPlaylistEntriesCommand Create(
|
||||
string? playlistId = null,
|
||||
List<Guid>? trackIds = null,
|
||||
int trackCount = 3,
|
||||
bool includePlaylistId = true,
|
||||
bool includeTrackIds = true)
|
||||
{
|
||||
return new AddPlaylistEntriesCommand(
|
||||
includePlaylistId ? (playlistId ?? Guid.NewGuid().ToString()) : null,
|
||||
includeTrackIds ? (trackIds ?? CreateRandomTrackIds(trackCount)) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="AddPlaylistEntriesCommand"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="AddPlaylistEntriesCommand"/> instances.</returns>
|
||||
public List<AddPlaylistEntriesCommand> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the requested number of distinct random track Ids.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of track Ids to create.</param>
|
||||
/// <returns>The created track Ids.</returns>
|
||||
private static List<Guid> CreateRandomTrackIds(int count)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Guid.NewGuid())];
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.Playlists.Commands.AddPlaylistEntry;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.Playlists.Commands.AddPlaylistEntry;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="AddPlaylistEntryCommand"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AddPlaylistEntryCommandFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="AddPlaylistEntryCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="playlistId">Optional. The Id of the playlist, taken from the route.</param>
|
||||
/// <param name="trackId">Optional. The Id of the track to add.</param>
|
||||
/// <param name="includePlaylistId">Whether the playlist Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeTrackId">Whether the track Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="AddPlaylistEntryCommand"/>.</returns>
|
||||
public AddPlaylistEntryCommand Create(
|
||||
string? playlistId = null,
|
||||
Guid? trackId = null,
|
||||
bool includePlaylistId = true,
|
||||
bool includeTrackId = true)
|
||||
{
|
||||
return new AddPlaylistEntryCommand(
|
||||
includePlaylistId ? (playlistId ?? Guid.NewGuid().ToString()) : null,
|
||||
includeTrackId ? (trackId ?? Guid.NewGuid()) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="AddPlaylistEntryCommand"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="AddPlaylistEntryCommand"/> instances.</returns>
|
||||
public List<AddPlaylistEntryCommand> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.Playlists.Commands.AddPlaylistScopeEntries;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.Playlists.Commands.AddPlaylistScopeEntries;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="AddPlaylistScopeEntriesCommand"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AddPlaylistScopeEntriesCommandFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="AddPlaylistScopeEntriesCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="playlistId">Optional. The Id of the playlist, taken from the route.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the music library the scope belongs to.</param>
|
||||
/// <param name="artistId">Optional. The Id of the artist the scope is limited to.</param>
|
||||
/// <param name="albumId">Optional. The Id of the album the scope is limited to.</param>
|
||||
/// <param name="includePlaylistId">Whether the playlist Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeLibraryId">Whether the library Id should be included, or forced to <see langword="null"/>.</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>
|
||||
/// <returns>The created <see cref="AddPlaylistScopeEntriesCommand"/>.</returns>
|
||||
public AddPlaylistScopeEntriesCommand Create(
|
||||
string? playlistId = null,
|
||||
Guid? libraryId = null,
|
||||
Guid? artistId = null,
|
||||
Guid? albumId = null,
|
||||
bool includePlaylistId = true,
|
||||
bool includeLibraryId = true,
|
||||
bool includeArtistId = false,
|
||||
bool includeAlbumId = false)
|
||||
{
|
||||
return new AddPlaylistScopeEntriesCommand(
|
||||
includePlaylistId ? (playlistId ?? Guid.NewGuid().ToString()) : null,
|
||||
includeLibraryId ? (libraryId ?? Guid.NewGuid()) : null,
|
||||
includeArtistId ? (artistId ?? Guid.NewGuid()) : null,
|
||||
includeAlbumId ? (albumId ?? Guid.NewGuid()) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="AddPlaylistScopeEntriesCommand"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="AddPlaylistScopeEntriesCommand"/> instances.</returns>
|
||||
public List<AddPlaylistScopeEntriesCommand> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+4
-2
@@ -25,16 +25,18 @@ public class CreatePlaylistCommandFixture
|
||||
/// <param name="type">Optional. The kind of media the playlist holds. Defaults to the only supported kind.</param>
|
||||
/// <param name="includeDescription">Whether the description should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeType">Whether the media type should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeName">Whether the name should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="CreatePlaylistCommand"/>.</returns>
|
||||
public CreatePlaylistCommand Create(
|
||||
string? name = null,
|
||||
string? description = null,
|
||||
PlaylistType? type = null,
|
||||
bool includeDescription = true,
|
||||
bool includeType = true)
|
||||
bool includeType = true,
|
||||
bool includeName = true)
|
||||
{
|
||||
return new CreatePlaylistCommand(
|
||||
name ?? _faker.Lorem.Sentence(3),
|
||||
includeName ? (name ?? _faker.Lorem.Sentence(3)) : null,
|
||||
includeDescription ? (description ?? _faker.Lorem.Sentence()) : null,
|
||||
includeType ? (type ?? PlaylistType.Music) : null);
|
||||
}
|
||||
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.Playlists.Commands.DeletePlaylist;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.Playlists.Commands.DeletePlaylist;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="DeletePlaylistCommand"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class DeletePlaylistCommandFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="DeletePlaylistCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="playlistId">Optional. The Id of the playlist, taken from the route.</param>
|
||||
/// <param name="includePlaylistId">Whether the playlist Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="DeletePlaylistCommand"/>.</returns>
|
||||
public DeletePlaylistCommand Create(
|
||||
string? playlistId = null,
|
||||
bool includePlaylistId = true)
|
||||
{
|
||||
return new DeletePlaylistCommand(
|
||||
includePlaylistId ? (playlistId ?? Guid.NewGuid().ToString()) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="DeletePlaylistCommand"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="DeletePlaylistCommand"/> instances.</returns>
|
||||
public List<DeletePlaylistCommand> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Core.Playlists.Commands.MovePlaylistEntry;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.Playlists.Commands.MovePlaylistEntry;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MovePlaylistEntryCommand"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MovePlaylistEntryCommandFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MovePlaylistEntryCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="playlistId">Optional. The Id of the playlist, taken from the route.</param>
|
||||
/// <param name="playlistEntryId">Optional. The Id of the entry to move, taken from the route.</param>
|
||||
/// <param name="targetPosition">Optional. The new zero based position of the entry.</param>
|
||||
/// <param name="includePlaylistId">Whether the playlist Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includePlaylistEntryId">Whether the entry Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeTargetPosition">Whether the target position should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="MovePlaylistEntryCommand"/>.</returns>
|
||||
public MovePlaylistEntryCommand Create(
|
||||
string? playlistId = null,
|
||||
string? playlistEntryId = null,
|
||||
int? targetPosition = null,
|
||||
bool includePlaylistId = true,
|
||||
bool includePlaylistEntryId = true,
|
||||
bool includeTargetPosition = true)
|
||||
{
|
||||
return new MovePlaylistEntryCommand(
|
||||
includePlaylistId ? (playlistId ?? Guid.NewGuid().ToString()) : null,
|
||||
includePlaylistEntryId ? (playlistEntryId ?? Guid.NewGuid().ToString()) : null,
|
||||
includeTargetPosition ? (targetPosition ?? _faker.Random.Int(0, 1_000)) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="MovePlaylistEntryCommand"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MovePlaylistEntryCommand"/> instances.</returns>
|
||||
public List<MovePlaylistEntryCommand> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.Playlists.Commands.RemovePlaylistEntry;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.Playlists.Commands.RemovePlaylistEntry;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="RemovePlaylistEntryCommand"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class RemovePlaylistEntryCommandFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="RemovePlaylistEntryCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="playlistId">Optional. The Id of the playlist, taken from the route.</param>
|
||||
/// <param name="playlistEntryId">Optional. The Id of the entry to remove, taken from the route.</param>
|
||||
/// <param name="includePlaylistId">Whether the playlist Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includePlaylistEntryId">Whether the entry Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="RemovePlaylistEntryCommand"/>.</returns>
|
||||
public RemovePlaylistEntryCommand Create(
|
||||
string? playlistId = null,
|
||||
string? playlistEntryId = null,
|
||||
bool includePlaylistId = true,
|
||||
bool includePlaylistEntryId = true)
|
||||
{
|
||||
return new RemovePlaylistEntryCommand(
|
||||
includePlaylistId ? (playlistId ?? Guid.NewGuid().ToString()) : null,
|
||||
includePlaylistEntryId ? (playlistEntryId ?? Guid.NewGuid().ToString()) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="RemovePlaylistEntryCommand"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="RemovePlaylistEntryCommand"/> instances.</returns>
|
||||
public List<RemovePlaylistEntryCommand> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Core.Playlists.Commands.UpdatePlaylist;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.Playlists.Commands.UpdatePlaylist;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="UpdatePlaylistCommand"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UpdatePlaylistCommandFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="UpdatePlaylistCommand"/>.
|
||||
/// </summary>
|
||||
/// <param name="playlistId">Optional. The Id of the playlist, taken from the route.</param>
|
||||
/// <param name="name">Optional. The name of the playlist.</param>
|
||||
/// <param name="description">Optional. The description of the playlist.</param>
|
||||
/// <param name="includePlaylistId">Whether the playlist Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeName">Whether the name should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeDescription">Whether the description should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="UpdatePlaylistCommand"/>.</returns>
|
||||
public UpdatePlaylistCommand Create(
|
||||
string? playlistId = null,
|
||||
string? name = null,
|
||||
string? description = null,
|
||||
bool includePlaylistId = true,
|
||||
bool includeName = true,
|
||||
bool includeDescription = true)
|
||||
{
|
||||
return new UpdatePlaylistCommand(
|
||||
includePlaylistId ? (playlistId ?? Guid.NewGuid().ToString()) : null,
|
||||
includeName ? (name ?? _faker.Lorem.Sentence(3)) : null,
|
||||
includeDescription ? (description ?? _faker.Lorem.Sentence()) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="UpdatePlaylistCommand"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="UpdatePlaylistCommand"/> instances.</returns>
|
||||
public List<UpdatePlaylistCommand> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.Playlists.Queries.GetPlaylists;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.Playlists.Queries.GetPlaylists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetPlaylistsQuery"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetPlaylistsQueryFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a <see cref="GetPlaylistsQuery"/>.
|
||||
/// </summary>
|
||||
/// <returns>The created <see cref="GetPlaylistsQuery"/>.</returns>
|
||||
/// <remarks>
|
||||
/// The query carries no members, because the current user is always taken from the authenticated request context.
|
||||
/// </remarks>
|
||||
public GetPlaylistsQuery Create()
|
||||
{
|
||||
return new GetPlaylistsQuery();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetPlaylistsQuery"/> instances.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="GetPlaylistsQuery"/> instances.</returns>
|
||||
public List<GetPlaylistsQuery> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Core.UsersManagement.Settings.Commands.UpdatePlaybackState;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.UsersManagement.Settings.Commands.UpdatePlaybackState;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="UpdatePlaybackStateCommand"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UpdatePlaybackStateCommandFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid command to update the playback state the player reports for the current user.
|
||||
/// </summary>
|
||||
/// <param name="volume">Optional. The last volume the player reported, as a value between 0 and 1.</param>
|
||||
/// <param name="isMuted">Optional. The last mute state the player reported.</param>
|
||||
/// <param name="includeVolume">Whether the volume should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <param name="includeIsMuted">Whether the mute state should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="UpdatePlaybackStateCommand"/>.</returns>
|
||||
public UpdatePlaybackStateCommand Create(
|
||||
double? volume = null,
|
||||
bool? isMuted = null,
|
||||
bool includeVolume = true,
|
||||
bool includeIsMuted = true)
|
||||
{
|
||||
return new UpdatePlaybackStateCommand(
|
||||
includeVolume ? volume ?? _faker.Random.Double(0, 1) : null,
|
||||
includeIsMuted ? isMuted ?? _faker.Random.Bool() : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="UpdatePlaybackStateCommand"/> instances.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="UpdatePlaybackStateCommand"/> instances.</returns>
|
||||
public List<UpdatePlaybackStateCommand> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.UsersManagement.Settings.Queries.GetPlaybackState;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.UsersManagement.Settings.Queries.GetPlaybackState;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="GetPlaybackStateQuery"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetPlaybackStateQueryFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="GetPlaybackStateQuery"/> instance.
|
||||
/// </summary>
|
||||
/// <returns>The created <see cref="GetPlaybackStateQuery"/>.</returns>
|
||||
public GetPlaybackStateQuery Create()
|
||||
{
|
||||
return new GetPlaybackStateQuery();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="GetPlaybackStateQuery"/> instances.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="GetPlaybackStateQuery"/> instances.</returns>
|
||||
public List<GetPlaybackStateQuery> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user