Adds music stack test coverage and fixes playlist cache and stream error handling

This commit is contained in:
BinaryAlley committed 2026-10-29 15:46:24 +02:00
1 parent 394f6b510c
commit aba803b106
197 files changed
+29081 -34

No files matched your search

@@ -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())];
}
}
@@ -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())];
}
}
@@ -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())];
}
}
@@ -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())];
}
}
@@ -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);
}
@@ -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())];
}
}
@@ -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())];
}
}
@@ -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())];
}
}
@@ -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())];
}
}
@@ -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())];
}
}
@@ -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())];
}
}
@@ -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())];
}
}