mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 19:21:10 +00:00
Adds the music library track test suite
This commit is contained in:
1 parent
dc2692e208
commit
12d310631b
89 files changed
+18849
-9
No files matched your search
@@ -0,0 +1,45 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Common.ValueObjects.Metadata;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="Mood"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MoodFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="Mood"/>.
|
||||
/// </summary>
|
||||
/// <param name="name">Optional. The name of the mood. If not provided, a random name is generated.</param>
|
||||
/// <returns>The created <see cref="Mood"/>.</returns>
|
||||
public Mood Create(
|
||||
string? name = null)
|
||||
{
|
||||
Result<Mood> moodResult = Mood.Create(name ?? _faker.Lorem.Word());
|
||||
|
||||
if (moodResult.IsFailure)
|
||||
throw new InvalidOperationException("Failed to create Mood: " + string.Join(", ", moodResult.Errors));
|
||||
return moodResult.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="Mood"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="Mood"/> instances.</returns>
|
||||
public List<Mood> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.AudioLibraryBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryId"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryIdFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryId"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The raw value of the library Id.</param>
|
||||
/// <returns>The created <see cref="LibraryId"/>.</returns>
|
||||
public LibraryId Create(
|
||||
Guid? value = null)
|
||||
{
|
||||
return value is null ? LibraryId.CreateUnique() : LibraryId.Create(value.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="LibraryId"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="LibraryId"/> instances.</returns>
|
||||
public List<LibraryId> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.ExternalIdentifiers.MediaContributorBoundedContext.MediaContributorAggregate;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.AudioLibraryBoundedContext.ExternalIdentifiers.MediaContributorBoundedContext.MediaContributorAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MediaContributorId"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaContributorIdFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MediaContributorId"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The raw value of the media contributor Id.</param>
|
||||
/// <returns>The created <see cref="MediaContributorId"/>.</returns>
|
||||
public MediaContributorId Create(
|
||||
Guid? value = null)
|
||||
{
|
||||
return value is null ? MediaContributorId.CreateUnique() : MediaContributorId.Create(value.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="MediaContributorId"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MediaContributorId"/> instances.</returns>
|
||||
public List<MediaContributorId> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.Entities;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.AudioLibraryBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.Entities;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="Artist"/> domain aggregate root.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ArtistFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly LibraryIdFixture _libraryIdFixture = new();
|
||||
private readonly AlbumFixture _albumFixture = new();
|
||||
private readonly MusicBrainzIdFixture _musicBrainzIdFixture = new();
|
||||
private readonly MusicMediaContributorFixture _musicMediaContributorFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="Artist"/> domain aggregate root.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">Optional. The Id of the media library this artist belongs to.</param>
|
||||
/// <param name="name">Optional. The name of the artist.</param>
|
||||
/// <param name="website">Optional. The website of the artist.</param>
|
||||
/// <param name="musicBrainzArtistId">Optional. The MusicBrainz identifier of the artist.</param>
|
||||
/// <param name="contributors">Optional. The media contributors that make up the artist.</param>
|
||||
/// <param name="albums">Optional. The albums of the artist. Defaults to a single random album, since an artist must have at least one.</param>
|
||||
/// <returns>The created <see cref="Artist"/> domain aggregate root.</returns>
|
||||
public Artist Create(
|
||||
LibraryId? libraryId = null,
|
||||
string? name = null,
|
||||
Optional<string>? website = null,
|
||||
Optional<MusicBrainzId>? musicBrainzArtistId = null,
|
||||
List<MusicMediaContributor>? contributors = null,
|
||||
List<Album>? albums = null)
|
||||
{
|
||||
Result<Artist> artistResult = Artist.Create(
|
||||
libraryId ?? _libraryIdFixture.Create(),
|
||||
name ?? _faker.Name.FullName(),
|
||||
website ?? Optional<string>.Some(_faker.Internet.Url()),
|
||||
musicBrainzArtistId ?? Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create()),
|
||||
contributors ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 3)).Select(_ => _musicMediaContributorFixture.Create())],
|
||||
albums ?? [_albumFixture.Create()]);
|
||||
|
||||
if (artistResult.IsFailure)
|
||||
throw new InvalidOperationException("Failed to create Artist: " + string.Join(", ", artistResult.Errors));
|
||||
return artistResult.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="Artist"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="Artist"/> instances.</returns>
|
||||
public List<Artist> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.Common.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.Entities;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.AudioLibraryBoundedContext.Common.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="Album"/> domain entity.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AlbumFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly AlbumMetadataFixture _albumMetadataFixture = new();
|
||||
private readonly BarcodeFixture _barcodeFixture = new();
|
||||
private readonly MusicBrainzIdFixture _musicBrainzIdFixture = new();
|
||||
private readonly MusicMediaContributorFixture _musicMediaContributorFixture = new();
|
||||
private readonly AudioRatingFixture _audioRatingFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="Album"/> domain entity.
|
||||
/// </summary>
|
||||
/// <param name="metadata">Optional. The album metadata of the album.</param>
|
||||
/// <param name="mediaFormat">Optional. The physical or digital medium of the album.</param>
|
||||
/// <param name="barcode">Optional. The barcode of the album.</param>
|
||||
/// <param name="catalogNumber">Optional. The catalog number of the album.</param>
|
||||
/// <param name="musicBrainzReleaseId">Optional. The MusicBrainz identifier of the release.</param>
|
||||
/// <param name="musicBrainzReleaseGroupId">Optional. The MusicBrainz identifier of the release group.</param>
|
||||
/// <param name="musicBrainzReleaseArtistId">Optional. The MusicBrainz identifier of the release artist.</param>
|
||||
/// <param name="contributors">Optional. The media contributors of the album.</param>
|
||||
/// <param name="ratings">Optional. The ratings of the album.</param>
|
||||
/// <param name="tracks">Optional. The tracks of the album. Defaults to an empty list so callers can control the initial tracks.</param>
|
||||
/// <returns>The created <see cref="Album"/> domain entity.</returns>
|
||||
public Album Create(
|
||||
AlbumMetadata? metadata = null,
|
||||
Optional<MusicMediaFormat>? mediaFormat = null,
|
||||
Optional<Barcode>? barcode = null,
|
||||
Optional<string>? catalogNumber = null,
|
||||
Optional<MusicBrainzId>? musicBrainzReleaseId = null,
|
||||
Optional<MusicBrainzId>? musicBrainzReleaseGroupId = null,
|
||||
Optional<MusicBrainzId>? musicBrainzReleaseArtistId = null,
|
||||
List<MusicMediaContributor>? contributors = null,
|
||||
List<AudioRating>? ratings = null,
|
||||
List<Track>? tracks = null)
|
||||
{
|
||||
Result<Album> albumResult = Album.Create(
|
||||
metadata ?? _albumMetadataFixture.Create(),
|
||||
mediaFormat ?? Optional<MusicMediaFormat>.Some(_faker.PickRandom<MusicMediaFormat>()),
|
||||
barcode ?? Optional<Barcode>.Some(_barcodeFixture.Create()),
|
||||
catalogNumber ?? Optional<string>.Some(_faker.Random.String2(_faker.Random.Int(5, 20))),
|
||||
musicBrainzReleaseId ?? Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create()),
|
||||
musicBrainzReleaseGroupId ?? Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create()),
|
||||
musicBrainzReleaseArtistId ?? Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create()),
|
||||
contributors ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 3)).Select(_ => _musicMediaContributorFixture.Create())],
|
||||
ratings ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 2)).Select(_ => _audioRatingFixture.Create())],
|
||||
tracks ?? []);
|
||||
|
||||
if (albumResult.IsFailure)
|
||||
throw new InvalidOperationException("Failed to create Album: " + string.Join(", ", albumResult.Errors));
|
||||
return albumResult.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="Album"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="Album"/> instances.</returns>
|
||||
public List<Album> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.Common.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.Entities;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Common.ValueObjects.Metadata;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.AudioLibraryBoundedContext.Common.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="Track"/> domain entity.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class TrackFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly AudioMetadataFixture _audioMetadataFixture = new();
|
||||
private readonly MoodFixture _moodFixture = new();
|
||||
private readonly IsrcFixture _isrcFixture = new();
|
||||
private readonly MusicMediaContributorFixture _musicMediaContributorFixture = new();
|
||||
private readonly MusicBrainzIdFixture _musicBrainzIdFixture = new();
|
||||
private readonly AudioRatingFixture _audioRatingFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="Track"/> domain entity.
|
||||
/// </summary>
|
||||
/// <param name="path">Optional. The file system path of the track.</param>
|
||||
/// <param name="metadata">Optional. The audio metadata of the track.</param>
|
||||
/// <param name="trackNumber">Optional. The number of the track on its disc.</param>
|
||||
/// <param name="discNumber">Optional. The number of the disc the track belongs to.</param>
|
||||
/// <param name="moods">Optional. The moods of the track.</param>
|
||||
/// <param name="script">Optional. The script used by the language of the track.</param>
|
||||
/// <param name="key">Optional. The musical key of the track.</param>
|
||||
/// <param name="bpm">Optional. The tempo of the track in beats per minute.</param>
|
||||
/// <param name="isrcs">Optional. The ISRCs of the track.</param>
|
||||
/// <param name="work">Optional. The title of the work the track is a recording of.</param>
|
||||
/// <param name="musicBrainzRecordingId">Optional. The MusicBrainz identifier of the recording.</param>
|
||||
/// <param name="musicBrainzTrackId">Optional. The MusicBrainz identifier of the track.</param>
|
||||
/// <param name="musicBrainzWorkId">Optional. The MusicBrainz identifier of the work.</param>
|
||||
/// <param name="contributors">Optional. The media contributors of the track.</param>
|
||||
/// <param name="ratings">Optional. The ratings of the track.</param>
|
||||
/// <returns>The created <see cref="Track"/> domain entity.</returns>
|
||||
public Track Create(
|
||||
string? path = null,
|
||||
AudioMetadata? metadata = null,
|
||||
int? trackNumber = null,
|
||||
Optional<int>? discNumber = null,
|
||||
List<Mood>? moods = null,
|
||||
Optional<string>? script = null,
|
||||
Optional<MusicKey>? key = null,
|
||||
Optional<int>? bpm = null,
|
||||
List<Isrc>? isrcs = null,
|
||||
Optional<string>? work = null,
|
||||
Optional<MusicBrainzId>? musicBrainzRecordingId = null,
|
||||
Optional<MusicBrainzId>? musicBrainzTrackId = null,
|
||||
Optional<MusicBrainzId>? musicBrainzWorkId = null,
|
||||
List<MusicMediaContributor>? contributors = null,
|
||||
List<AudioRating>? ratings = null)
|
||||
{
|
||||
Result<Track> trackResult = Track.Create(
|
||||
path ?? _faker.System.FilePath(),
|
||||
metadata ?? _audioMetadataFixture.Create(),
|
||||
trackNumber ?? _faker.Random.Int(1, 30),
|
||||
discNumber ?? Optional<int>.Some(_faker.Random.Int(1, 2)),
|
||||
moods ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 3)).Select(_ => _moodFixture.Create())],
|
||||
script ?? Optional<string>.Some(_faker.Lorem.Word()),
|
||||
key ?? Optional<MusicKey>.Some(_faker.PickRandom<MusicKey>()),
|
||||
bpm ?? Optional<int>.Some(_faker.Random.Int(60, 220)),
|
||||
isrcs ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 2)).Select(_ => _isrcFixture.Create())],
|
||||
work ?? Optional<string>.Some(_faker.Lorem.Sentence()),
|
||||
musicBrainzRecordingId ?? Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create()),
|
||||
musicBrainzTrackId ?? Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create()),
|
||||
musicBrainzWorkId ?? Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create()),
|
||||
contributors ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 3)).Select(_ => _musicMediaContributorFixture.Create())],
|
||||
ratings ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 2)).Select(_ => _audioRatingFixture.Create())]);
|
||||
|
||||
if (trackResult.IsFailure)
|
||||
throw new InvalidOperationException("Failed to create Track: " + string.Join(", ", trackResult.Errors));
|
||||
return trackResult.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="Track"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="Track"/> instances.</returns>
|
||||
public List<Track> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="AlbumId"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AlbumIdFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="AlbumId"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The value used to create the <see cref="AlbumId"/>. If not provided, a random value is generated.</param>
|
||||
/// <returns>The created <see cref="AlbumId"/>.</returns>
|
||||
public AlbumId Create(Guid? value = null)
|
||||
{
|
||||
return value is null ? AlbumId.CreateUnique() : AlbumId.Create(value.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="AlbumId"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="AlbumId"/> instances.</returns>
|
||||
public List<AlbumId> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Common.ValueObjects.Metadata;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="AlbumMetadata"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AlbumMetadataFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly GenreFixture _genreFixture = new();
|
||||
private readonly TagFixture _tagFixture = new();
|
||||
private readonly ReleaseInfoFixture _releaseInfoFixture = new();
|
||||
private readonly LanguageInfoFixture _languageInfoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="AlbumMetadata"/>.
|
||||
/// </summary>
|
||||
/// <param name="title">Optional. The title of the album.</param>
|
||||
/// <param name="originalTitle">Optional. The original title of the album.</param>
|
||||
/// <param name="description">Optional. The description of the album.</param>
|
||||
/// <param name="releaseInfo">Optional. The release information of the album.</param>
|
||||
/// <param name="genres">Optional. The genres of the album.</param>
|
||||
/// <param name="tags">Optional. The tags associated with the album.</param>
|
||||
/// <param name="language">Optional. The language of the album.</param>
|
||||
/// <param name="originalLanguage">Optional. The original language of the album.</param>
|
||||
/// <param name="releaseType">Optional. The type of the release.</param>
|
||||
/// <param name="releaseStatus">Optional. The status of the release.</param>
|
||||
/// <param name="totalDiscs">Optional. The number of discs of the release.</param>
|
||||
/// <param name="totalTracks">Optional. The number of tracks of the release.</param>
|
||||
/// <returns>The created <see cref="AlbumMetadata"/>.</returns>
|
||||
public AlbumMetadata Create(
|
||||
string? title = null,
|
||||
Optional<string>? originalTitle = null,
|
||||
Optional<string>? description = null,
|
||||
ReleaseInfo? releaseInfo = null,
|
||||
List<Genre>? genres = null,
|
||||
List<Tag>? tags = null,
|
||||
Optional<LanguageInfo>? language = null,
|
||||
Optional<LanguageInfo>? originalLanguage = null,
|
||||
Optional<MusicReleaseType>? releaseType = null,
|
||||
Optional<MusicReleaseStatus>? releaseStatus = null,
|
||||
Optional<int>? totalDiscs = null,
|
||||
int? totalTracks = null)
|
||||
{
|
||||
Result<AlbumMetadata> metadataResult = AlbumMetadata.Create(
|
||||
title ?? _faker.Commerce.ProductName(),
|
||||
originalTitle ?? Optional<string>.None(),
|
||||
description ?? Optional<string>.Some(_faker.Lorem.Sentence()),
|
||||
releaseInfo ?? _releaseInfoFixture.Create(),
|
||||
genres ?? [_genreFixture.Create(), _genreFixture.Create()],
|
||||
tags ?? [_tagFixture.Create(), _tagFixture.Create()],
|
||||
language ?? Optional<LanguageInfo>.Some(_languageInfoFixture.Create()),
|
||||
originalLanguage ?? Optional<LanguageInfo>.None(),
|
||||
releaseType ?? Optional<MusicReleaseType>.Some(_faker.PickRandom<MusicReleaseType>()),
|
||||
releaseStatus ?? Optional<MusicReleaseStatus>.Some(_faker.PickRandom<MusicReleaseStatus>()),
|
||||
totalDiscs ?? Optional<int>.Some(_faker.Random.Int(1, 4)),
|
||||
totalTracks ?? _faker.Random.Int(1, 50));
|
||||
|
||||
if (metadataResult.IsFailure)
|
||||
throw new InvalidOperationException("Failed to create AlbumMetadata: " + string.Join(", ", metadataResult.Errors));
|
||||
return metadataResult.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="AlbumMetadata"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="AlbumMetadata"/> instances.</returns>
|
||||
public List<AlbumMetadata> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ArtistId"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ArtistIdFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ArtistId"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The value used to create the <see cref="ArtistId"/>. If not provided, a random value is generated.</param>
|
||||
/// <returns>The created <see cref="ArtistId"/>.</returns>
|
||||
public ArtistId Create(
|
||||
Guid? value = null)
|
||||
{
|
||||
return value is null ? ArtistId.CreateUnique() : ArtistId.Create(value.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="ArtistId"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ArtistId"/> instances.</returns>
|
||||
public List<ArtistId> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="Barcode"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class BarcodeFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="Barcode"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The value of the barcode. If not provided, a random valid barcode is generated.</param>
|
||||
/// <returns>The created <see cref="Barcode"/>.</returns>
|
||||
public Barcode Create(
|
||||
string? value = null)
|
||||
{
|
||||
Result<Barcode> barcodeResult = Barcode.Create(value ?? GenerateRandomValue());
|
||||
|
||||
if (barcodeResult.IsFailure)
|
||||
throw new InvalidOperationException("Failed to create Barcode: " + string.Join(", ", barcodeResult.Errors));
|
||||
return barcodeResult.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="Barcode"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="Barcode"/> instances.</returns>
|
||||
public List<Barcode> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates a random value matching the <c>^\d{12,13}$</c> barcode format.
|
||||
/// </summary>
|
||||
/// <returns>The generated barcode value.</returns>
|
||||
private string GenerateRandomValue()
|
||||
{
|
||||
int digitCount = _faker.Random.Int(12, 13);
|
||||
return _faker.Random.String2(digitCount, "0123456789");
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="Isrc"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class IsrcFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="Isrc"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The value of the ISRC. If not provided, a random valid ISRC is generated.</param>
|
||||
/// <returns>The created <see cref="Isrc"/>.</returns>
|
||||
public Isrc Create(
|
||||
string? value = null)
|
||||
{
|
||||
Result<Isrc> isrcResult = Isrc.Create(value ?? GenerateRandomValue());
|
||||
|
||||
if (isrcResult.IsFailure)
|
||||
throw new InvalidOperationException("Failed to create Isrc: " + string.Join(", ", isrcResult.Errors));
|
||||
return isrcResult.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="Isrc"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="Isrc"/> instances.</returns>
|
||||
public List<Isrc> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates a random value matching the <c>^[A-Z]{2}[A-Z0-9]{3}[0-9]{7}$</c> ISRC format.
|
||||
/// </summary>
|
||||
/// <returns>The generated ISRC value.</returns>
|
||||
private string GenerateRandomValue()
|
||||
{
|
||||
string countryCode = _faker.Random.String2(2, "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
||||
string registrantCode = _faker.Random.String2(3, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
|
||||
string yearAndDesignationCode = _faker.Random.Number(1000000, 9999999).ToString();
|
||||
return countryCode + registrantCode + yearAndDesignationCode;
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MusicBrainzId"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MusicBrainzIdFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MusicBrainzId"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The value used to create the <see cref="MusicBrainzId"/>. If not provided, a random value is generated.</param>
|
||||
/// <returns>The created <see cref="MusicBrainzId"/>.</returns>
|
||||
public MusicBrainzId Create(
|
||||
Guid? value = null)
|
||||
{
|
||||
return MusicBrainzId.Create(value ?? Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="MusicBrainzId"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MusicBrainzId"/> instances.</returns>
|
||||
public List<MusicBrainzId> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.ExternalIdentifiers.MediaContributorBoundedContext.MediaContributorAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.AudioLibraryBoundedContext.ExternalIdentifiers.MediaContributorBoundedContext.MediaContributorAggregate;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaContributors;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MusicMediaContributor"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MusicMediaContributorFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly MediaContributorIdFixture _mediaContributorIdFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MusicMediaContributor"/>.
|
||||
/// </summary>
|
||||
/// <param name="contributorId">Optional. The unique identifier of the media contributor.</param>
|
||||
/// <param name="role">Optional. The role the contributor played.</param>
|
||||
/// <returns>The created <see cref="MusicMediaContributor"/>.</returns>
|
||||
public MusicMediaContributor Create(
|
||||
MediaContributorId? contributorId = null,
|
||||
MediaContributorRole? role = null)
|
||||
{
|
||||
Result<MusicMediaContributor> contributorResult = MusicMediaContributor.Create(
|
||||
contributorId ?? _mediaContributorIdFixture.Create(),
|
||||
role ?? _faker.PickRandom<MediaContributorRole>());
|
||||
|
||||
if (contributorResult.IsFailure)
|
||||
throw new InvalidOperationException("Failed to create MusicMediaContributor: " + string.Join(", ", contributorResult.Errors));
|
||||
return contributorResult.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="MusicMediaContributor"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MusicMediaContributor"/> instances.</returns>
|
||||
public List<MusicMediaContributor> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="TrackId"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class TrackIdFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="TrackId"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The value used to create the <see cref="TrackId"/>. If not provided, a random value is generated.</param>
|
||||
/// <returns>The created <see cref="TrackId"/>.</returns>
|
||||
public TrackId Create(
|
||||
Guid? value = null)
|
||||
{
|
||||
return value is null ? TrackId.CreateUnique() : TrackId.Create(value.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="TrackId"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="TrackId"/> instances.</returns>
|
||||
public List<TrackId> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user