mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 16: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
+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())];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user