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

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

No files matched your search

@@ -0,0 +1,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())];
}
}
@@ -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())];
}
}
@@ -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())];
}
}
@@ -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())];
}
}
@@ -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())];
}
}
@@ -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())];
}
}
@@ -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())];
}
}