mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-02 21: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())];
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="TrackStreamDataDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class TrackStreamDataDtoFixture
|
||||
{
|
||||
private static readonly AudioFileFormat[] s_audioFileFormats = [AudioFileFormat.MP3, AudioFileFormat.FLAC, AudioFileFormat.OGG, AudioFileFormat.WAV];
|
||||
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="TrackStreamDataDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="path">Optional. The file system path of the audio file of the track.</param>
|
||||
/// <param name="format">Optional. The file format of the audio file of the track.</param>
|
||||
/// <param name="length">Optional. The length of the audio file of the track, in bytes.</param>
|
||||
/// <param name="lastModified">Optional. The date and time when the audio file of the track was last modified.</param>
|
||||
/// <returns>The created <see cref="TrackStreamDataDto"/>.</returns>
|
||||
public TrackStreamDataDto Create(
|
||||
string? path = null,
|
||||
AudioFileFormat? format = null,
|
||||
long? length = null,
|
||||
DateTimeOffset? lastModified = null)
|
||||
{
|
||||
return new TrackStreamDataDto(
|
||||
path ?? Path.Combine(_faker.System.DirectoryPath(), _faker.System.FileName("mp3")),
|
||||
format ?? _faker.PickRandom(s_audioFileFormats),
|
||||
length ?? _faker.Random.Long(1, 10_000_000),
|
||||
lastModified ?? _faker.Date.PastOffset());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="TrackStreamDataDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="TrackStreamDataDto"/> instances.</returns>
|
||||
public List<TrackStreamDataDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Requests.Playlists;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Requests.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="AddPlaylistEntriesRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AddPlaylistEntriesRequestFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="AddPlaylistEntriesRequest"/>.
|
||||
/// </summary>
|
||||
/// <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="includeTrackIds">Whether the track Ids should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="AddPlaylistEntriesRequest"/>.</returns>
|
||||
public AddPlaylistEntriesRequest Create(
|
||||
List<Guid>? trackIds = null,
|
||||
int trackCount = 3,
|
||||
bool includeTrackIds = true)
|
||||
{
|
||||
return new AddPlaylistEntriesRequest(
|
||||
includeTrackIds ? (trackIds ?? CreateRandomTrackIds(trackCount)) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="AddPlaylistEntriesRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="AddPlaylistEntriesRequest"/> instances.</returns>
|
||||
public List<AddPlaylistEntriesRequest> 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())];
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Requests.Playlists;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Requests.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="AddPlaylistEntryRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AddPlaylistEntryRequestFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="AddPlaylistEntryRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="trackId">Optional. The Id of the track to add.</param>
|
||||
/// <param name="includeTrackId">Whether the track Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="AddPlaylistEntryRequest"/>.</returns>
|
||||
public AddPlaylistEntryRequest Create(
|
||||
Guid? trackId = null,
|
||||
bool includeTrackId = true)
|
||||
{
|
||||
return new AddPlaylistEntryRequest(
|
||||
includeTrackId ? (trackId ?? Guid.NewGuid()) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="AddPlaylistEntryRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="AddPlaylistEntryRequest"/> instances.</returns>
|
||||
public List<AddPlaylistEntryRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Requests.Playlists;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Requests.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="AddPlaylistScopeEntriesRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AddPlaylistScopeEntriesRequestFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="AddPlaylistScopeEntriesRequest"/>.
|
||||
/// </summary>
|
||||
/// <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="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="AddPlaylistScopeEntriesRequest"/>.</returns>
|
||||
public AddPlaylistScopeEntriesRequest Create(
|
||||
Guid? libraryId = null,
|
||||
Guid? artistId = null,
|
||||
Guid? albumId = null,
|
||||
bool includeArtistId = false,
|
||||
bool includeAlbumId = false)
|
||||
{
|
||||
return new AddPlaylistScopeEntriesRequest(
|
||||
libraryId ?? Guid.NewGuid(),
|
||||
includeArtistId ? (artistId ?? Guid.NewGuid()) : null,
|
||||
includeAlbumId ? (albumId ?? Guid.NewGuid()) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="AddPlaylistScopeEntriesRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="AddPlaylistScopeEntriesRequest"/> instances.</returns>
|
||||
public List<AddPlaylistScopeEntriesRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Requests.Playlists;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Playlists;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Requests.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="CreatePlaylistRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class CreatePlaylistRequestFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="CreatePlaylistRequest"/>.
|
||||
/// </summary>
|
||||
/// <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="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>
|
||||
/// <param name="includeType">Whether the media type should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="CreatePlaylistRequest"/>.</returns>
|
||||
public CreatePlaylistRequest Create(
|
||||
string? name = null,
|
||||
string? description = null,
|
||||
PlaylistType? type = null,
|
||||
bool includeName = true,
|
||||
bool includeDescription = true,
|
||||
bool includeType = true)
|
||||
{
|
||||
return new CreatePlaylistRequest(
|
||||
includeName ? (name ?? _faker.Lorem.Sentence(3)) : null,
|
||||
includeDescription ? (description ?? _faker.Lorem.Sentence()) : null,
|
||||
includeType ? (type ?? PlaylistType.Music) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="CreatePlaylistRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="CreatePlaylistRequest"/> instances.</returns>
|
||||
public List<CreatePlaylistRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Requests.Playlists;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Requests.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MovePlaylistEntryRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MovePlaylistEntryRequestFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MovePlaylistEntryRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="targetPosition">Optional. The new zero based position of the entry. Defaults to a bounded random position.</param>
|
||||
/// <param name="includeTargetPosition">Whether the target position should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="MovePlaylistEntryRequest"/>.</returns>
|
||||
public MovePlaylistEntryRequest Create(
|
||||
int? targetPosition = null,
|
||||
bool includeTargetPosition = true)
|
||||
{
|
||||
return new MovePlaylistEntryRequest(
|
||||
includeTargetPosition ? (targetPosition ?? _faker.Random.Int(0, 1_000)) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="MovePlaylistEntryRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MovePlaylistEntryRequest"/> instances.</returns>
|
||||
public List<MovePlaylistEntryRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Requests.Playlists;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Requests.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="UpdatePlaylistRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UpdatePlaylistRequestFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="UpdatePlaylistRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="name">Optional. The name of the playlist.</param>
|
||||
/// <param name="description">Optional. The description of the playlist.</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="UpdatePlaylistRequest"/>.</returns>
|
||||
public UpdatePlaylistRequest Create(
|
||||
string? name = null,
|
||||
string? description = null,
|
||||
bool includeName = true,
|
||||
bool includeDescription = true)
|
||||
{
|
||||
return new UpdatePlaylistRequest(
|
||||
includeName ? (name ?? _faker.Lorem.Sentence(3)) : null,
|
||||
includeDescription ? (description ?? _faker.Lorem.Sentence()) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="UpdatePlaylistRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="UpdatePlaylistRequest"/> instances.</returns>
|
||||
public List<UpdatePlaylistRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Requests.UsersManagement.Settings;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Requests.UsersManagement.Settings;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="UpdatePlaybackStateRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UpdatePlaybackStateRequestFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="UpdatePlaybackStateRequest"/>.
|
||||
/// </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="UpdatePlaybackStateRequest"/>.</returns>
|
||||
public UpdatePlaybackStateRequest Create(
|
||||
double? volume = null,
|
||||
bool? isMuted = null,
|
||||
bool includeVolume = true,
|
||||
bool includeIsMuted = true)
|
||||
{
|
||||
return new UpdatePlaybackStateRequest(
|
||||
includeVolume ? volume ?? _faker.Random.Double(0, 1) : null,
|
||||
includeIsMuted ? isMuted ?? _faker.Random.Bool() : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="UpdatePlaybackStateRequest"/> instances.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<UpdatePlaybackStateRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Responses.Playlists;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Playlists;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Responses.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistDetailsResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistDetailsResponseFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PlaylistDetailsResponse"/>.
|
||||
/// </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.</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 time should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="PlaylistDetailsResponse"/>.</returns>
|
||||
public PlaylistDetailsResponse Create(
|
||||
Guid? id = null,
|
||||
string? name = null,
|
||||
string? description = null,
|
||||
PlaylistType? type = null,
|
||||
DateTime? updatedOnUtc = null,
|
||||
bool includeDescription = true,
|
||||
bool includeUpdatedOnUtc = true)
|
||||
{
|
||||
return new PlaylistDetailsResponse(
|
||||
id ?? _faker.Random.Guid(),
|
||||
name ?? _faker.Lorem.Sentence(3),
|
||||
includeDescription ? (description ?? _faker.Lorem.Sentence()) : null,
|
||||
type ?? PlaylistType.Music,
|
||||
includeUpdatedOnUtc ? (updatedOnUtc ?? DateTime.UtcNow.AddMinutes(-_faker.Random.Int(1, 1_440))) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="PlaylistDetailsResponse"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PlaylistDetailsResponse"/> instances.</returns>
|
||||
public List<PlaylistDetailsResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Responses.Playlists;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Responses.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistEntriesAddedResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistEntriesAddedResponseFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PlaylistEntriesAddedResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="playlistId">Optional. The Id of the playlist the entries were added to.</param>
|
||||
/// <param name="addedCount">Optional. The number of entries that were appended.</param>
|
||||
/// <param name="updatedOnUtc">Optional. The date and time when the playlist was last updated.</param>
|
||||
/// <param name="includeUpdatedOnUtc">Whether the update time should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="PlaylistEntriesAddedResponse"/>.</returns>
|
||||
public PlaylistEntriesAddedResponse Create(
|
||||
Guid? playlistId = null,
|
||||
int? addedCount = null,
|
||||
DateTime? updatedOnUtc = null,
|
||||
bool includeUpdatedOnUtc = true)
|
||||
{
|
||||
return new PlaylistEntriesAddedResponse(
|
||||
playlistId ?? _faker.Random.Guid(),
|
||||
addedCount ?? _faker.Random.Int(0, 1_000),
|
||||
includeUpdatedOnUtc ? (updatedOnUtc ?? DateTime.UtcNow.AddMinutes(-_faker.Random.Int(1, 1_440))) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="PlaylistEntriesAddedResponse"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PlaylistEntriesAddedResponse"/> instances.</returns>
|
||||
public List<PlaylistEntriesAddedResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Responses.Playlists;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Responses.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistEntryAddedResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistEntryAddedResponseFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly PlaylistEntryResponseFixture _playlistEntryResponseFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PlaylistEntryAddedResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="playlistId">Optional. The Id of the playlist the entry was added to.</param>
|
||||
/// <param name="entry">Optional. The added entry.</param>
|
||||
/// <param name="updatedOnUtc">Optional. The date and time when the playlist was last updated.</param>
|
||||
/// <param name="includeUpdatedOnUtc">Whether the update time should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="PlaylistEntryAddedResponse"/>.</returns>
|
||||
public PlaylistEntryAddedResponse Create(
|
||||
Guid? playlistId = null,
|
||||
PlaylistEntryResponse? entry = null,
|
||||
DateTime? updatedOnUtc = null,
|
||||
bool includeUpdatedOnUtc = true)
|
||||
{
|
||||
return new PlaylistEntryAddedResponse(
|
||||
playlistId ?? _faker.Random.Guid(),
|
||||
entry ?? _playlistEntryResponseFixture.Create(),
|
||||
includeUpdatedOnUtc ? (updatedOnUtc ?? DateTime.UtcNow.AddMinutes(-_faker.Random.Int(1, 1_440))) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="PlaylistEntryAddedResponse"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PlaylistEntryAddedResponse"/> instances.</returns>
|
||||
public List<PlaylistEntryAddedResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Responses.Playlists;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Responses.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistEntryMovedResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistEntryMovedResponseFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PlaylistEntryMovedResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="playlistId">Optional. The Id of the playlist whose entry was moved.</param>
|
||||
/// <param name="entryId">Optional. The Id of the moved entry.</param>
|
||||
/// <param name="position">Optional. The new zero based position of the entry.</param>
|
||||
/// <param name="updatedOnUtc">Optional. The date and time when the playlist was last updated.</param>
|
||||
/// <param name="includeUpdatedOnUtc">Whether the update time should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="PlaylistEntryMovedResponse"/>.</returns>
|
||||
public PlaylistEntryMovedResponse Create(
|
||||
Guid? playlistId = null,
|
||||
Guid? entryId = null,
|
||||
int? position = null,
|
||||
DateTime? updatedOnUtc = null,
|
||||
bool includeUpdatedOnUtc = true)
|
||||
{
|
||||
return new PlaylistEntryMovedResponse(
|
||||
playlistId ?? _faker.Random.Guid(),
|
||||
entryId ?? _faker.Random.Guid(),
|
||||
position ?? _faker.Random.Int(0, 1_000),
|
||||
includeUpdatedOnUtc ? (updatedOnUtc ?? DateTime.UtcNow.AddMinutes(-_faker.Random.Int(1, 1_440))) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="PlaylistEntryMovedResponse"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PlaylistEntryMovedResponse"/> instances.</returns>
|
||||
public List<PlaylistEntryMovedResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Responses.Playlists;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Responses.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistEntryRemovedResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistEntryRemovedResponseFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PlaylistEntryRemovedResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="playlistId">Optional. The Id of the playlist the entry was removed from.</param>
|
||||
/// <param name="removedEntryId">Optional. The Id of the removed entry.</param>
|
||||
/// <param name="repositionedCount">Optional. The number of entries that were repositioned, which the contract always reports as zero.</param>
|
||||
/// <param name="updatedOnUtc">Optional. The date and time when the playlist was last updated.</param>
|
||||
/// <param name="includeUpdatedOnUtc">Whether the update time should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="PlaylistEntryRemovedResponse"/>.</returns>
|
||||
public PlaylistEntryRemovedResponse Create(
|
||||
Guid? playlistId = null,
|
||||
Guid? removedEntryId = null,
|
||||
int? repositionedCount = null,
|
||||
DateTime? updatedOnUtc = null,
|
||||
bool includeUpdatedOnUtc = true)
|
||||
{
|
||||
return new PlaylistEntryRemovedResponse(
|
||||
playlistId ?? _faker.Random.Guid(),
|
||||
removedEntryId ?? _faker.Random.Guid(),
|
||||
repositionedCount ?? 0,
|
||||
includeUpdatedOnUtc ? (updatedOnUtc ?? DateTime.UtcNow.AddMinutes(-_faker.Random.Int(1, 1_440))) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="PlaylistEntryRemovedResponse"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PlaylistEntryRemovedResponse"/> instances.</returns>
|
||||
public List<PlaylistEntryRemovedResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Responses.Playlists;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Playlists;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Responses.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistSummaryResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistSummaryResponseFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PlaylistSummaryResponse"/>.
|
||||
/// </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.</param>
|
||||
/// <param name="entryCount">Optional. The number of entries of the playlist.</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 time should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="PlaylistSummaryResponse"/>.</returns>
|
||||
public PlaylistSummaryResponse 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 = true)
|
||||
{
|
||||
return new PlaylistSummaryResponse(
|
||||
id ?? _faker.Random.Guid(),
|
||||
name ?? _faker.Lorem.Sentence(3),
|
||||
includeDescription ? (description ?? _faker.Lorem.Sentence()) : null,
|
||||
type ?? PlaylistType.Music,
|
||||
entryCount ?? _faker.Random.Int(0, 1_000),
|
||||
createdOnUtc ?? DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)),
|
||||
includeUpdatedOnUtc ? (updatedOnUtc ?? DateTime.UtcNow.AddMinutes(-_faker.Random.Int(1, 1_440))) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="PlaylistSummaryResponse"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PlaylistSummaryResponse"/> instances.</returns>
|
||||
public List<PlaylistSummaryResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Responses.UsersManagement.Settings;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Responses.UsersManagement.Settings;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaybackStateResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaybackStateResponseFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PlaybackStateResponse"/>.
|
||||
/// </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>
|
||||
/// <returns>The created <see cref="PlaybackStateResponse"/>.</returns>
|
||||
public PlaybackStateResponse Create(
|
||||
double? volume = null,
|
||||
bool? isMuted = null)
|
||||
{
|
||||
return new PlaybackStateResponse(
|
||||
volume ?? _faker.Random.Double(0, 1),
|
||||
isMuted ?? _faker.Random.Bool());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="PlaybackStateResponse"/> instances.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<PlaybackStateResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.PlaylistBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MediaItemId"/> value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaItemIdFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MediaItemId"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The raw value of the media item Id.</param>
|
||||
/// <returns>The created <see cref="MediaItemId"/>.</returns>
|
||||
public MediaItemId Create(
|
||||
Guid? value = null)
|
||||
{
|
||||
return MediaItemId.Create(value ?? Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="MediaItemId"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MediaItemId"/> instances.</returns>
|
||||
public List<MediaItemId> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.PlaylistBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="UserId"/> value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UserIdFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="UserId"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The raw value of the user Id.</param>
|
||||
/// <returns>The created <see cref="UserId"/>.</returns>
|
||||
public UserId Create(
|
||||
Guid? value = null)
|
||||
{
|
||||
return UserId.Create(value ?? Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="UserId"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="UserId"/> instances.</returns>
|
||||
public List<UserId> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.Entities;
|
||||
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.PlaylistBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Playlists;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistEntry"/> entity.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistEntryFixture
|
||||
{
|
||||
private const long MAXIMUM_RANDOM_POSITION = 1_000_000_000L;
|
||||
|
||||
private readonly Faker _faker = new();
|
||||
private readonly PlaylistEntryIdFixture _playlistEntryIdFixture = new();
|
||||
private readonly MediaItemIdFixture _mediaItemIdFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PlaylistEntry"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the entry.</param>
|
||||
/// <param name="mediaItemId">Optional. The Id of the media item referenced by the entry.</param>
|
||||
/// <param name="mediaItemType">Optional. The kind of media item referenced by the entry. Defaults to a music track, which is the kind a music playlist accepts.</param>
|
||||
/// <param name="position">Optional. The sparse order key of the entry. Defaults to a bounded random key.</param>
|
||||
/// <returns>The created <see cref="PlaylistEntry"/>.</returns>
|
||||
public PlaylistEntry Create(
|
||||
PlaylistEntryId? id = null,
|
||||
MediaItemId? mediaItemId = null,
|
||||
PlaylistMediaItemType? mediaItemType = null,
|
||||
long? position = null)
|
||||
{
|
||||
return PlaylistEntry.Create(
|
||||
id ?? _playlistEntryIdFixture.Create(),
|
||||
mediaItemId ?? _mediaItemIdFixture.Create(),
|
||||
mediaItemType ?? PlaylistMediaItemType.MusicTrack,
|
||||
position ?? _faker.Random.Long(0, MAXIMUM_RANDOM_POSITION)).Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="PlaylistEntry"/> instances with randomized test data and distinct positions.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The positions are spaced apart and unique, so the created entries can be placed in the same playlist without violating the
|
||||
/// uniqueness invariant of the sparse order keys.
|
||||
/// </remarks>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PlaylistEntry"/> instances.</returns>
|
||||
public List<PlaylistEntry> CreateMany(int count = 3)
|
||||
{
|
||||
long firstPosition = _faker.Random.Long(0, MAXIMUM_RANDOM_POSITION);
|
||||
return [.. Enumerable.Range(0, count).Select(index => Create(position: firstPosition + index))];
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.Events;
|
||||
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.PlaylistBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Playlists;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistCreatedDomainEvent"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistCreatedDomainEventFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly PlaylistIdFixture _playlistIdFixture = new();
|
||||
private readonly UserIdFixture _userIdFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PlaylistCreatedDomainEvent"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the domain event.</param>
|
||||
/// <param name="playlistId">Optional. The unique identifier of the playlist.</param>
|
||||
/// <param name="userId">Optional. The unique identifier of the user that owns the playlist.</param>
|
||||
/// <param name="name">Optional. The name of the playlist.</param>
|
||||
/// <param name="type">Optional. The kind of media the playlist holds. Defaults to the only supported kind.</param>
|
||||
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
|
||||
/// <returns>The created <see cref="PlaylistCreatedDomainEvent"/>.</returns>
|
||||
public PlaylistCreatedDomainEvent Create(
|
||||
Guid? id = null,
|
||||
PlaylistId? playlistId = null,
|
||||
UserId? userId = null,
|
||||
string? name = null,
|
||||
PlaylistType? type = null,
|
||||
DateTime? occurredOnUtc = null)
|
||||
{
|
||||
return new PlaylistCreatedDomainEvent(
|
||||
id ?? Guid.NewGuid(),
|
||||
playlistId ?? _playlistIdFixture.Create(),
|
||||
userId ?? _userIdFixture.Create(),
|
||||
name ?? _faker.Lorem.Sentence(3),
|
||||
type ?? PlaylistType.Music,
|
||||
occurredOnUtc ?? DateTime.UtcNow);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="PlaylistCreatedDomainEvent"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PlaylistCreatedDomainEvent"/> instances.</returns>
|
||||
public List<PlaylistCreatedDomainEvent> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.Events;
|
||||
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.PlaylistBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistDeletedDomainEvent"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistDeletedDomainEventFixture
|
||||
{
|
||||
private readonly PlaylistIdFixture _playlistIdFixture = new();
|
||||
private readonly UserIdFixture _userIdFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PlaylistDeletedDomainEvent"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the domain event.</param>
|
||||
/// <param name="playlistId">Optional. The unique identifier of the playlist.</param>
|
||||
/// <param name="userId">Optional. The unique identifier of the user that owned the playlist.</param>
|
||||
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
|
||||
/// <returns>The created <see cref="PlaylistDeletedDomainEvent"/>.</returns>
|
||||
public PlaylistDeletedDomainEvent Create(
|
||||
Guid? id = null,
|
||||
PlaylistId? playlistId = null,
|
||||
UserId? userId = null,
|
||||
DateTime? occurredOnUtc = null)
|
||||
{
|
||||
return new PlaylistDeletedDomainEvent(
|
||||
id ?? Guid.NewGuid(),
|
||||
playlistId ?? _playlistIdFixture.Create(),
|
||||
userId ?? _userIdFixture.Create(),
|
||||
occurredOnUtc ?? DateTime.UtcNow);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="PlaylistDeletedDomainEvent"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PlaylistDeletedDomainEvent"/> instances.</returns>
|
||||
public List<PlaylistDeletedDomainEvent> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.Events;
|
||||
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.PlaylistBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistDetailsUpdatedDomainEvent"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistDetailsUpdatedDomainEventFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly PlaylistIdFixture _playlistIdFixture = new();
|
||||
private readonly UserIdFixture _userIdFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PlaylistDetailsUpdatedDomainEvent"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the domain event.</param>
|
||||
/// <param name="playlistId">Optional. The unique identifier of the playlist.</param>
|
||||
/// <param name="userId">Optional. The unique identifier of the user that owns the playlist.</param>
|
||||
/// <param name="name">Optional. The new name of the playlist.</param>
|
||||
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
|
||||
/// <returns>The created <see cref="PlaylistDetailsUpdatedDomainEvent"/>.</returns>
|
||||
public PlaylistDetailsUpdatedDomainEvent Create(
|
||||
Guid? id = null,
|
||||
PlaylistId? playlistId = null,
|
||||
UserId? userId = null,
|
||||
string? name = null,
|
||||
DateTime? occurredOnUtc = null)
|
||||
{
|
||||
return new PlaylistDetailsUpdatedDomainEvent(
|
||||
id ?? Guid.NewGuid(),
|
||||
playlistId ?? _playlistIdFixture.Create(),
|
||||
userId ?? _userIdFixture.Create(),
|
||||
name ?? _faker.Lorem.Sentence(3),
|
||||
occurredOnUtc ?? DateTime.UtcNow);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="PlaylistDetailsUpdatedDomainEvent"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PlaylistDetailsUpdatedDomainEvent"/> instances.</returns>
|
||||
public List<PlaylistDetailsUpdatedDomainEvent> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.Entities;
|
||||
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.PlaylistBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Playlists;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="Playlist"/> domain aggregate.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly PlaylistIdFixture _playlistIdFixture = new();
|
||||
private readonly UserIdFixture _userIdFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="Playlist"/> domain aggregate, with pre-existing data.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the playlist.</param>
|
||||
/// <param name="userId">Optional. The Id of the user that owns 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="entries">Optional. The ordered entries of the playlist. Defaults to no entries.</param>
|
||||
/// <param name="createdOnUtc">Optional. The date and time when the playlist was created. Defaults to a few days in the past.</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 no value.</param>
|
||||
/// <param name="includeUpdatedOnUtc">Whether the update date and time should be included, or forced to no value.</param>
|
||||
/// <returns>The created <see cref="Playlist"/>.</returns>
|
||||
/// <remarks>
|
||||
/// The playlist is built through the rehydrating <see cref="Playlist.Create(PlaylistId, UserId, string, Optional{string}, PlaylistType, List{PlaylistEntry}, DateTime, Optional{DateTime})"/>
|
||||
/// overload, so it carries no domain events and is never marked as deleted.
|
||||
/// </remarks>
|
||||
public Playlist Create(
|
||||
PlaylistId? id = null,
|
||||
UserId? userId = null,
|
||||
string? name = null,
|
||||
string? description = null,
|
||||
PlaylistType? type = null,
|
||||
IEnumerable<PlaylistEntry>? entries = null,
|
||||
DateTime? createdOnUtc = null,
|
||||
DateTime? updatedOnUtc = null,
|
||||
bool includeDescription = true,
|
||||
bool includeUpdatedOnUtc = false)
|
||||
{
|
||||
return Playlist.Create(
|
||||
id ?? _playlistIdFixture.Create(),
|
||||
userId ?? _userIdFixture.Create(),
|
||||
name ?? _faker.Lorem.Sentence(3),
|
||||
includeDescription ? Optional<string>.FromNullable(description ?? _faker.Lorem.Sentence()) : Optional<string>.None(),
|
||||
type ?? PlaylistType.Music,
|
||||
entries is null ? [] : [.. entries],
|
||||
createdOnUtc ?? DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)).AddMinutes(-_faker.Random.Int(0, 59)),
|
||||
includeUpdatedOnUtc ? Optional<DateTime>.Some(updatedOnUtc ?? DateTime.UtcNow) : Optional<DateTime>.None()).Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="Playlist"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="Playlist"/> instances.</returns>
|
||||
public List<Playlist> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistEntryId"/> value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistEntryIdFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PlaylistEntryId"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The raw value of the playlist entry Id.</param>
|
||||
/// <returns>The created <see cref="PlaylistEntryId"/>.</returns>
|
||||
public PlaylistEntryId Create(
|
||||
Guid? value = null)
|
||||
{
|
||||
return PlaylistEntryId.Create(value ?? Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="PlaylistEntryId"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PlaylistEntryId"/> instances.</returns>
|
||||
public List<PlaylistEntryId> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistId"/> value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistIdFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PlaylistId"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The raw value of the playlist Id.</param>
|
||||
/// <returns>The created <see cref="PlaylistId"/>.</returns>
|
||||
public PlaylistId Create(
|
||||
Guid? value = null)
|
||||
{
|
||||
return PlaylistId.Create(value ?? Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="PlaylistId"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PlaylistId"/> instances.</returns>
|
||||
public List<PlaylistId> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ public class StubApiHttpClient : IApiHttpClient
|
||||
private readonly Dictionary<string, Func<object, object>> _postResponseFactories = [];
|
||||
private readonly Dictionary<string, Func<object, object>> _putResponseFactories = [];
|
||||
private readonly HashSet<string> _deleteSuccessEndpoints = [];
|
||||
private readonly Dictionary<string, ApiException> _deleteExceptions = [];
|
||||
private BlobDataDto? _blobResponse;
|
||||
|
||||
/// <summary>
|
||||
@@ -167,6 +168,16 @@ public class StubApiHttpClient : IApiHttpClient
|
||||
_deleteSuccessEndpoints.Add(endpoint);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers the exception thrown when the specified DELETE endpoint is called.
|
||||
/// </summary>
|
||||
/// <param name="endpoint">The API endpoint for which to register the exception.</param>
|
||||
/// <param name="exception">The exception to throw.</param>
|
||||
public void RegisterDeleteException(string endpoint, ApiException exception)
|
||||
{
|
||||
_deleteExceptions[endpoint] = exception;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers the blob response returned when a blob endpoint is called.
|
||||
/// </summary>
|
||||
@@ -185,6 +196,7 @@ public class StubApiHttpClient : IApiHttpClient
|
||||
_postResponseFactories.Clear();
|
||||
_putResponseFactories.Clear();
|
||||
_deleteSuccessEndpoints.Clear();
|
||||
_deleteExceptions.Clear();
|
||||
_blobResponse = null;
|
||||
GetEndpointsCalled.Clear();
|
||||
PostRequests.Clear();
|
||||
@@ -245,6 +257,8 @@ public class StubApiHttpClient : IApiHttpClient
|
||||
public Task DeleteAsync(string endpoint, CancellationToken cancellationToken = default)
|
||||
{
|
||||
DeleteEndpointsCalled.Add(endpoint);
|
||||
if (_deleteExceptions.TryGetValue(endpoint, out ApiException? exception))
|
||||
throw exception;
|
||||
if (_deleteSuccessEndpoints.Contains(endpoint))
|
||||
return Task.CompletedTask;
|
||||
throw new ApiException(null, System.Net.HttpStatusCode.InternalServerError, endpoint);
|
||||
|
||||
+17
-2
@@ -15,7 +15,7 @@ namespace Lumina.Presentation.Web.Fixtures.Common.Api;
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class TestApiHttpMessageHandler : HttpMessageHandler
|
||||
{
|
||||
private readonly Func<HttpRequestMessage, HttpResponseMessage> _responseFactory;
|
||||
private readonly Func<HttpRequestMessage, CancellationToken, Task<HttpResponseMessage>> _responseFactory;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of requests that were sent through this handler.
|
||||
@@ -27,11 +27,25 @@ public class TestApiHttpMessageHandler : HttpMessageHandler
|
||||
/// </summary>
|
||||
public List<string?> RequestBodies { get; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the cancellation tokens the requests were sent with.
|
||||
/// </summary>
|
||||
public List<CancellationToken> CancellationTokens { get; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TestApiHttpMessageHandler"/> class.
|
||||
/// </summary>
|
||||
/// <param name="responseFactory">The factory that produces the response for a given request.</param>
|
||||
public TestApiHttpMessageHandler(Func<HttpRequestMessage, HttpResponseMessage> responseFactory)
|
||||
{
|
||||
_responseFactory = (request, cancellationToken) => Task.FromResult(responseFactory(request));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TestApiHttpMessageHandler"/> class.
|
||||
/// </summary>
|
||||
/// <param name="responseFactory">The asynchronous factory that produces the response for a given request and cancellation token.</param>
|
||||
public TestApiHttpMessageHandler(Func<HttpRequestMessage, CancellationToken, Task<HttpResponseMessage>> responseFactory)
|
||||
{
|
||||
_responseFactory = responseFactory;
|
||||
}
|
||||
@@ -45,7 +59,8 @@ public class TestApiHttpMessageHandler : HttpMessageHandler
|
||||
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
|
||||
{
|
||||
Requests.Add(request);
|
||||
CancellationTokens.Add(cancellationToken);
|
||||
RequestBodies.Add(request.Content is null ? null : await request.Content.ReadAsStringAsync(cancellationToken));
|
||||
return await Task.FromResult(_responseFactory(request));
|
||||
return await _responseFactory(request, cancellationToken);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Api;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="HttpContent"/> test double that exposes whether the client buffered the content before handing it to the caller,
|
||||
/// whether the content was disposed, and whether obtaining its stream is allowed to fail.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public sealed class TrackingStreamContent : HttpContent
|
||||
{
|
||||
private readonly byte[] _contentBytes;
|
||||
private readonly MemoryStream _contentStream;
|
||||
private readonly bool _shouldFailStreamCreation;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the content was buffered by the client before it was handed to the caller.
|
||||
/// </summary>
|
||||
public bool WasBufferedByClient { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the content was disposed.
|
||||
/// </summary>
|
||||
public bool IsDisposed { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the stream the content hands over when it is read without being buffered first.
|
||||
/// </summary>
|
||||
public Stream ContentStream => _contentStream;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TrackingStreamContent"/> class.
|
||||
/// </summary>
|
||||
/// <param name="contentBytes">The bytes of the content.</param>
|
||||
/// <param name="mediaType">The media type the content declares.</param>
|
||||
/// <param name="shouldFailStreamCreation">Whether obtaining the content stream should fail.</param>
|
||||
public TrackingStreamContent(byte[] contentBytes, string mediaType = "application/octet-stream", bool shouldFailStreamCreation = false)
|
||||
{
|
||||
_contentBytes = contentBytes;
|
||||
_contentStream = new MemoryStream(contentBytes);
|
||||
_shouldFailStreamCreation = shouldFailStreamCreation;
|
||||
Headers.ContentType = new MediaTypeHeaderValue(mediaType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the content to the provided stream, recording that the client buffered it.
|
||||
/// </summary>
|
||||
/// <param name="stream">The stream the content is written to.</param>
|
||||
/// <param name="context">The transport context of the serialization, if any.</param>
|
||||
/// <returns>A task that represents the asynchronous serialization.</returns>
|
||||
protected override Task SerializeToStreamAsync(Stream stream, TransportContext? context)
|
||||
{
|
||||
WasBufferedByClient = true;
|
||||
return stream.WriteAsync(_contentBytes, 0, _contentBytes.Length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hands over the known content stream without buffering the content first.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>The content stream.</returns>
|
||||
/// <exception cref="InvalidOperationException">Thrown when the content is configured to fail obtaining its stream.</exception>
|
||||
protected override Task<Stream> CreateContentReadStreamAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
if (_shouldFailStreamCreation)
|
||||
throw new InvalidOperationException("The content stream cannot be obtained.");
|
||||
return Task.FromResult<Stream>(_contentStream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Computes the length of the content.
|
||||
/// </summary>
|
||||
/// <param name="length">The length of the content in bytes.</param>
|
||||
/// <returns>Always <see langword="true"/>.</returns>
|
||||
protected override bool TryComputeLength(out long length)
|
||||
{
|
||||
length = _contentBytes.Length;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disposes the content, recording that it was disposed.
|
||||
/// </summary>
|
||||
/// <param name="disposing">Whether the content is being disposed.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
IsDisposed = true;
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Playlists;
|
||||
using Lumina.Presentation.Web.Common.Enums.Playlists;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistDetailsDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistDetailsDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="PlaylistDetailsDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional Id of the playlist.</param>
|
||||
/// <param name="name">Optional name of the playlist.</param>
|
||||
/// <param name="description">Optional description of the playlist.</param>
|
||||
/// <param name="type">Optional kind of media the playlist holds.</param>
|
||||
/// <param name="updatedOnUtc">Optional 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 last update date should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="PlaylistDetailsDto"/> instance.</returns>
|
||||
public PlaylistDetailsDto Create(
|
||||
Guid? id = null,
|
||||
string? name = null,
|
||||
string? description = null,
|
||||
PlaylistType? type = null,
|
||||
DateTime? updatedOnUtc = null,
|
||||
bool includeDescription = true,
|
||||
bool includeUpdatedOnUtc = true)
|
||||
{
|
||||
DateTime resolvedUpdatedOnUtc = DateTime.SpecifyKind(updatedOnUtc ?? DateTime.UtcNow.AddHours(-_faker.Random.Int(1, 24)), DateTimeKind.Utc);
|
||||
return new PlaylistDetailsDto(
|
||||
Id: id ?? _faker.Random.Guid(),
|
||||
Name: name ?? _faker.Lorem.Sentence(3),
|
||||
Description: includeDescription ? (description ?? _faker.Lorem.Sentence(5)) : null,
|
||||
Type: type ?? PlaylistType.Music,
|
||||
UpdatedOnUtc: includeUpdatedOnUtc ? resolvedUpdatedOnUtc : null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="PlaylistDetailsDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PlaylistDetailsDto"/> instances.</returns>
|
||||
public List<PlaylistDetailsDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Playlists;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistEntriesAddedDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistEntriesAddedDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="PlaylistEntriesAddedDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="playlistId">Optional Id of the playlist the entries were added to.</param>
|
||||
/// <param name="addedCount">Optional number of entries that were appended.</param>
|
||||
/// <param name="updatedOnUtc">Optional date and time when the playlist was last updated.</param>
|
||||
/// <param name="includeUpdatedOnUtc">Whether the last update date should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="PlaylistEntriesAddedDto"/> instance.</returns>
|
||||
public PlaylistEntriesAddedDto Create(
|
||||
Guid? playlistId = null,
|
||||
int? addedCount = null,
|
||||
DateTime? updatedOnUtc = null,
|
||||
bool includeUpdatedOnUtc = true)
|
||||
{
|
||||
DateTime resolvedUpdatedOnUtc = DateTime.SpecifyKind(updatedOnUtc ?? DateTime.UtcNow.AddHours(-_faker.Random.Int(1, 24)), DateTimeKind.Utc);
|
||||
return new PlaylistEntriesAddedDto(
|
||||
PlaylistId: playlistId ?? _faker.Random.Guid(),
|
||||
AddedCount: addedCount ?? _faker.Random.Int(0, 1_000),
|
||||
UpdatedOnUtc: includeUpdatedOnUtc ? resolvedUpdatedOnUtc : null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="PlaylistEntriesAddedDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PlaylistEntriesAddedDto"/> instances.</returns>
|
||||
public List<PlaylistEntriesAddedDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Playlists;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistEntryAddedDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistEntryAddedDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly PlaylistEntryDtoFixture _playlistEntryDtoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="PlaylistEntryAddedDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="playlistId">Optional Id of the playlist the entry was added to.</param>
|
||||
/// <param name="entry">Optional added entry.</param>
|
||||
/// <param name="updatedOnUtc">Optional date and time when the playlist was last updated.</param>
|
||||
/// <param name="includeUpdatedOnUtc">Whether the last update date should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="PlaylistEntryAddedDto"/> instance.</returns>
|
||||
public PlaylistEntryAddedDto Create(
|
||||
Guid? playlistId = null,
|
||||
PlaylistEntryDto? entry = null,
|
||||
DateTime? updatedOnUtc = null,
|
||||
bool includeUpdatedOnUtc = true)
|
||||
{
|
||||
DateTime resolvedUpdatedOnUtc = DateTime.SpecifyKind(updatedOnUtc ?? DateTime.UtcNow.AddHours(-_faker.Random.Int(1, 24)), DateTimeKind.Utc);
|
||||
return new PlaylistEntryAddedDto(
|
||||
PlaylistId: playlistId ?? _faker.Random.Guid(),
|
||||
Entry: entry ?? _playlistEntryDtoFixture.Create(),
|
||||
UpdatedOnUtc: includeUpdatedOnUtc ? resolvedUpdatedOnUtc : null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="PlaylistEntryAddedDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PlaylistEntryAddedDto"/> instances.</returns>
|
||||
public List<PlaylistEntryAddedDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Playlists;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistEntryMovedDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistEntryMovedDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="PlaylistEntryMovedDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="playlistId">Optional Id of the playlist whose entry was moved.</param>
|
||||
/// <param name="entryId">Optional Id of the moved entry.</param>
|
||||
/// <param name="position">Optional new zero based position of the entry.</param>
|
||||
/// <param name="updatedOnUtc">Optional date and time when the playlist was last updated.</param>
|
||||
/// <param name="includeUpdatedOnUtc">Whether the last update date should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="PlaylistEntryMovedDto"/> instance.</returns>
|
||||
public PlaylistEntryMovedDto Create(
|
||||
Guid? playlistId = null,
|
||||
Guid? entryId = null,
|
||||
int? position = null,
|
||||
DateTime? updatedOnUtc = null,
|
||||
bool includeUpdatedOnUtc = true)
|
||||
{
|
||||
DateTime resolvedUpdatedOnUtc = DateTime.SpecifyKind(updatedOnUtc ?? DateTime.UtcNow.AddHours(-_faker.Random.Int(1, 24)), DateTimeKind.Utc);
|
||||
return new PlaylistEntryMovedDto(
|
||||
PlaylistId: playlistId ?? _faker.Random.Guid(),
|
||||
EntryId: entryId ?? _faker.Random.Guid(),
|
||||
Position: position ?? _faker.Random.Int(0, 1_000),
|
||||
UpdatedOnUtc: includeUpdatedOnUtc ? resolvedUpdatedOnUtc : null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="PlaylistEntryMovedDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="PlaylistEntryMovedDto"/> instances.</returns>
|
||||
public List<PlaylistEntryMovedDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.Playlists;
|
||||
using Lumina.Presentation.Web.Common.Enums.Playlists;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaylistSummaryDto"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaylistSummaryDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="PlaylistSummaryDto"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional Id of the playlist.</param>
|
||||
/// <param name="name">Optional name of the playlist.</param>
|
||||
/// <param name="description">Optional description of the playlist.</param>
|
||||
/// <param name="type">Optional kind of media the playlist holds.</param>
|
||||
/// <param name="entryCount">Optional number of entries of the playlist.</param>
|
||||
/// <param name="createdOnUtc">Optional date and time when the playlist was created.</param>
|
||||
/// <param name="updatedOnUtc">Optional 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 last update date should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="PlaylistSummaryDto"/> instance.</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 = true)
|
||||
{
|
||||
DateTime resolvedCreatedOnUtc = DateTime.SpecifyKind(createdOnUtc ?? DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)), DateTimeKind.Utc);
|
||||
DateTime resolvedUpdatedOnUtc = DateTime.SpecifyKind(updatedOnUtc ?? resolvedCreatedOnUtc.AddHours(_faker.Random.Int(1, 24)), DateTimeKind.Utc);
|
||||
return new PlaylistSummaryDto(
|
||||
Id: id ?? _faker.Random.Guid(),
|
||||
Name: name ?? _faker.Lorem.Sentence(3),
|
||||
Description: includeDescription ? (description ?? _faker.Lorem.Sentence(5)) : null,
|
||||
Type: type ?? PlaylistType.Music,
|
||||
EntryCount: entryCount ?? _faker.Random.Int(0, 1_000),
|
||||
CreatedOnUtc: resolvedCreatedOnUtc,
|
||||
UpdatedOnUtc: includeUpdatedOnUtc ? resolvedUpdatedOnUtc : null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <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())];
|
||||
}
|
||||
}
|
||||
+4
-2
@@ -22,14 +22,16 @@ public class ThemeTemplateResponseDtoFixture
|
||||
/// </summary>
|
||||
/// <param name="theme">Optional theme the template belongs to.</param>
|
||||
/// <param name="template">Optional sanitized template content.</param>
|
||||
/// <param name="includeTemplate">Whether the template content should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="ThemeTemplateResponseDto"/> instance.</returns>
|
||||
public ThemeTemplateResponseDto Create(
|
||||
ThemeResponseDto? theme = null,
|
||||
string? template = null)
|
||||
string? template = null,
|
||||
bool includeTemplate = true)
|
||||
{
|
||||
return new ThemeTemplateResponseDto(
|
||||
Theme: theme ?? _themeResponseDtoFixture.Create(),
|
||||
Template: template ?? _faker.Lorem.Paragraph()
|
||||
Template: includeTemplate ? (template ?? _faker.Lorem.Paragraph()) : null!
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.DTO.UsersManagement;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.DTO.UsersManagement;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PlaybackStateDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PlaybackStateDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PlaybackStateDto"/>.
|
||||
/// </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="PlaybackStateDto"/>.</returns>
|
||||
public PlaybackStateDto Create(
|
||||
double? volume = null,
|
||||
bool? isMuted = null,
|
||||
bool includeVolume = true,
|
||||
bool includeIsMuted = true)
|
||||
{
|
||||
return new PlaybackStateDto
|
||||
{
|
||||
Volume = includeVolume ? volume ?? _faker.Random.Double(0, 1) : null,
|
||||
IsMuted = includeIsMuted ? isMuted ?? _faker.Random.Bool() : null
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="PlaybackStateDto"/> instances.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<PlaybackStateDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.Requests.Playlists;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="AddPlaylistEntriesRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AddPlaylistEntriesRequestFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="AddPlaylistEntriesRequest"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="trackIds">Optional Ids of the tracks to add, in order.</param>
|
||||
/// <param name="trackCount">Optional number of random track Ids to generate when <paramref name="trackIds"/> is not supplied.</param>
|
||||
/// <param name="includeTrackIds">Whether the track Ids should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="AddPlaylistEntriesRequest"/> instance.</returns>
|
||||
public AddPlaylistEntriesRequest Create(
|
||||
List<Guid>? trackIds = null,
|
||||
int trackCount = 3,
|
||||
bool includeTrackIds = true)
|
||||
{
|
||||
return new AddPlaylistEntriesRequest(
|
||||
TrackIds: includeTrackIds ? (trackIds ?? CreateRandomTrackIds(trackCount)) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="AddPlaylistEntriesRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="AddPlaylistEntriesRequest"/> instances.</returns>
|
||||
public List<AddPlaylistEntriesRequest> 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())];
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.Requests.Playlists;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="AddPlaylistEntryRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AddPlaylistEntryRequestFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="AddPlaylistEntryRequest"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="trackId">Optional Id of the track to add.</param>
|
||||
/// <param name="includeTrackId">Whether the track Id should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="AddPlaylistEntryRequest"/> instance.</returns>
|
||||
public AddPlaylistEntryRequest Create(
|
||||
Guid? trackId = null,
|
||||
bool includeTrackId = true)
|
||||
{
|
||||
return new AddPlaylistEntryRequest(
|
||||
TrackId: includeTrackId ? (trackId ?? Guid.NewGuid()) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="AddPlaylistEntryRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="AddPlaylistEntryRequest"/> instances.</returns>
|
||||
public List<AddPlaylistEntryRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.Requests.Playlists;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="AddPlaylistScopeEntriesRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AddPlaylistScopeEntriesRequestFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="AddPlaylistScopeEntriesRequest"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">Optional Id of the music library the scope belongs to.</param>
|
||||
/// <param name="artistId">Optional Id of the artist the scope is limited to.</param>
|
||||
/// <param name="albumId">Optional Id of the album the scope is limited to.</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>A configured <see cref="AddPlaylistScopeEntriesRequest"/> instance.</returns>
|
||||
public AddPlaylistScopeEntriesRequest Create(
|
||||
Guid? libraryId = null,
|
||||
Guid? artistId = null,
|
||||
Guid? albumId = null,
|
||||
bool includeArtistId = true,
|
||||
bool includeAlbumId = true)
|
||||
{
|
||||
return new AddPlaylistScopeEntriesRequest(
|
||||
LibraryId: libraryId ?? Guid.NewGuid(),
|
||||
ArtistId: includeArtistId ? (artistId ?? Guid.NewGuid()) : null,
|
||||
AlbumId: includeAlbumId ? (albumId ?? Guid.NewGuid()) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="AddPlaylistScopeEntriesRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="AddPlaylistScopeEntriesRequest"/> instances.</returns>
|
||||
public List<AddPlaylistScopeEntriesRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.Enums.Playlists;
|
||||
using Lumina.Presentation.Web.Common.Requests.Playlists;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="CreatePlaylistRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class CreatePlaylistRequestFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="CreatePlaylistRequest"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="name">Optional name of the playlist.</param>
|
||||
/// <param name="description">Optional description of the playlist.</param>
|
||||
/// <param name="type">Optional kind of media the playlist holds.</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>
|
||||
/// <param name="includeType">Whether the media type should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="CreatePlaylistRequest"/> instance.</returns>
|
||||
public CreatePlaylistRequest Create(
|
||||
string? name = null,
|
||||
string? description = null,
|
||||
PlaylistType? type = null,
|
||||
bool includeName = true,
|
||||
bool includeDescription = true,
|
||||
bool includeType = true)
|
||||
{
|
||||
return new CreatePlaylistRequest(
|
||||
Name: includeName ? (name ?? _faker.Lorem.Sentence(3)) : null,
|
||||
Description: includeDescription ? (description ?? _faker.Lorem.Sentence(5)) : null,
|
||||
Type: includeType ? (type ?? PlaylistType.Music) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="CreatePlaylistRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="CreatePlaylistRequest"/> instances.</returns>
|
||||
public List<CreatePlaylistRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.Requests.Playlists;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MovePlaylistEntryRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MovePlaylistEntryRequestFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="MovePlaylistEntryRequest"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="targetPosition">Optional new zero based position of the entry.</param>
|
||||
/// <param name="includeTargetPosition">Whether the target position should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>A configured <see cref="MovePlaylistEntryRequest"/> instance.</returns>
|
||||
public MovePlaylistEntryRequest Create(
|
||||
int? targetPosition = null,
|
||||
bool includeTargetPosition = true)
|
||||
{
|
||||
return new MovePlaylistEntryRequest(
|
||||
TargetPosition: includeTargetPosition ? (targetPosition ?? _faker.Random.Int(0, 1_000)) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="MovePlaylistEntryRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MovePlaylistEntryRequest"/> instances.</returns>
|
||||
public List<MovePlaylistEntryRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.Requests.Playlists;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Playlists;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="UpdatePlaylistRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UpdatePlaylistRequestFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="UpdatePlaylistRequest"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="name">Optional name of the playlist.</param>
|
||||
/// <param name="description">Optional description of the playlist.</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>A configured <see cref="UpdatePlaylistRequest"/> instance.</returns>
|
||||
public UpdatePlaylistRequest Create(
|
||||
string? name = null,
|
||||
string? description = null,
|
||||
bool includeName = true,
|
||||
bool includeDescription = true)
|
||||
{
|
||||
return new UpdatePlaylistRequest(
|
||||
Name: includeName ? (name ?? _faker.Lorem.Sentence(3)) : null,
|
||||
Description: includeDescription ? (description ?? _faker.Lorem.Sentence(5)) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="UpdatePlaylistRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="UpdatePlaylistRequest"/> instances.</returns>
|
||||
public List<UpdatePlaylistRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user