mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 15:11:10 +00:00
Renames project paths from Lumina to Nemera
This commit is contained in:
1 parent
ce6fddb4c9
commit
0f659a4877
6450 files changed
No files matched your search
+104
@@ -0,0 +1,104 @@
|
||||
#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.Fixtures.Common.ValueObjects.Metadata;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.AudioLibraryBoundedContext.Common.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="AudioMetadata"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AudioMetadataFixture
|
||||
{
|
||||
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="AudioMetadata"/>.
|
||||
/// </summary>
|
||||
/// <param name="title">Optional. The title of the audio.</param>
|
||||
/// <param name="originalTitle">Optional. The original title of the audio.</param>
|
||||
/// <param name="durationInSeconds">Optional. The duration of the audio, in seconds.</param>
|
||||
/// <param name="sampleRate">Optional. The sample rate of the audio, in Hz.</param>
|
||||
/// <param name="channels">Optional. The number of audio channels.</param>
|
||||
/// <param name="releaseInfo">Optional. The release information of the audio.</param>
|
||||
/// <param name="description">Optional. The description of the audio.</param>
|
||||
/// <param name="genres">Optional. The genres of the audio.</param>
|
||||
/// <param name="tags">Optional. The tags associated with the audio.</param>
|
||||
/// <param name="language">Optional. The language of the audio.</param>
|
||||
/// <param name="originalLanguage">Optional. The original language of the audio.</param>
|
||||
/// <param name="bitDepth">Optional. The bit depth of the audio.</param>
|
||||
/// <param name="audioCodec">Optional. The audio codec used.</param>
|
||||
/// <param name="container">Optional. The container of the audio.</param>
|
||||
/// <param name="bitrate">Optional. The bitrate of the audio, in kbps.</param>
|
||||
/// <param name="acoustId">Optional. The AcoustID fingerprint identifier of the audio file.</param>
|
||||
/// <param name="replayGainTrackGain">Optional. The ReplayGain track gain, in decibels.</param>
|
||||
/// <param name="replayGainTrackPeak">Optional. The ReplayGain track peak.</param>
|
||||
/// <param name="replayGainAlbumGain">Optional. The ReplayGain album gain, in decibels.</param>
|
||||
/// <param name="replayGainAlbumPeak">Optional. The ReplayGain album peak.</param>
|
||||
/// <returns>The created <see cref="AudioMetadata"/>.</returns>
|
||||
public AudioMetadata Create(
|
||||
string? title = null,
|
||||
Optional<string>? originalTitle = null,
|
||||
int? durationInSeconds = null,
|
||||
int? sampleRate = null,
|
||||
int? channels = null,
|
||||
ReleaseInfo? releaseInfo = null,
|
||||
Optional<string>? description = null,
|
||||
List<Genre>? genres = null,
|
||||
List<Tag>? tags = null,
|
||||
Optional<LanguageInfo>? language = null,
|
||||
Optional<LanguageInfo>? originalLanguage = null,
|
||||
Optional<int>? bitDepth = null,
|
||||
Optional<string>? audioCodec = null,
|
||||
Optional<string>? container = null,
|
||||
Optional<int>? bitrate = null,
|
||||
Optional<string>? acoustId = null,
|
||||
Optional<decimal>? replayGainTrackGain = null,
|
||||
Optional<decimal>? replayGainTrackPeak = null,
|
||||
Optional<decimal>? replayGainAlbumGain = null,
|
||||
Optional<decimal>? replayGainAlbumPeak = null)
|
||||
{
|
||||
return AudioMetadata.Create(
|
||||
title ?? _faker.Music.Genre(),
|
||||
originalTitle ?? Optional<string>.None(),
|
||||
durationInSeconds ?? _faker.Random.Int(60, 7200),
|
||||
sampleRate ?? _faker.Random.Int(44100, 192000),
|
||||
channels ?? _faker.Random.Int(1, 8),
|
||||
releaseInfo ?? _releaseInfoFixture.Create(),
|
||||
description ?? Optional<string>.Some(_faker.Lorem.Sentence()),
|
||||
genres ?? [_genreFixture.Create(), _genreFixture.Create()],
|
||||
tags ?? [_tagFixture.Create(), _tagFixture.Create()],
|
||||
language ?? Optional<LanguageInfo>.Some(_languageInfoFixture.Create()),
|
||||
originalLanguage ?? Optional<LanguageInfo>.None(),
|
||||
bitDepth ?? Optional<int>.Some(_faker.Random.Int(8, 32)),
|
||||
audioCodec ?? Optional<string>.Some("PCM"),
|
||||
container ?? Optional<string>.Some(_faker.PickRandom("MP3", "FLAC", "OGG", "MP4", "AAC", "WAV")),
|
||||
bitrate ?? Optional<int>.Some(_faker.Random.Int(128, 320)),
|
||||
acoustId ?? Optional<string>.None(),
|
||||
replayGainTrackGain ?? Optional<decimal>.None(),
|
||||
replayGainTrackPeak ?? Optional<decimal>.None(),
|
||||
replayGainAlbumGain ?? Optional<decimal>.None(),
|
||||
replayGainAlbumPeak ?? Optional<decimal>.None()).Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="AudioMetadata"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="AudioMetadata"/> instances.</returns>
|
||||
public List<AudioMetadata> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.Common.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.Common.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="AudioRating"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AudioRatingFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="AudioRating"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The numeric value of the rating.</param>
|
||||
/// <param name="maxValue">Optional. The maximum possible rating value.</param>
|
||||
/// <param name="source">Optional. The source of the rating.</param>
|
||||
/// <param name="voteCount">Optional. The number of votes or reviews.</param>
|
||||
/// <returns>The created <see cref="AudioRating"/>.</returns>
|
||||
public AudioRating Create(
|
||||
decimal? value = null,
|
||||
decimal? maxValue = null,
|
||||
Optional<AudioRatingSource>? source = null,
|
||||
Optional<int>? voteCount = null)
|
||||
{
|
||||
decimal resolvedMaxValue = maxValue ?? 5m;
|
||||
Result<AudioRating> ratingResult = AudioRating.Create(
|
||||
value ?? _faker.Random.Decimal(0m, resolvedMaxValue),
|
||||
resolvedMaxValue,
|
||||
source ?? Optional<AudioRatingSource>.Some(_faker.PickRandom<AudioRatingSource>()),
|
||||
voteCount ?? Optional<int>.Some(_faker.Random.Int(0, 10000)));
|
||||
|
||||
if (ratingResult.IsFailure)
|
||||
throw new InvalidOperationException("Failed to create AudioRating: " + string.Join(", ", ratingResult.Errors));
|
||||
return ratingResult.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="AudioRating"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="AudioRating"/> instances.</returns>
|
||||
public List<AudioRating> 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())];
|
||||
}
|
||||
}
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
#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.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.Common.ValueObjects.Metadata;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.AudioLibraryBoundedContext.Common.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 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;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="Artist"/> domain aggregate root.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ArtistFixture
|
||||
{
|
||||
private const int MINIMUM_LIFESPAN_YEAR = 1900;
|
||||
private const int MAXIMUM_LIFESPAN_YEAR = 2026;
|
||||
|
||||
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();
|
||||
private readonly MusicAreaFixture _musicAreaFixture = new();
|
||||
private readonly MusicArtistAliasFixture _musicArtistAliasFixture = new();
|
||||
private readonly GenreFixture _genreFixture = new();
|
||||
private readonly TagFixture _tagFixture = new();
|
||||
private readonly AudioRatingFixture _audioRatingFixture = 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="sortName">Optional. The sort name of the artist.</param>
|
||||
/// <param name="disambiguation">Optional. The disambiguation comment of the artist.</param>
|
||||
/// <param name="type">Optional. The type of the artist.</param>
|
||||
/// <param name="gender">Optional. The gender of the artist.</param>
|
||||
/// <param name="country">Optional. The country of the artist.</param>
|
||||
/// <param name="area">Optional. The area the artist is primarily identified with.</param>
|
||||
/// <param name="beginArea">Optional. The area the artist began in.</param>
|
||||
/// <param name="endArea">Optional. The area the artist ended in.</param>
|
||||
/// <param name="lifeSpanBegin">Optional. The date the artist started existing.</param>
|
||||
/// <param name="lifeSpanEnd">Optional. The date the artist stopped existing.</param>
|
||||
/// <param name="isEnded">Optional. Whether the artist no longer exists.</param>
|
||||
/// <param name="website">Optional. The website of the artist.</param>
|
||||
/// <param name="musicBrainzArtistId">Optional. The MusicBrainz identifier of the artist.</param>
|
||||
/// <param name="ipis">Optional. The IPI codes of the artist.</param>
|
||||
/// <param name="isnis">Optional. The ISNI codes of the artist.</param>
|
||||
/// <param name="aliases">Optional. The alternative names of the artist.</param>
|
||||
/// <param name="genres">Optional. The genres associated with the artist.</param>
|
||||
/// <param name="tags">Optional. The tags associated with the artist.</param>
|
||||
/// <param name="ratings">Optional. The ratings 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>? sortName = null,
|
||||
Optional<string>? disambiguation = null,
|
||||
Optional<MusicArtistType>? type = null,
|
||||
Optional<MusicArtistGender>? gender = null,
|
||||
Optional<string>? country = null,
|
||||
Optional<MusicArea>? area = null,
|
||||
Optional<MusicArea>? beginArea = null,
|
||||
Optional<MusicArea>? endArea = null,
|
||||
Optional<DateOnly>? lifeSpanBegin = null,
|
||||
Optional<DateOnly>? lifeSpanEnd = null,
|
||||
bool? isEnded = null,
|
||||
Optional<string>? website = null,
|
||||
Optional<MusicBrainzId>? musicBrainzArtistId = null,
|
||||
List<string>? ipis = null,
|
||||
List<string>? isnis = null,
|
||||
List<MusicArtistAlias>? aliases = null,
|
||||
List<Genre>? genres = null,
|
||||
List<Tag>? tags = null,
|
||||
List<AudioRating>? ratings = null,
|
||||
List<MusicMediaContributor>? contributors = null,
|
||||
List<Album>? albums = null)
|
||||
{
|
||||
int lifeSpanBeginYear = Random.Shared.Next(MINIMUM_LIFESPAN_YEAR, MAXIMUM_LIFESPAN_YEAR);
|
||||
int lifeSpanEndYear = Random.Shared.Next(lifeSpanBeginYear, Math.Max(lifeSpanBeginYear + 1, MAXIMUM_LIFESPAN_YEAR));
|
||||
Result<Artist> artistResult = Artist.Create(
|
||||
libraryId ?? _libraryIdFixture.Create(),
|
||||
name ?? _faker.Name.FullName(),
|
||||
sortName ?? Optional<string>.Some(_faker.Name.FullName()),
|
||||
disambiguation ?? Optional<string>.Some(_faker.Lorem.Sentence()),
|
||||
type ?? Optional<MusicArtistType>.Some(_faker.PickRandom<MusicArtistType>()),
|
||||
gender ?? Optional<MusicArtistGender>.Some(_faker.PickRandom<MusicArtistGender>()),
|
||||
country ?? Optional<string>.Some(_faker.Address.CountryCode()),
|
||||
area ?? Optional<MusicArea>.Some(_musicAreaFixture.Create()),
|
||||
beginArea ?? Optional<MusicArea>.Some(_musicAreaFixture.Create()),
|
||||
endArea ?? Optional<MusicArea>.Some(_musicAreaFixture.Create()),
|
||||
lifeSpanBegin ?? Optional<DateOnly>.Some(new DateOnly(lifeSpanBeginYear, 1, 1)),
|
||||
lifeSpanEnd ?? Optional<DateOnly>.Some(new DateOnly(lifeSpanEndYear, 1, 1)),
|
||||
isEnded ?? _faker.Random.Bool(),
|
||||
website ?? Optional<string>.Some(_faker.Internet.Url()),
|
||||
musicBrainzArtistId ?? Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create()),
|
||||
ipis ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 2)).Select(_ => _faker.Random.AlphaNumeric(9))],
|
||||
isnis ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 2)).Select(_ => _faker.Random.AlphaNumeric(16))],
|
||||
aliases ?? _musicArtistAliasFixture.CreateMany(_faker.Random.Int(1, 2)),
|
||||
genres ?? _genreFixture.CreateMany(_faker.Random.Int(1, 2)),
|
||||
tags ?? _tagFixture.CreateMany(_faker.Random.Int(1, 2)),
|
||||
ratings ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 2)).Select(_ => _audioRatingFixture.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())];
|
||||
}
|
||||
}
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
#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="disambiguation">Optional. The disambiguation comment of the album.</param>
|
||||
/// <param name="mediaFormat">Optional. The physical or digital medium of the album.</param>
|
||||
/// <param name="packaging">Optional. The outermost physical packaging of the album.</param>
|
||||
/// <param name="script">Optional. The script used by the language of the release 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="label">Optional. The name of the label that issued the album.</param>
|
||||
/// <param name="asin">Optional. The ASIN 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<string>? disambiguation = null,
|
||||
Optional<MusicMediaFormat>? mediaFormat = null,
|
||||
Optional<MusicReleasePackaging>? packaging = null,
|
||||
Optional<string>? script = null,
|
||||
Optional<Barcode>? barcode = null,
|
||||
List<string>? catalogNumbers = null,
|
||||
Optional<string>? label = null,
|
||||
Optional<string>? asin = 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(),
|
||||
disambiguation ?? Optional<string>.Some(_faker.Lorem.Sentence()),
|
||||
mediaFormat ?? Optional<MusicMediaFormat>.Some(_faker.PickRandom<MusicMediaFormat>()),
|
||||
packaging ?? Optional<MusicReleasePackaging>.Some(_faker.PickRandom<MusicReleasePackaging>()),
|
||||
script ?? Optional<string>.Some(_faker.Random.String2(4)),
|
||||
barcode ?? Optional<Barcode>.Some(_barcodeFixture.Create()),
|
||||
catalogNumbers ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 2)).Select(_ => _faker.Random.String2(_faker.Random.Int(5, 20)))],
|
||||
label ?? Optional<string>.Some(_faker.Company.CompanyName()),
|
||||
asin ?? Optional<string>.Some(_faker.Random.AlphaNumeric(10)),
|
||||
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())];
|
||||
}
|
||||
}
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
#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 MusicWorkFixture _musicWorkFixture = 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="disambiguation">Optional. The disambiguation comment 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="isVideo">Optional. Whether the recording of the track is a video recording.</param>
|
||||
/// <param name="isrcs">Optional. The ISRCs of the track.</param>
|
||||
/// <param name="work">Optional. 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="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,
|
||||
Optional<string>? disambiguation = null,
|
||||
int? trackNumber = null,
|
||||
Optional<int>? discNumber = null,
|
||||
List<Mood>? moods = null,
|
||||
Optional<string>? script = null,
|
||||
Optional<MusicKey>? key = null,
|
||||
Optional<int>? bpm = null,
|
||||
bool? isVideo = null,
|
||||
List<Isrc>? isrcs = null,
|
||||
Optional<MusicWork>? work = null,
|
||||
Optional<MusicBrainzId>? musicBrainzRecordingId = null,
|
||||
Optional<MusicBrainzId>? musicBrainzTrackId = null,
|
||||
List<MusicMediaContributor>? contributors = null,
|
||||
List<AudioRating>? ratings = null)
|
||||
{
|
||||
Result<Track> trackResult = Track.Create(
|
||||
path ?? _faker.System.FilePath(),
|
||||
metadata ?? _audioMetadataFixture.Create(),
|
||||
disambiguation ?? Optional<string>.None(),
|
||||
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)),
|
||||
isVideo ?? _faker.Random.Bool(),
|
||||
isrcs ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 2)).Select(_ => _isrcFixture.Create())],
|
||||
work ?? Optional<MusicWork>.Some(_musicWorkFixture.Create()),
|
||||
musicBrainzRecordingId ?? Optional<MusicBrainzId>.Some(_musicBrainzIdFixture.Create()),
|
||||
musicBrainzTrackId ?? 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())];
|
||||
}
|
||||
}
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
#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="releaseTitle">Optional. The title of the specific release (edition) 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="releaseTypes">Optional. The types 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>? releaseTitle = null,
|
||||
Optional<string>? description = null,
|
||||
ReleaseInfo? releaseInfo = null,
|
||||
List<Genre>? genres = null,
|
||||
List<Tag>? tags = null,
|
||||
Optional<LanguageInfo>? language = null,
|
||||
Optional<LanguageInfo>? originalLanguage = null,
|
||||
List<MusicReleaseType>? releaseTypes = 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(),
|
||||
releaseTitle ?? Optional<string>.Some(_faker.Commerce.ProductName()),
|
||||
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(),
|
||||
releaseTypes ?? [_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;
|
||||
}
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
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="MusicArea"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MusicAreaFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly MusicBrainzIdFixture _musicBrainzIdFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MusicArea"/>.
|
||||
/// </summary>
|
||||
/// <param name="musicBrainzAreaId">Optional. The MusicBrainz identifier of the area.</param>
|
||||
/// <param name="name">Optional. The name of the area.</param>
|
||||
/// <param name="sortName">Optional. The sort name of the area.</param>
|
||||
/// <param name="disambiguation">Optional. The disambiguation comment of the area.</param>
|
||||
/// <param name="type">Optional. The MusicBrainz type of the area.</param>
|
||||
/// <param name="iso3166Code">Optional. The ISO 3166 code of the area.</param>
|
||||
/// <returns>The created <see cref="MusicArea"/>.</returns>
|
||||
public MusicArea Create(
|
||||
MusicBrainzId? musicBrainzAreaId = null,
|
||||
string? name = null,
|
||||
Optional<string>? sortName = null,
|
||||
Optional<string>? disambiguation = null,
|
||||
Optional<string>? type = null,
|
||||
Optional<string>? iso3166Code = null)
|
||||
{
|
||||
Result<MusicArea> areaResult = MusicArea.Create(
|
||||
musicBrainzAreaId ?? _musicBrainzIdFixture.Create(),
|
||||
name ?? _faker.Address.Country(),
|
||||
sortName ?? Optional<string>.Some(_faker.Address.Country()),
|
||||
disambiguation ?? Optional<string>.Some(_faker.Lorem.Sentence()),
|
||||
type ?? Optional<string>.Some(_faker.Random.ArrayElement(["Country", "City", "Area"])),
|
||||
iso3166Code ?? Optional<string>.Some(_faker.Address.CountryCode()));
|
||||
|
||||
if (areaResult.IsFailure)
|
||||
throw new System.InvalidOperationException("Failed to create MusicArea: " + string.Join(", ", areaResult.Errors));
|
||||
return areaResult.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="MusicArea"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MusicArea"/> instances.</returns>
|
||||
public List<MusicArea> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
#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="MusicArtistAlias"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MusicArtistAliasFixture
|
||||
{
|
||||
private const int MINIMUM_ALIAS_YEAR = 1900;
|
||||
private const int MAXIMUM_ALIAS_YEAR = 2026;
|
||||
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MusicArtistAlias"/>.
|
||||
/// </summary>
|
||||
/// <param name="name">Optional. The name of the alias.</param>
|
||||
/// <param name="sortName">Optional. The sort name of the alias.</param>
|
||||
/// <param name="type">Optional. The type of the alias.</param>
|
||||
/// <param name="locale">Optional. The locale the alias is used in.</param>
|
||||
/// <param name="isPrimary">Optional. Whether this is the primary alias of the artist.</param>
|
||||
/// <param name="beginDate">Optional. The date the alias began being used.</param>
|
||||
/// <param name="endDate">Optional. The date the alias stopped being used.</param>
|
||||
/// <param name="isEnded">Optional. Whether the alias is no longer used.</param>
|
||||
/// <returns>The created <see cref="MusicArtistAlias"/>.</returns>
|
||||
public MusicArtistAlias Create(
|
||||
string? name = null,
|
||||
Optional<string>? sortName = null,
|
||||
Optional<string>? type = null,
|
||||
Optional<string>? locale = null,
|
||||
bool? isPrimary = null,
|
||||
Optional<DateOnly>? beginDate = null,
|
||||
Optional<DateOnly>? endDate = null,
|
||||
bool? isEnded = null)
|
||||
{
|
||||
int beginYear = Random.Shared.Next(MINIMUM_ALIAS_YEAR, MAXIMUM_ALIAS_YEAR);
|
||||
int endYear = Random.Shared.Next(beginYear, Math.Max(beginYear + 1, MAXIMUM_ALIAS_YEAR));
|
||||
Result<MusicArtistAlias> aliasResult = MusicArtistAlias.Create(
|
||||
name ?? _faker.Name.FullName(),
|
||||
sortName ?? Optional<string>.Some(_faker.Name.FullName()),
|
||||
type ?? Optional<string>.Some(_faker.Random.ArrayElement(["Artist name", "Search hint"])),
|
||||
locale ?? Optional<string>.Some(_faker.Random.String2(2)),
|
||||
isPrimary ?? _faker.Random.Bool(),
|
||||
beginDate ?? Optional<DateOnly>.Some(new DateOnly(beginYear, 1, 1)),
|
||||
endDate ?? Optional<DateOnly>.Some(new DateOnly(endYear, 1, 1)),
|
||||
isEnded ?? _faker.Random.Bool());
|
||||
|
||||
if (aliasResult.IsFailure)
|
||||
throw new InvalidOperationException("Failed to create MusicArtistAlias: " + string.Join(", ", aliasResult.Errors));
|
||||
return aliasResult.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="MusicArtistAlias"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MusicArtistAlias"/> instances.</returns>
|
||||
public List<MusicArtistAlias> 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="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())];
|
||||
}
|
||||
}
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
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="MusicLibraryPathMetadata"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MusicLibraryPathMetadataFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly ParsedLibraryPathFixture _parsedLibraryPathFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MusicLibraryPathMetadata"/>.
|
||||
/// </summary>
|
||||
/// <param name="artistName">Optional. The name of the artist derived from the path.</param>
|
||||
/// <param name="releaseType">Optional. The type of the release derived from the path.</param>
|
||||
/// <param name="releaseYear">Optional. The release year derived from the path.</param>
|
||||
/// <param name="releaseName">Optional. The name of the release derived from the path.</param>
|
||||
/// <param name="trackNumber">Optional. The number of the track derived from the path.</param>
|
||||
/// <param name="discNumber">Optional. The number of the disc the track belongs to, derived from the path.</param>
|
||||
/// <param name="trackTitle">Optional. The title of the track derived from the path.</param>
|
||||
/// <param name="includeArtistName">Whether the artist name should be captured. When <see langword="false"/>, the artist name is not captured.</param>
|
||||
/// <param name="includeReleaseType">Whether the release type should be captured. When <see langword="false"/>, the release type is not captured.</param>
|
||||
/// <param name="includeReleaseYear">Whether the release year should be captured. When <see langword="false"/>, the release year is not captured.</param>
|
||||
/// <param name="includeReleaseName">Whether the release name should be captured. When <see langword="false"/>, the release name is not captured.</param>
|
||||
/// <param name="includeTrackNumber">Whether the track number should be captured. When <see langword="false"/>, the track number is not captured.</param>
|
||||
/// <param name="includeDiscNumber">Whether the disc number should be captured. When <see langword="false"/>, the disc number is not captured.</param>
|
||||
/// <param name="includeTrackTitle">Whether the track title should be captured. When <see langword="false"/>, the track title is not captured.</param>
|
||||
/// <returns>The created <see cref="MusicLibraryPathMetadata"/>.</returns>
|
||||
public MusicLibraryPathMetadata Create(
|
||||
string? artistName = null,
|
||||
MusicReleaseType? releaseType = null,
|
||||
int? releaseYear = null,
|
||||
string? releaseName = null,
|
||||
int? trackNumber = null,
|
||||
int? discNumber = null,
|
||||
string? trackTitle = null,
|
||||
bool includeArtistName = true,
|
||||
bool includeReleaseType = true,
|
||||
bool includeReleaseYear = true,
|
||||
bool includeReleaseName = true,
|
||||
bool includeTrackNumber = true,
|
||||
bool includeDiscNumber = true,
|
||||
bool includeTrackTitle = true)
|
||||
{
|
||||
Dictionary<LibraryPathPartKind, string> values = [];
|
||||
if (includeArtistName)
|
||||
values[LibraryPathPartKind.Artist] = artistName ?? _faker.Name.FullName();
|
||||
if (includeReleaseType)
|
||||
values[LibraryPathPartKind.ReleaseType] = (releaseType ?? _faker.PickRandom<MusicReleaseType>()).ToString();
|
||||
if (includeReleaseYear)
|
||||
values[LibraryPathPartKind.ReleaseYear] = (releaseYear ?? _faker.Random.Int(1900, 2025)).ToString();
|
||||
if (includeReleaseName)
|
||||
values[LibraryPathPartKind.ReleaseName] = releaseName ?? _faker.Commerce.ProductName();
|
||||
if (includeTrackNumber)
|
||||
values[LibraryPathPartKind.TrackNumber] = (trackNumber ?? _faker.Random.Int(1, 30)).ToString();
|
||||
if (includeDiscNumber)
|
||||
values[LibraryPathPartKind.DiscNumber] = (discNumber ?? _faker.Random.Int(1, 4)).ToString();
|
||||
if (includeTrackTitle)
|
||||
values[LibraryPathPartKind.TrackName] = trackTitle ?? _faker.Commerce.ProductName();
|
||||
return MusicLibraryPathMetadata.FromParsedLibraryPath(_parsedLibraryPathFixture.Create(values));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="MusicLibraryPathMetadata"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MusicLibraryPathMetadata"/> instances.</returns>
|
||||
public List<MusicLibraryPathMetadata> 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())];
|
||||
}
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
#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 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="MusicWork"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MusicWorkFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly MusicBrainzIdFixture _musicBrainzIdFixture = new();
|
||||
private readonly LanguageInfoFixture _languageInfoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MusicWork"/>.
|
||||
/// </summary>
|
||||
/// <param name="musicBrainzWorkId">Optional. The MusicBrainz identifier of the work.</param>
|
||||
/// <param name="title">Optional. The title of the work.</param>
|
||||
/// <param name="type">Optional. The MusicBrainz type of the work.</param>
|
||||
/// <param name="languages">Optional. The languages of the work.</param>
|
||||
/// <param name="iswcs">Optional. The ISWC codes of the work.</param>
|
||||
/// <returns>The created <see cref="MusicWork"/>.</returns>
|
||||
public MusicWork Create(
|
||||
MusicBrainzId? musicBrainzWorkId = null,
|
||||
string? title = null,
|
||||
Optional<string>? type = null,
|
||||
List<LanguageInfo>? languages = null,
|
||||
List<string>? iswcs = null)
|
||||
{
|
||||
Result<MusicWork> workResult = MusicWork.Create(
|
||||
musicBrainzWorkId ?? _musicBrainzIdFixture.Create(),
|
||||
title ?? _faker.Music.Genre(),
|
||||
type ?? Optional<string>.Some(_faker.Random.ArrayElement(["Song", "Instrumental"])),
|
||||
languages ?? _languageInfoFixture.CreateMany(_faker.Random.Int(1, 2)),
|
||||
iswcs ?? [.. Enumerable.Range(0, _faker.Random.Int(1, 2)).Select(_ => $"T{_faker.Random.AlphaNumeric(10)}")]);
|
||||
|
||||
if (workResult.IsFailure)
|
||||
throw new System.InvalidOperationException("Failed to create MusicWork: " + string.Join(", ", workResult.Errors));
|
||||
return workResult.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="MusicWork"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MusicWork"/> instances.</returns>
|
||||
public List<MusicWork> 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