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
+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