mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 18:13:42 +00:00
Implements tests for commit 067e9a21d0
This commit is contained in:
1 parent
aeefa9487e
commit
a75447062f
18 files changed
+3156
No files matched your search
+61
@@ -0,0 +1,61 @@
|
||||
#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.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DTO.MediaLibrary.AudioLibrary.MusicLibrary.Tracks;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ShuffleTrackRowDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ShuffleTrackRowFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ShuffleTrackRowDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="trackId">Optional. The Id of the track.</param>
|
||||
/// <param name="title">Optional. The title of the track.</param>
|
||||
/// <param name="durationInSeconds">Optional. The duration of the track in seconds.</param>
|
||||
/// <param name="albumId">Optional. The Id of the album the track belongs to.</param>
|
||||
/// <param name="albumTitle">Optional. The title of the album the track belongs to.</param>
|
||||
/// <param name="artistId">Optional. The Id of the artist the album belongs to.</param>
|
||||
/// <param name="coverPath">Optional. The path of the cover of the album.</param>
|
||||
/// <param name="includeCoverPath">Whether the cover path should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="ShuffleTrackRowDto"/>.</returns>
|
||||
public ShuffleTrackRowDto Create(
|
||||
Guid? trackId = null,
|
||||
string? title = null,
|
||||
int? durationInSeconds = null,
|
||||
Guid? albumId = null,
|
||||
string? albumTitle = null,
|
||||
Guid? artistId = null,
|
||||
string? coverPath = null,
|
||||
bool includeCoverPath = true)
|
||||
{
|
||||
return new ShuffleTrackRowDto(
|
||||
trackId ?? _faker.Random.Guid(),
|
||||
title ?? _faker.Lorem.Sentence(),
|
||||
durationInSeconds ?? _faker.Random.Int(1, 7200),
|
||||
albumId ?? _faker.Random.Guid(),
|
||||
albumTitle ?? _faker.Lorem.Sentence(),
|
||||
artistId ?? _faker.Random.Guid(),
|
||||
includeCoverPath ? (coverPath ?? _faker.System.FileName("jpg")) : null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ShuffleTrackRowDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ShuffleTrackRowDto"/> instances.</returns>
|
||||
public List<ShuffleTrackRowDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks.Queries.ShuffleTracks;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks.Queries.ShuffleTracks;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ShuffleTracksQuery"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ShuffleTracksQueryFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ShuffleTracksQuery"/>.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">Optional. The Id of the media library the tracks are sampled from, taken from the route.</param>
|
||||
/// <param name="count">Optional. The maximum number of tracks to return.</param>
|
||||
/// <param name="artistId">Optional. The Id of the artist whose tracks are sampled.</param>
|
||||
/// <param name="albumId">Optional. The Id of the album whose tracks are sampled.</param>
|
||||
/// <param name="excludedTrackIds">Optional. The tracks that must not be returned.</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="includeExcludedTrackIds">Whether the excluded track Ids should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="ShuffleTracksQuery"/>.</returns>
|
||||
public ShuffleTracksQuery Create(
|
||||
string? libraryId = null,
|
||||
int? count = null,
|
||||
Guid? artistId = null,
|
||||
Guid? albumId = null,
|
||||
IReadOnlyList<Guid>? excludedTrackIds = null,
|
||||
bool includeLibraryId = true,
|
||||
bool includeArtistId = true,
|
||||
bool includeAlbumId = true,
|
||||
bool includeExcludedTrackIds = true)
|
||||
{
|
||||
return new ShuffleTracksQuery(
|
||||
includeLibraryId ? (libraryId ?? Guid.NewGuid().ToString()) : null,
|
||||
count ?? Random.Shared.Next(1, 501),
|
||||
includeArtistId ? (artistId ?? Guid.NewGuid()) : null,
|
||||
includeAlbumId ? (albumId ?? Guid.NewGuid()) : null,
|
||||
includeExcludedTrackIds
|
||||
? (excludedTrackIds ?? [.. Enumerable.Range(0, Random.Shared.Next(0, 3)).Select(_ => Guid.NewGuid())])
|
||||
: null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ShuffleTracksQuery"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ShuffleTracksQuery"/> instances.</returns>
|
||||
public List<ShuffleTracksQuery> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user