Adds cover update endpoints for music artists and albums.

This commit is contained in:
BinaryAlley committed 2026-10-13 13:26:41 +03:00
1 parent 4f43bf352b
commit 4ceb8f7360
32 files changed
+4892

No files matched your search

@@ -0,0 +1,72 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Commands.UpdateAlbumCover;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Text;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Albums.Commands.UpdateAlbumCover;
/// <summary>
/// Fixture class for the <see cref="UpdateAlbumCoverCommand"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class UpdateAlbumCoverCommandFixture
{
/// <summary>
/// Creates a random valid <see cref="UpdateAlbumCoverCommand"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library the album belongs to.</param>
/// <param name="artistId">Optional. The Id of the artist the album belongs to.</param>
/// <param name="albumId">Optional. The Id of the album whose cover is updated.</param>
/// <param name="cover">Optional. The stream of the uploaded cover image file.</param>
/// <param name="fileName">Optional. The name of the uploaded cover image file.</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="includeCover">Whether the cover stream should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeFileName">Whether the file name should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="UpdateAlbumCoverCommand"/>.</returns>
public UpdateAlbumCoverCommand Create(
string? libraryId = null,
string? artistId = null,
string? albumId = null,
Stream? cover = null,
string? fileName = null,
bool includeLibraryId = true,
bool includeArtistId = true,
bool includeAlbumId = true,
bool includeCover = true,
bool includeFileName = true)
{
return new UpdateAlbumCoverCommand(
includeLibraryId ? (libraryId ?? Guid.NewGuid().ToString()) : null,
includeArtistId ? (artistId ?? Guid.NewGuid().ToString()) : null,
includeAlbumId ? (albumId ?? Guid.NewGuid().ToString()) : null,
includeCover ? (cover ?? CreateCoverStream()) : null,
includeFileName ? (fileName ?? "cover.jpg") : null);
}
/// <summary>
/// Creates a list of <see cref="UpdateAlbumCoverCommand"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="UpdateAlbumCoverCommand"/> instances.</returns>
public List<UpdateAlbumCoverCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
/// <summary>
/// Creates an in-memory stream carrying a minimal file payload.
/// </summary>
/// <returns>A non-empty in-memory stream.</returns>
private static Stream CreateCoverStream()
{
byte[] payload = Encoding.UTF8.GetBytes("fake cover payload");
return new MemoryStream(payload);
}
}
@@ -0,0 +1,67 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists.Commands.UpdateArtistCover;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Text;
#endregion
namespace Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Artists.Commands.UpdateArtistCover;
/// <summary>
/// Fixture class for the <see cref="UpdateArtistCoverCommand"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class UpdateArtistCoverCommandFixture
{
/// <summary>
/// Creates a random valid <see cref="UpdateArtistCoverCommand"/>.
/// </summary>
/// <param name="libraryId">Optional. The Id of the media library the artist belongs to.</param>
/// <param name="artistId">Optional. The Id of the artist whose cover is updated.</param>
/// <param name="cover">Optional. The stream of the uploaded cover image file.</param>
/// <param name="fileName">Optional. The name of the uploaded cover image file.</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="includeCover">Whether the cover stream should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeFileName">Whether the file name should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="UpdateArtistCoverCommand"/>.</returns>
public UpdateArtistCoverCommand Create(
string? libraryId = null,
string? artistId = null,
Stream? cover = null,
string? fileName = null,
bool includeLibraryId = true,
bool includeArtistId = true,
bool includeCover = true,
bool includeFileName = true)
{
return new UpdateArtistCoverCommand(
includeLibraryId ? (libraryId ?? Guid.NewGuid().ToString()) : null,
includeArtistId ? (artistId ?? Guid.NewGuid().ToString()) : null,
includeCover ? (cover ?? CreateCoverStream()) : null,
includeFileName ? (fileName ?? "cover.jpg") : null);
}
/// <summary>
/// Creates a list of <see cref="UpdateArtistCoverCommand"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="UpdateArtistCoverCommand"/> instances.</returns>
public List<UpdateArtistCoverCommand> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
/// <summary>
/// Creates an in-memory stream carrying a minimal file payload.
/// </summary>
/// <returns>A non-empty in-memory stream.</returns>
private static Stream CreateCoverStream()
{
byte[] payload = Encoding.UTF8.GetBytes("fake cover payload");
return new MemoryStream(payload);
}
}
@@ -0,0 +1,40 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Albums;
/// <summary>
/// Fixture class for the <see cref="UpdateAlbumCoverResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class UpdateAlbumCoverResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="UpdateAlbumCoverResponse"/>.
/// </summary>
/// <param name="coverPath">Optional. The relative path of the stored cover image.</param>
/// <returns>The created <see cref="UpdateAlbumCoverResponse"/>.</returns>
public UpdateAlbumCoverResponse Create(string? coverPath = null)
{
return new UpdateAlbumCoverResponse(
coverPath ?? _faker.System.FilePath()
);
}
/// <summary>
/// Creates a list of <see cref="UpdateAlbumCoverResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<UpdateAlbumCoverResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,40 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Artists;
/// <summary>
/// Fixture class for the <see cref="UpdateArtistCoverResponse"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class UpdateArtistCoverResponseFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="UpdateArtistCoverResponse"/>.
/// </summary>
/// <param name="coverPath">Optional. The relative path of the stored cover image.</param>
/// <returns>The created <see cref="UpdateArtistCoverResponse"/>.</returns>
public UpdateArtistCoverResponse Create(string? coverPath = null)
{
return new UpdateArtistCoverResponse(
coverPath ?? _faker.System.FilePath()
);
}
/// <summary>
/// Creates a list of <see cref="UpdateArtistCoverResponse"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<UpdateArtistCoverResponse> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}