Renames project paths from Lumina to Nemera

This commit is contained in:
BinaryAlley committed 2026-11-27 15:34:43 +02:00
1 parent ce6fddb4c9
commit 0f659a4877
6450 files changed

No files matched your search

@@ -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())];
}
}
@@ -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())];
}
}
@@ -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())];
}
}
@@ -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())];
}
}
@@ -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())];
}
}
@@ -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())];
}
}
@@ -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())];
}
}
@@ -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())];
}
}
@@ -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())];
}
}
@@ -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())];
}
}
@@ -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");
}
}
@@ -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;
}
}
@@ -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())];
}
}
@@ -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())];
}
}
@@ -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())];
}
}
@@ -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())];
}
}
@@ -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())];
}
}
@@ -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())];
}
}
@@ -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())];
}
}
@@ -0,0 +1,37 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.FavoriteBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.FavoriteBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
/// <summary>
/// Fixture class for the <see cref="MediaItemId"/> value object.
/// </summary>
[ExcludeFromCodeCoverage]
public class MediaItemIdFixture
{
/// <summary>
/// Creates a random valid <see cref="MediaItemId"/>.
/// </summary>
/// <param name="value">Optional. The raw value of the media item Id.</param>
/// <returns>The created <see cref="MediaItemId"/>.</returns>
public MediaItemId Create(
Guid? value = null)
{
return MediaItemId.Create(value ?? Guid.NewGuid());
}
/// <summary>
/// Creates a list of <see cref="MediaItemId"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="MediaItemId"/> instances.</returns>
public List<MediaItemId> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,37 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.FavoriteBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.FavoriteBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
/// <summary>
/// Fixture class for the <see cref="UserId"/> value object.
/// </summary>
[ExcludeFromCodeCoverage]
public class UserIdFixture
{
/// <summary>
/// Creates a random valid <see cref="UserId"/>.
/// </summary>
/// <param name="value">Optional. The raw value of the user Id.</param>
/// <returns>The created <see cref="UserId"/>.</returns>
public UserId Create(
Guid? value = null)
{
return UserId.Create(value ?? Guid.NewGuid());
}
/// <summary>
/// Creates a list of <see cref="UserId"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="UserId"/> instances.</returns>
public List<UserId> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,73 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Domain.Core.BoundedContexts.FavoriteBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
using Lumina.Domain.Core.BoundedContexts.FavoriteBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
using Lumina.Domain.Core.BoundedContexts.FavoriteBoundedContext.FavoriteAggregate.Events;
using Lumina.Domain.Core.BoundedContexts.FavoriteBoundedContext.FavoriteAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.FavoriteBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
using Lumina.Domain.Fixtures.Core.BoundedContexts.FavoriteBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
using Lumina.Domain.Fixtures.Core.BoundedContexts.FavoriteBoundedContext.FavoriteAggregate.ValueObjects;
using Lumina.Domain.SharedKernel.Common.Enums.Favorites;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.FavoriteBoundedContext.FavoriteAggregate.Events;
/// <summary>
/// Fixture class for the <see cref="FavoriteAddedDomainEvent"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class FavoriteAddedDomainEventFixture
{
private readonly Faker _faker = new();
private readonly FavoriteIdFixture _favoriteIdFixture = new();
private readonly UserIdFixture _userIdFixture = new();
private readonly MediaItemIdFixture _mediaItemIdFixture = new();
private readonly FavoriteMediaKind[] _supportedMediaKinds =
[
FavoriteMediaKind.MusicArtist,
FavoriteMediaKind.MusicAlbum,
FavoriteMediaKind.MusicTrack,
FavoriteMediaKind.Book
];
/// <summary>
/// Creates a random valid <see cref="FavoriteAddedDomainEvent"/>.
/// </summary>
/// <param name="id">Optional. The Id of the domain event.</param>
/// <param name="favoriteId">Optional. The unique identifier of the favorite.</param>
/// <param name="userId">Optional. The unique identifier of the user that favorited the media item.</param>
/// <param name="mediaItemId">Optional. The unique identifier of the favorited media item.</param>
/// <param name="mediaKind">Optional. The kind of the favorited media item. Defaults to a random supported kind.</param>
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
/// <returns>The created <see cref="FavoriteAddedDomainEvent"/>.</returns>
public FavoriteAddedDomainEvent Create(
Guid? id = null,
FavoriteId? favoriteId = null,
UserId? userId = null,
MediaItemId? mediaItemId = null,
FavoriteMediaKind? mediaKind = null,
DateTime? occurredOnUtc = null)
{
return new FavoriteAddedDomainEvent(
id ?? Guid.NewGuid(),
favoriteId ?? _favoriteIdFixture.Create(),
userId ?? _userIdFixture.Create(),
mediaItemId ?? _mediaItemIdFixture.Create(),
mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds),
occurredOnUtc ?? DateTime.UtcNow);
}
/// <summary>
/// Creates multiple <see cref="FavoriteAddedDomainEvent"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="FavoriteAddedDomainEvent"/> instances.</returns>
public List<FavoriteAddedDomainEvent> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,73 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Domain.Core.BoundedContexts.FavoriteBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
using Lumina.Domain.Core.BoundedContexts.FavoriteBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
using Lumina.Domain.Core.BoundedContexts.FavoriteBoundedContext.FavoriteAggregate.Events;
using Lumina.Domain.Core.BoundedContexts.FavoriteBoundedContext.FavoriteAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.FavoriteBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
using Lumina.Domain.Fixtures.Core.BoundedContexts.FavoriteBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
using Lumina.Domain.Fixtures.Core.BoundedContexts.FavoriteBoundedContext.FavoriteAggregate.ValueObjects;
using Lumina.Domain.SharedKernel.Common.Enums.Favorites;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.FavoriteBoundedContext.FavoriteAggregate.Events;
/// <summary>
/// Fixture class for the <see cref="FavoriteRemovedDomainEvent"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class FavoriteRemovedDomainEventFixture
{
private readonly Faker _faker = new();
private readonly FavoriteIdFixture _favoriteIdFixture = new();
private readonly UserIdFixture _userIdFixture = new();
private readonly MediaItemIdFixture _mediaItemIdFixture = new();
private readonly FavoriteMediaKind[] _supportedMediaKinds =
[
FavoriteMediaKind.MusicArtist,
FavoriteMediaKind.MusicAlbum,
FavoriteMediaKind.MusicTrack,
FavoriteMediaKind.Book
];
/// <summary>
/// Creates a random valid <see cref="FavoriteRemovedDomainEvent"/>.
/// </summary>
/// <param name="id">Optional. The Id of the domain event.</param>
/// <param name="favoriteId">Optional. The unique identifier of the removed favorite.</param>
/// <param name="userId">Optional. The unique identifier of the user that owned the favorite.</param>
/// <param name="mediaItemId">Optional. The unique identifier of the media item that was unfavorited.</param>
/// <param name="mediaKind">Optional. The kind of the media item that was unfavorited. Defaults to a random supported kind.</param>
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
/// <returns>The created <see cref="FavoriteRemovedDomainEvent"/>.</returns>
public FavoriteRemovedDomainEvent Create(
Guid? id = null,
FavoriteId? favoriteId = null,
UserId? userId = null,
MediaItemId? mediaItemId = null,
FavoriteMediaKind? mediaKind = null,
DateTime? occurredOnUtc = null)
{
return new FavoriteRemovedDomainEvent(
id ?? Guid.NewGuid(),
favoriteId ?? _favoriteIdFixture.Create(),
userId ?? _userIdFixture.Create(),
mediaItemId ?? _mediaItemIdFixture.Create(),
mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds),
occurredOnUtc ?? DateTime.UtcNow);
}
/// <summary>
/// Creates multiple <see cref="FavoriteRemovedDomainEvent"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="FavoriteRemovedDomainEvent"/> instances.</returns>
public List<FavoriteRemovedDomainEvent> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,100 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.FavoriteBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
using Lumina.Domain.Core.BoundedContexts.FavoriteBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
using Lumina.Domain.Core.BoundedContexts.FavoriteBoundedContext.FavoriteAggregate;
using Lumina.Domain.Core.BoundedContexts.FavoriteBoundedContext.FavoriteAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.FavoriteBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
using Lumina.Domain.Fixtures.Core.BoundedContexts.FavoriteBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
using Lumina.Domain.Fixtures.Core.BoundedContexts.FavoriteBoundedContext.FavoriteAggregate.ValueObjects;
using Lumina.Domain.SharedKernel.Common.Enums.Favorites;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.FavoriteBoundedContext.FavoriteAggregate;
/// <summary>
/// Fixture class for the <see cref="Favorite"/> domain aggregate.
/// </summary>
[ExcludeFromCodeCoverage]
public class FavoriteFixture
{
private readonly Faker _faker = new();
private readonly FavoriteIdFixture _favoriteIdFixture = new();
private readonly UserIdFixture _userIdFixture = new();
private readonly MediaItemIdFixture _mediaItemIdFixture = new();
private readonly FavoriteMediaKind[] _supportedMediaKinds =
[
FavoriteMediaKind.MusicArtist,
FavoriteMediaKind.MusicAlbum,
FavoriteMediaKind.MusicTrack,
FavoriteMediaKind.Book
];
/// <summary>
/// Creates a random valid <see cref="Favorite"/> domain aggregate, with pre-existing data.
/// </summary>
/// <param name="id">Optional. The Id of the favorite.</param>
/// <param name="userId">Optional. The Id of the user that owns the favorite.</param>
/// <param name="mediaItemId">Optional. The Id of the favorited media item.</param>
/// <param name="mediaKind">Optional. The kind of the favorited media item. Defaults to a random supported kind.</param>
/// <param name="createdOnUtc">Optional. The date and time when the favorite was created. Defaults to a few days in the past.</param>
/// <param name="updatedOnUtc">Optional. The date and time when the favorite was last updated. Defaults to a moment at or after the creation date, or to no value when <paramref name="includeUpdatedOnUtc"/> is <see langword="false"/>.</param>
/// <param name="includeUpdatedOnUtc">Whether to generate an update date and time when <paramref name="updatedOnUtc"/> is not supplied.</param>
/// <returns>The created <see cref="Favorite"/>.</returns>
/// <remarks>
/// The favorite is built through the rehydrating <see cref="Favorite.Create(FavoriteId, UserId, MediaItemId, FavoriteMediaKind, DateTime, Optional{DateTime})"/>
/// overload, so it carries no domain events, is never marked as removed, and keeps whatever media kind it is given, including a planned one.
/// </remarks>
public Favorite Create(
FavoriteId? id = null,
UserId? userId = null,
MediaItemId? mediaItemId = null,
FavoriteMediaKind? mediaKind = null,
DateTime? createdOnUtc = null,
Optional<DateTime>? updatedOnUtc = null,
bool includeUpdatedOnUtc = true)
{
DateTime resolvedCreatedOnUtc = createdOnUtc ?? DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)).AddMinutes(-_faker.Random.Int(0, 59));
return Favorite.Create(
id ?? _favoriteIdFixture.Create(),
userId ?? _userIdFixture.Create(),
mediaItemId ?? _mediaItemIdFixture.Create(),
mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds),
resolvedCreatedOnUtc,
ResolveUpdatedOnUtc(updatedOnUtc, includeUpdatedOnUtc, resolvedCreatedOnUtc)).Value;
}
/// <summary>
/// Creates multiple <see cref="Favorite"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="Favorite"/> instances.</returns>
public List<Favorite> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
/// <summary>
/// Resolves the update date and time of the favorite, keeping it at or after the creation date and inside the date range.
/// </summary>
/// <param name="updatedOnUtc">The explicitly supplied update date and time, if any.</param>
/// <param name="includeUpdatedOnUtc">Whether to generate an update date and time when none is supplied.</param>
/// <param name="createdOnUtc">The creation date and time of the favorite.</param>
/// <returns>The resolved update date and time, or no value when the favorite was never updated.</returns>
private Optional<DateTime> ResolveUpdatedOnUtc(Optional<DateTime>? updatedOnUtc, bool includeUpdatedOnUtc, DateTime createdOnUtc)
{
if (updatedOnUtc.HasValue)
return updatedOnUtc.Value;
if (!includeUpdatedOnUtc)
return Optional<DateTime>.None();
TimeSpan offsetFromCreation = TimeSpan.FromMinutes(_faker.Random.Int(0, 1440));
return Optional<DateTime>.Some(DateTime.MaxValue - createdOnUtc < offsetFromCreation
? DateTime.MaxValue
: createdOnUtc.Add(offsetFromCreation));
}
}
@@ -0,0 +1,37 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.FavoriteBoundedContext.FavoriteAggregate.ValueObjects;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.FavoriteBoundedContext.FavoriteAggregate.ValueObjects;
/// <summary>
/// Fixture class for the <see cref="FavoriteId"/> value object.
/// </summary>
[ExcludeFromCodeCoverage]
public class FavoriteIdFixture
{
/// <summary>
/// Creates a random valid <see cref="FavoriteId"/>.
/// </summary>
/// <param name="value">Optional. The raw value of the favorite Id.</param>
/// <returns>The created <see cref="FavoriteId"/>.</returns>
public FavoriteId Create(
Guid? value = null)
{
return FavoriteId.Create(value ?? Guid.NewGuid());
}
/// <summary>
/// Creates a list of <see cref="FavoriteId"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="FavoriteId"/> instances.</returns>
public List<FavoriteId> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,104 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
/// <summary>
/// Fixture class for the <see cref="Directory"/> entity.
/// </summary>
[ExcludeFromCodeCoverage]
public class DirectoryFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="Directory"/>.
/// </summary>
/// <param name="path">Optional. The directory path. If not provided, a random path is generated.</param>
/// <param name="name">Optional. The directory name. If not provided, a random name is generated.</param>
/// <param name="dateCreated">Optional. The directory's creation date. If not provided, a random past date is generated.</param>
/// <param name="dateModified">Optional. The directory's modification date. If not provided, a recent date is generated.</param>
/// <param name="status">Optional. The directory's status. If not provided, a random status is assigned.</param>
/// <param name="isHidden">Optional. Whether the directory is hidden. If not provided, a random value is generated.</param>
/// <param name="childItems">Optional. A list of child items to be added to the directory.</param>
/// <returns>A newly created <see cref="Directory"/> instance.</returns>
/// <exception cref="InvalidOperationException">Thrown if the <see cref="Directory"/> creation fails.</exception>
public Directory Create(
string? path = null,
string? name = null,
Optional<DateTime>? dateCreated = null,
Optional<DateTime>? dateModified = null,
FileSystemItemStatus? status = null,
bool? isHidden = null,
List<FileSystemItem>? childItems = null)
{
path ??= _faker.System.FilePath();
name ??= _faker.System.FileName();
dateCreated ??= Optional<DateTime>.Some(_faker.Date.Past());
dateModified ??= Optional<DateTime>.Some(_faker.Date.Recent());
status ??= _faker.PickRandom<FileSystemItemStatus>();
isHidden ??= _faker.Random.Bool();
Result<Directory> directoryResult = Directory.Create(path, name, dateCreated.Value, dateModified.Value, status.Value, isHidden.Value);
if (directoryResult.IsFailure)
throw new InvalidOperationException("Failed to create Directory: " + string.Join(", ", directoryResult.Errors));
Directory directory = directoryResult.Value;
if (childItems != null)
foreach (FileSystemItem item in childItems)
directory.AddItem(item);
return directory;
}
/// <summary>
/// Creates a list of <see cref="Directory"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<Directory> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
/// <summary>
/// Creates a list of nested <see cref="Directory"/> objects with a hierarchical structure.
/// </summary>
/// <param name="count">The number of top-level directories to create. Default is 3.</param>
/// <param name="maxDepth">The maximum depth of the directory hierarchy. Default is 3.</param>
/// <param name="maxChildrenPerDirectory">The maximum number of child items (files or directories) per directory. Default is 3.</param>
/// <returns>A list of <see cref="Directory"/> objects with nested structures.</returns>
public List<Directory> CreateManyNested(int count = 3, int maxDepth = 3, int maxChildrenPerDirectory = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => CreateNestedDirectory(1, maxDepth, maxChildrenPerDirectory))];
}
/// <summary>
/// Recursively creates a nested <see cref="Directory"/> structure.
/// </summary>
/// <param name="currentDepth">The current depth in the directory hierarchy.</param>
/// <param name="maxDepth">The maximum allowed depth for the directory hierarchy.</param>
/// <param name="maxChildrenPerDirectory">The maximum number of child items (files or directories) allowed per directory.</param>
/// <returns>A <see cref="Directory"/> object that may contain nested directories and files.</returns>
private Directory CreateNestedDirectory(int currentDepth, int maxDepth, int maxChildrenPerDirectory)
{
List<FileSystemItem> childItems = [];
if (currentDepth < maxDepth)
{
int childCount = _faker.Random.Int(0, maxChildrenPerDirectory);
for (int i = 0; i < childCount; i++)
childItems.Add(CreateNestedDirectory(currentDepth + 1, maxDepth, maxChildrenPerDirectory));
}
return Create(childItems: childItems);
}
}
@@ -0,0 +1,68 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
/// <summary>
/// Fixture class for the <see cref="File"/> entity.
/// </summary>
[ExcludeFromCodeCoverage]
public class FileFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="File"/>.
/// </summary>
/// <param name="path">Optional. The file path. If not provided, a random path is generated.</param>
/// <param name="name">Optional. The file name. If not provided, a random name is generated.</param>
/// <param name="dateCreated">Optional. The file's creation date. If not provided, a random past date is generated.</param>
/// <param name="dateModified">Optional. The file's modification date. If not provided, a recent date is generated.</param>
/// <param name="size">Optional. The file size. If not provided, a random size is generated.</param>
/// <param name="status">Optional. The file's status. If not provided, a random status is assigned.</param>
/// <param name="isHidden">Optional. Whether the file is hidden. If not provided, a random value is generated.</param>
/// <param name="includeDates">Whether the creation and modification dates should be included, or left unset.</param>
/// <returns>The created <see cref="File"/>.</returns>
public File Create(
string? path = null,
string? name = null,
Optional<DateTime>? dateCreated = null,
Optional<DateTime>? dateModified = null,
long? size = null,
FileSystemItemStatus? status = null,
bool? isHidden = null,
bool includeDates = true)
{
path ??= _faker.System.FilePath();
name ??= _faker.System.FileName();
dateCreated ??= includeDates ? Optional<DateTime>.Some(_faker.Date.Past()) : Optional<DateTime>.None();
dateModified ??= includeDates ? Optional<DateTime>.Some(_faker.Date.Recent()) : Optional<DateTime>.None();
size ??= _faker.Random.Long();
status ??= _faker.PickRandom<FileSystemItemStatus>();
isHidden ??= _faker.Random.Bool();
Result<File> fileResult = File.Create(path, name, dateCreated.Value, dateModified.Value, size.Value, status.Value, isHidden.Value);
if (fileResult.IsFailure)
throw new InvalidOperationException("Failed to create File: " + string.Join(", ", fileResult.Errors));
return fileResult.Value;
}
/// <summary>
/// Creates a list of <see cref="File"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<File> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,46 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
/// <summary>
/// Fixture class for the <see cref="UnixRootItem"/> entity.
/// </summary>
[ExcludeFromCodeCoverage]
public class UnixRootItemFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="UnixRootItem"/>.
/// </summary>
/// <param name="status">Optional. The root item status.</param>
/// <returns>The created <see cref="UnixRootItem"/>.</returns>
public UnixRootItem Create(FileSystemItemStatus? status = null)
{
Result<UnixRootItem> unixRootItemResult = UnixRootItem.Create(
status ?? _faker.PickRandom<FileSystemItemStatus>()
);
if (unixRootItemResult.IsFailure)
throw new InvalidOperationException("Failed to create UnixRootItem: " + string.Join(", ", unixRootItemResult.Errors));
return unixRootItemResult.Value;
}
/// <summary>
/// Creates a list of <see cref="UnixRootItem"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<UnixRootItem> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,53 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Entities;
/// <summary>
/// Fixture class for the <see cref="WindowsRootItem"/> entity.
/// </summary>
[ExcludeFromCodeCoverage]
public class WindowsRootItemFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="WindowsRootItem"/>.
/// </summary>
/// <param name="path">Optional. The root item path.</param>
/// <param name="name">Optional. The root item name.</param>
/// <param name="status">Optional. The root item status.</param>
/// <returns>The created <see cref="WindowsRootItem"/>.</returns>
public WindowsRootItem Create(
string? path = null,
string? name = null,
FileSystemItemStatus? status = null)
{
Result<WindowsRootItem> windowsRootItemResult = WindowsRootItem.Create(
path ?? _faker.System.FilePath(),
name ?? _faker.System.FileName(),
status ?? _faker.PickRandom<FileSystemItemStatus>()
);
if (windowsRootItemResult.IsFailure)
throw new InvalidOperationException("Failed to create WindowsRootItem: " + string.Join(", ", windowsRootItemResult.Errors));
return windowsRootItemResult.Value;
}
/// <summary>
/// Creates a list of <see cref="WindowsRootItem"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<WindowsRootItem> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,26 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate;
/// <summary>
/// Test-support class that allows the abstract <see cref="FileSystemItem"/> type to be instantiated in tests.
/// </summary>
[ExcludeFromCodeCoverage]
public class FileSystemItemFixture : FileSystemItem
{
/// <summary>
/// Initializes a new instance of the <see cref="FileSystemItemFixture"/> class.
/// </summary>
/// <param name="id">The unique identifier for the file system path.</param>
/// <param name="name">The name of the file system item.</param>
/// <param name="fileSystemItemType">The type of the file system item.</param>
public FileSystemItemFixture(FileSystemPathId id, string name, FileSystemItemType fileSystemItemType)
: base(id, name, fileSystemItemType)
{
}
}
@@ -0,0 +1,12 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Platform;
/// <summary>
/// Fixture interface for non existing platform context.
/// </summary>
public interface INonExistentPlatformContextFixture : IPlatformContext
{
}
@@ -0,0 +1,46 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
/// <summary>
/// Fixture class for the <see cref="FileSystemPathId"/> value object.
/// </summary>
[ExcludeFromCodeCoverage]
public class FileSystemPathIdFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="FileSystemPathId"/>.
/// </summary>
/// <param name="path">Optional. The path of the file system path element.</param>
/// <returns>The created <see cref="FileSystemPathId"/>.</returns>
public FileSystemPathId Create(string? path = null)
{
path ??= _faker.System.FilePath();
Result<FileSystemPathId> fileSystemPathIdResult = FileSystemPathId.Create(path);
if (fileSystemPathIdResult.IsFailure)
throw new InvalidOperationException("Failed to create FileSystemPathId: " + string.Join(", ", fileSystemPathIdResult.Errors));
return fileSystemPathIdResult.Value;
}
/// <summary>
/// Creates a list of <see cref="FileSystemPathId"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<FileSystemPathId> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,53 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
/// <summary>
/// Fixture class for the <see cref="PathSegment"/> value object.
/// </summary>
[ExcludeFromCodeCoverage]
public class PathSegmentFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="PathSegment"/>.
/// </summary>
/// <param name="name">Optional. The segment name.</param>
/// <param name="isDirectory">Whether the segment is a directory.</param>
/// <param name="isDrive">Whether the segment is a drive.</param>
/// <returns>The created <see cref="PathSegment"/>.</returns>
public PathSegment Create(
string? name = null,
bool? isDirectory = null,
bool? isDrive = null)
{
name ??= _faker.System.FileName();
isDirectory ??= true;
isDrive ??= false;
Result<PathSegment> pathResult = PathSegment.Create(name, isDirectory.Value, isDrive.Value);
if (pathResult.IsFailure)
throw new InvalidOperationException("Failed to create PathSegment: " + string.Join(", ", pathResult.Errors));
return pathResult.Value;
}
/// <summary>
/// Creates a list of <see cref="PathSegment"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<PathSegment> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,69 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
/// <summary>
/// Fixture class for the <see cref="StreamInfo"/> value object.
/// </summary>
[ExcludeFromCodeCoverage]
public class StreamInfoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="StreamInfo"/>.
/// </summary>
/// <param name="streamId">Optional. The unique identifier for the stream.</param>
/// <param name="mimeType">Optional. The MIME type of the stream.</param>
/// <param name="bitrate">Optional. The bitrate of the stream in kbps.</param>
/// <param name="codec">Optional. The codec used for the stream.</param>
/// <param name="resolution">Optional. The video resolution.</param>
/// <param name="frameRate">Optional. The frame rate of the video stream.</param>
/// <param name="sampleRate">Optional. The sample rate of the audio stream.</param>
/// <param name="channels">Optional. The number of audio channels.</param>
/// <returns>The created <see cref="StreamInfo"/>.</returns>
public StreamInfo Create(
string? streamId = null,
string? mimeType = null,
int? bitrate = null,
string? codec = null,
Optional<string>? resolution = null,
Optional<float>? frameRate = null,
Optional<int>? sampleRate = null,
Optional<int>? channels = null)
{
streamId ??= _faker.Random.AlphaNumeric(10);
mimeType ??= _faker.System.MimeType();
bitrate ??= _faker.Random.Number(1, 10000);
codec ??= _faker.Random.Word();
resolution ??= Optional<string>.FromNullable(_faker.Random.Bool() ? $"{_faker.Random.Number(100, 4000)}x{_faker.Random.Number(100, 4000)}" : null);
frameRate ??= Optional<float>.FromNullable(_faker.Random.Bool() ? (float?)_faker.Random.Float(1, 120) : null);
sampleRate ??= Optional<int>.FromNullable(_faker.Random.Bool() ? (int?)_faker.Random.Number(8000, 192000) : null);
channels ??= Optional<int>.FromNullable(_faker.Random.Bool() ? (int?)_faker.Random.Number(1, 8) : null);
Result<StreamInfo> streamInfoResult = StreamInfo.Create(
streamId, mimeType, bitrate.Value, codec, resolution.Value, frameRate.Value, sampleRate.Value, channels.Value);
if (streamInfoResult.IsFailure)
throw new InvalidOperationException("Failed to create StreamInfo: " + string.Join(", ", streamInfoResult.Errors));
return streamInfoResult.Value;
}
/// <summary>
/// Creates a list of <see cref="StreamInfo"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<StreamInfo> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,43 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
using Lumina.Domain.SharedKernel.Common.Enums.PhotoLibrary;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
/// <summary>
/// Fixture class for the <see cref="Thumbnail"/> value object.
/// </summary>
[ExcludeFromCodeCoverage]
public class ThumbnailFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="Thumbnail"/>.
/// </summary>
/// <param name="type">Optional. The <see cref="ImageType"/> of the thumbnail. If not provided, a random image type is selected.</param>
/// <param name="bytes">Optional. The byte array representing the image data. If not provided, a random 1KB byte array is generated.</param>
/// <returns>A newly created <see cref="Thumbnail"/> instance.</returns>
public Thumbnail Create(ImageType? type = null, byte[]? bytes = null)
{
type ??= _faker.PickRandom<ImageType>();
bytes ??= _faker.Random.Bytes(1024); // Generate 1KB of random bytes.
return new Thumbnail(type.Value, bytes);
}
/// <summary>
/// Creates a list of <see cref="Thumbnail"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<Thumbnail> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,33 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.Events;
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.Events;
/// <summary>
/// Fixture class for the <see cref="LibraryDeletedDomainEvent"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class LibraryDeletedDomainEventFixture
{
private readonly LibraryFixture _libraryFixture = new();
/// <summary>
/// Creates a random valid <see cref="LibraryDeletedDomainEvent"/>.
/// </summary>
/// <param name="id">Optional. The Id of the domain event.</param>
/// <param name="library">Optional. The library that was deleted.</param>
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
/// <returns>The created <see cref="LibraryDeletedDomainEvent"/>.</returns>
public LibraryDeletedDomainEvent Create(Guid? id = null, Library? library = null, DateTime? occurredOnUtc = null)
{
return new LibraryDeletedDomainEvent(
id ?? Guid.NewGuid(),
library ?? _libraryFixture.Create(),
occurredOnUtc ?? DateTime.UtcNow);
}
}
@@ -0,0 +1,33 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.Events;
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.Events;
/// <summary>
/// Fixture class for the <see cref="LibrarySavedDomainEvent"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class LibrarySavedDomainEventFixture
{
private readonly LibraryFixture _libraryFixture = new();
/// <summary>
/// Creates a random valid <see cref="LibrarySavedDomainEvent"/>.
/// </summary>
/// <param name="id">Optional. The Id of the domain event.</param>
/// <param name="library">Optional. The library that was created or updated.</param>
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
/// <returns>The created <see cref="LibrarySavedDomainEvent"/>.</returns>
public LibrarySavedDomainEvent Create(Guid? id = null, Library? library = null, DateTime? occurredOnUtc = null)
{
return new LibrarySavedDomainEvent(
id ?? Guid.NewGuid(),
library ?? _libraryFixture.Create(),
occurredOnUtc ?? DateTime.UtcNow);
}
}
@@ -0,0 +1,135 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
/// <summary>
/// Fixture class for the <see cref="Library"/> domain aggregate.
/// </summary>
[ExcludeFromCodeCoverage]
public class LibraryFixture
{
private readonly Faker _faker = new();
private readonly LibraryIdFixture _libraryIdFixture = new();
private readonly UserIdFixture _userIdFixture = new();
private readonly ScanIdFixture _scanIdFixture = new();
private readonly LibraryConsumptionSettingsFixture _libraryConsumptionSettingsFixture = new();
/// <summary>
/// Creates a random valid <see cref="Library"/> domain aggregate.
/// </summary>
/// <param name="id">Optional. The library Id.</param>
/// <param name="userId">Optional. The Id of the user that owns the library.</param>
/// <param name="title">Optional. The library title.</param>
/// <param name="libraryType">Optional. The library type.</param>
/// <param name="contentLocations">Optional. The content locations of the library.</param>
/// <param name="coverImage">Optional. The cover image of the library.</param>
/// <param name="isEnabled">Whether the library is enabled.</param>
/// <param name="isLocked">Whether the library is locked.</param>
/// <param name="canDownloadMetadataFromWeb">Whether metadata download from the web is enabled.</param>
/// <param name="shouldSaveMetadataInMediaDirectories">Whether metadata should be saved in the media directories.</param>
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Whether unchanged directories should be skipped during scan.</param>
/// <param name="shouldSkipHiddenFilesAndDirectoriesDuringScan">Whether hidden files and directories should be skipped during scan.</param>
/// <param name="isContentOnSsd">Whether the content of the library is stored on a solid state drive.</param>
/// <param name="consumptionSettings">Optional. The consumption settings of the library.</param>
/// <param name="scanIds">Optional. The scan Ids associated with the library.</param>
/// <param name="pathTemplate">Optional. The path template of the library.</param>
/// <param name="includeCoverImage">Whether the cover image should be included, or left unset, meaning the library has no cover.</param>
/// <returns>The created <see cref="Library"/>.</returns>
public Library Create(
Guid? id = null,
Guid? userId = null,
string? title = null,
LibraryType? libraryType = null,
IEnumerable<string>? contentLocations = null,
string? coverImage = null,
bool isEnabled = true,
bool isLocked = false,
bool canDownloadMetadataFromWeb = true,
bool shouldSaveMetadataInMediaDirectories = false,
bool shouldSkipUnchangedDirectoriesDuringScan = false,
bool shouldSkipHiddenFilesAndDirectoriesDuringScan = false,
bool isContentOnSsd = false,
LibraryConsumptionSettings? consumptionSettings = null,
IEnumerable<Guid>? scanIds = null,
LibraryPathTemplate? pathTemplate = null,
bool includeCoverImage = true)
{
List<string> validPaths =
[
"C:/Media",
"D:/Books",
"E:/Digital Library",
"F:/Content"
];
UserId resolvedUserId = userId is null ? _userIdFixture.Create() : _userIdFixture.Create(userId.Value);
LibraryType resolvedLibraryType = libraryType ?? _faker.PickRandom<LibraryType>();
LibraryConsumptionSettings resolvedConsumptionSettings = consumptionSettings ?? _libraryConsumptionSettingsFixture.Create(resolvedLibraryType);
List<ScanId> resolvedScanIds = scanIds is null ? [.. _scanIdFixture.CreateMany(2)] : [.. scanIds.Select(scanId => _scanIdFixture.Create(scanId))];
string? resolvedCoverImage = includeCoverImage ? (coverImage ?? _faker.System.FilePath()) : null;
Result<Library> library = id is null ?
Library.Create(
resolvedUserId,
title ?? _faker.Random.String2(_faker.Random.Number(1, 50)),
resolvedLibraryType,
contentLocations ?? validPaths.Take(Random.Shared.Next(1, validPaths.Count)),
Optional<string>.FromNullable(resolvedCoverImage),
isEnabled,
isLocked,
canDownloadMetadataFromWeb,
shouldSaveMetadataInMediaDirectories,
shouldSkipUnchangedDirectoriesDuringScan,
shouldSkipHiddenFilesAndDirectoriesDuringScan,
isContentOnSsd,
resolvedConsumptionSettings,
pathTemplate ?? LibraryPathTemplate.Empty(),
resolvedScanIds
) :
Library.Create(
_libraryIdFixture.Create(id.Value),
resolvedUserId,
title ?? _faker.Random.String2(_faker.Random.Number(1, 50)),
resolvedLibraryType,
contentLocations ?? validPaths.Take(Random.Shared.Next(1, validPaths.Count)),
Optional<string>.FromNullable(resolvedCoverImage),
isEnabled,
isLocked,
canDownloadMetadataFromWeb,
shouldSaveMetadataInMediaDirectories,
shouldSkipUnchangedDirectoriesDuringScan,
shouldSkipHiddenFilesAndDirectoriesDuringScan,
isContentOnSsd,
resolvedConsumptionSettings,
pathTemplate ?? LibraryPathTemplate.Empty(),
resolvedScanIds
);
return library.Value;
}
/// <summary>
/// Creates multiple <see cref="Library"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="Library"/> instances.</returns>
public List<Library> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,59 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
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.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
/// <summary>
/// Fixture class for the <see cref="LibraryConsumptionSettings"/> domain value object.
/// </summary>
[ExcludeFromCodeCoverage]
public class LibraryConsumptionSettingsFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a valid <see cref="LibraryConsumptionSettings"/>.
/// </summary>
/// <param name="shouldTrackConsumptionProgress">Optional. Whether the consumption progress is tracked. A random value is used when absent.</param>
/// <param name="completionThresholdPercentage">Optional. The completion threshold percentage. A random value is used when absent and the threshold is included.</param>
/// <param name="includeCompletionThreshold">Whether the completion threshold should be included. When <see langword="false"/>, no threshold is set.</param>
/// <returns>The created consumption settings.</returns>
public LibraryConsumptionSettings Create(
bool? shouldTrackConsumptionProgress = null,
int? completionThresholdPercentage = null,
bool includeCompletionThreshold = true)
{
bool resolvedShouldTrackConsumptionProgress = shouldTrackConsumptionProgress ?? _faker.Random.Bool();
Optional<int> resolvedCompletionThresholdPercentage = includeCompletionThreshold
? Optional<int>.FromNullable(completionThresholdPercentage ?? _faker.Random.Int(0, 100))
: Optional<int>.None();
return LibraryConsumptionSettings.Create(resolvedShouldTrackConsumptionProgress, resolvedCompletionThresholdPercentage);
}
/// <summary>
/// Creates the default <see cref="LibraryConsumptionSettings"/> for <paramref name="libraryType"/>.
/// </summary>
/// <param name="libraryType">The type of the media library for which to create the default consumption settings.</param>
/// <returns>The default consumption settings of the media library type.</returns>
public LibraryConsumptionSettings Create(LibraryType libraryType)
{
return LibraryConsumptionSettings.CreateDefault(libraryType);
}
/// <summary>
/// Creates multiple <see cref="LibraryConsumptionSettings"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="LibraryConsumptionSettings"/> instances.</returns>
public List<LibraryConsumptionSettings> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,36 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
/// <summary>
/// Fixture class for the <see cref="LibraryId"/> 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 LibraryId.Create(value ?? Guid.NewGuid());
}
/// <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())];
}
}
@@ -0,0 +1,68 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
/// <summary>
/// Fixture class for the <see cref="LibraryPathPart"/> domain value object.
/// </summary>
[ExcludeFromCodeCoverage]
public class LibraryPathPartFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="LibraryPathPart"/>.
/// </summary>
/// <param name="kind">Optional. The kind of the path part.</param>
/// <param name="representation">Optional. The literal text or the value mask of the path part. When omitted, a representation valid for the resolved kind is generated.</param>
/// <param name="isOptional">Whether the path part can be absent from the path.</param>
/// <returns>The created <see cref="LibraryPathPart"/>.</returns>
public LibraryPathPart Create(
LibraryPathPartKind? kind = null,
string? representation = null,
bool isOptional = false)
{
LibraryPathPartKind resolvedKind = kind ?? _faker.PickRandom<LibraryPathPartKind>();
string resolvedRepresentation = representation ?? CreateValidRepresentation(resolvedKind);
Result<LibraryPathPart> partResult = LibraryPathPart.Create(resolvedKind, resolvedRepresentation, isOptional);
if (partResult.IsFailure)
throw new InvalidOperationException("Failed to create LibraryPathPart: " + string.Join(", ", partResult.Errors));
return partResult.Value;
}
/// <summary>
/// Creates multiple <see cref="LibraryPathPart"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="LibraryPathPart"/> instances.</returns>
public List<LibraryPathPart> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
/// <summary>
/// Creates a representation that is valid for the provided <paramref name="kind"/>.
/// </summary>
/// <param name="kind">The kind of the path part a representation is created for.</param>
/// <returns>The created representation.</returns>
private string CreateValidRepresentation(LibraryPathPartKind kind)
{
// A separator renders the platform path separator, so it never carries a representation.
if (kind == LibraryPathPartKind.Separator)
return string.Empty;
// A literal is arbitrary on-disk text between value parts, so it carries no value placeholder.
if (kind == LibraryPathPartKind.Literal)
return _faker.Lorem.Word();
// A typed part must carry exactly one value placeholder, so that the position of the captured value is unambiguous.
return "{0}";
}
}
@@ -0,0 +1,44 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
/// <summary>
/// Fixture class for the <see cref="LibraryPathTemplate"/> domain value object.
/// </summary>
[ExcludeFromCodeCoverage]
public class LibraryPathTemplateFixture
{
private readonly Faker _faker = new();
private readonly LibraryPathPartFixture _libraryPathPartFixture = new();
/// <summary>
/// Creates a random valid <see cref="LibraryPathTemplate"/>.
/// </summary>
/// <param name="parts">Optional. The ordered parts that make up the path template.</param>
/// <param name="includeParts">Whether the template should carry parts. When <see langword="false"/>, an empty template is created.</param>
/// <returns>The created <see cref="LibraryPathTemplate"/>.</returns>
public LibraryPathTemplate Create(
IEnumerable<LibraryPathPart>? parts = null,
bool includeParts = true)
{
if (!includeParts)
return LibraryPathTemplate.Empty();
return LibraryPathTemplate.Create(parts ?? _libraryPathPartFixture.CreateMany(_faker.Random.Int(1, 4)));
}
/// <summary>
/// Creates multiple <see cref="LibraryPathTemplate"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="LibraryPathTemplate"/> instances.</returns>
public List<LibraryPathTemplate> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,47 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
/// <summary>
/// Fixture class for the <see cref="LibraryMediaItemDeletedDomainEvent"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class LibraryMediaItemDeletedDomainEventFixture
{
private readonly Faker _faker = new();
private readonly LibraryIdFixture _libraryIdFixture = new();
private readonly MediaLibraryScanCompositeIdFixture _mediaLibraryScanCompositeIdFixture = new();
/// <summary>
/// Creates a random valid <see cref="LibraryMediaItemDeletedDomainEvent"/>.
/// </summary>
/// <param name="id">Optional. The Id of the domain event.</param>
/// <param name="libraryId">Optional. The unique identifier of the library to which the deleted media library item belonged.</param>
/// <param name="mediaLibraryScanCompositeId">Optional. The composite identifier of the media library scan during which the item deletion was detected.</param>
/// <param name="path">Optional. The path of the media library item that was deleted.</param>
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
/// <returns>The created <see cref="LibraryMediaItemDeletedDomainEvent"/>.</returns>
public LibraryMediaItemDeletedDomainEvent Create(
Guid? id = null,
LibraryId? libraryId = null,
MediaLibraryScanCompositeId? mediaLibraryScanCompositeId = null,
string? path = null,
DateTime? occurredOnUtc = null)
{
return new LibraryMediaItemDeletedDomainEvent(
id ?? Guid.NewGuid(),
libraryId ?? _libraryIdFixture.Create(),
mediaLibraryScanCompositeId ?? _mediaLibraryScanCompositeIdFixture.Create(),
path ?? _faker.System.FilePath(),
occurredOnUtc ?? DateTime.UtcNow);
}
}
@@ -0,0 +1,42 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
/// <summary>
/// Fixture class for the <see cref="LibraryScanCancelledDomainEvent"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class LibraryScanCancelledDomainEventFixture
{
private readonly ScanIdFixture _scanIdFixture = new();
private readonly LibraryIdFixture _libraryIdFixture = new();
/// <summary>
/// Creates a random valid <see cref="LibraryScanCancelledDomainEvent"/>.
/// </summary>
/// <param name="id">Optional. The Id of the domain event.</param>
/// <param name="scanId">Optional. The unique identifier of the cancelled media library scan.</param>
/// <param name="libraryId">Optional. The unique identifier of the library whose scan was cancelled.</param>
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
/// <returns>The created <see cref="LibraryScanCancelledDomainEvent"/>.</returns>
public LibraryScanCancelledDomainEvent Create(
Guid? id = null,
ScanId? scanId = null,
LibraryId? libraryId = null,
DateTime? occurredOnUtc = null)
{
return new LibraryScanCancelledDomainEvent(
id ?? Guid.NewGuid(),
scanId ?? _scanIdFixture.Create(),
libraryId ?? _libraryIdFixture.Create(),
occurredOnUtc ?? DateTime.UtcNow);
}
}
@@ -0,0 +1,50 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
/// <summary>
/// Fixture class for the <see cref="LibraryScanFailedDomainEvent"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class LibraryScanFailedDomainEventFixture
{
private readonly Faker _faker = new();
private readonly LibraryIdFixture _libraryIdFixture = new();
private readonly MediaLibraryScanCompositeIdFixture _mediaLibraryScanCompositeIdFixture = new();
/// <summary>
/// Creates a random valid <see cref="LibraryScanFailedDomainEvent"/>.
/// </summary>
/// <param name="id">Optional. The Id of the domain event.</param>
/// <param name="libraryId">Optional. The unique identifier of the library whose scan has failed.</param>
/// <param name="mediaLibraryScanCompositeId">Optional. The composite identifier of the media library scan that has failed.</param>
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
/// <param name="errorMessage">Optional. The descriptive message of the failure.</param>
/// <param name="includeErrorMessage">Whether the error message should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="LibraryScanFailedDomainEvent"/>.</returns>
public LibraryScanFailedDomainEvent Create(
Guid? id = null,
LibraryId? libraryId = null,
MediaLibraryScanCompositeId? mediaLibraryScanCompositeId = null,
DateTime? occurredOnUtc = null,
string? errorMessage = null,
bool includeErrorMessage = true)
{
return new LibraryScanFailedDomainEvent(
id ?? Guid.NewGuid(),
libraryId ?? _libraryIdFixture.Create(),
mediaLibraryScanCompositeId ?? _mediaLibraryScanCompositeIdFixture.Create(),
occurredOnUtc ?? DateTime.UtcNow,
Optional<string>.FromNullable(includeErrorMessage ? (errorMessage ?? _faker.Random.Words()) : null));
}
}
@@ -0,0 +1,36 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
/// <summary>
/// Fixture class for the <see cref="LibraryScanFinishedDomainEvent"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class LibraryScanFinishedDomainEventFixture
{
private readonly MediaLibraryScanCompositeIdFixture _mediaLibraryScanCompositeIdFixture = new();
/// <summary>
/// Creates a random valid <see cref="LibraryScanFinishedDomainEvent"/>.
/// </summary>
/// <param name="id">Optional. The Id of the domain event.</param>
/// <param name="mediaLibraryScanCompositeId">Optional. The composite identifier of the media library scan that was finished.</param>
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
/// <returns>The created <see cref="LibraryScanFinishedDomainEvent"/>.</returns>
public LibraryScanFinishedDomainEvent Create(
Guid? id = null,
MediaLibraryScanCompositeId? mediaLibraryScanCompositeId = null,
DateTime? occurredOnUtc = null)
{
return new LibraryScanFinishedDomainEvent(
id ?? Guid.NewGuid(),
mediaLibraryScanCompositeId ?? _mediaLibraryScanCompositeIdFixture.Create(),
occurredOnUtc ?? DateTime.UtcNow);
}
}
@@ -0,0 +1,46 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
/// <summary>
/// Fixture class for the <see cref="LibraryScanJobProgressChangedDomainEvent"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class LibraryScanJobProgressChangedDomainEventFixture
{
private readonly LibraryIdFixture _libraryIdFixture = new();
private readonly MediaLibraryScanCompositeIdFixture _mediaLibraryScanCompositeIdFixture = new();
private readonly MediaLibraryScanJobProgressFixture _mediaLibraryScanJobProgressFixture = new();
/// <summary>
/// Creates a random valid <see cref="LibraryScanJobProgressChangedDomainEvent"/>.
/// </summary>
/// <param name="id">Optional. The Id of the domain event.</param>
/// <param name="libraryId">Optional. The unique identifier of the library being scanned.</param>
/// <param name="mediaLibraryScanCompositeId">Optional. The composite identifier of the media library scan whose job progress changed.</param>
/// <param name="progress">Optional. The new media library scan job progress.</param>
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
/// <returns>The created <see cref="LibraryScanJobProgressChangedDomainEvent"/>.</returns>
public LibraryScanJobProgressChangedDomainEvent Create(
Guid? id = null,
LibraryId? libraryId = null,
MediaLibraryScanCompositeId? mediaLibraryScanCompositeId = null,
MediaLibraryScanJobProgress? progress = null,
DateTime? occurredOnUtc = null)
{
return new LibraryScanJobProgressChangedDomainEvent(
id ?? Guid.NewGuid(),
libraryId ?? _libraryIdFixture.Create(),
mediaLibraryScanCompositeId ?? _mediaLibraryScanCompositeIdFixture.Create(),
progress ?? _mediaLibraryScanJobProgressFixture.Create(),
occurredOnUtc ?? DateTime.UtcNow);
}
}
@@ -0,0 +1,42 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
/// <summary>
/// Fixture class for the <see cref="LibraryScanProgressChangedDomainEvent"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class LibraryScanProgressChangedDomainEventFixture
{
private readonly LibraryIdFixture _libraryIdFixture = new();
private readonly MediaLibraryScanCompositeIdFixture _mediaLibraryScanCompositeIdFixture = new();
/// <summary>
/// Creates a random valid <see cref="LibraryScanProgressChangedDomainEvent"/>.
/// </summary>
/// <param name="id">Optional. The Id of the domain event.</param>
/// <param name="libraryId">Optional. The unique identifier of the library being scanned.</param>
/// <param name="mediaLibraryScanCompositeId">Optional. The composite identifier of the media library scan whose progress changed.</param>
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
/// <returns>The created <see cref="LibraryScanProgressChangedDomainEvent"/>.</returns>
public LibraryScanProgressChangedDomainEvent Create(
Guid? id = null,
LibraryId? libraryId = null,
MediaLibraryScanCompositeId? mediaLibraryScanCompositeId = null,
DateTime? occurredOnUtc = null)
{
return new LibraryScanProgressChangedDomainEvent(
id ?? Guid.NewGuid(),
libraryId ?? _libraryIdFixture.Create(),
mediaLibraryScanCompositeId ?? _mediaLibraryScanCompositeIdFixture.Create(),
occurredOnUtc ?? DateTime.UtcNow);
}
}
@@ -0,0 +1,48 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
/// <summary>
/// Fixture class for the <see cref="LibraryScanQueuedDomainEvent"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class LibraryScanQueuedDomainEventFixture
{
private readonly ScanIdFixture _scanIdFixture = new();
private readonly UserIdFixture _userIdFixture = new();
private readonly LibraryIdFixture _libraryIdFixture = new();
/// <summary>
/// Creates a random valid <see cref="LibraryScanQueuedDomainEvent"/>.
/// </summary>
/// <param name="id">Optional. The Id of the domain event.</param>
/// <param name="scanId">Optional. The unique identifier of the queued media library scan.</param>
/// <param name="userId">Optional. The unique identifier of the user that initiated the queued media library scan.</param>
/// <param name="libraryId">Optional. The unique identifier of the library whose scan was queued.</param>
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
/// <returns>The created <see cref="LibraryScanQueuedDomainEvent"/>.</returns>
public LibraryScanQueuedDomainEvent Create(
Guid? id = null,
ScanId? scanId = null,
UserId? userId = null,
LibraryId? libraryId = null,
DateTime? occurredOnUtc = null)
{
return new LibraryScanQueuedDomainEvent(
id ?? Guid.NewGuid(),
scanId ?? _scanIdFixture.Create(),
userId ?? _userIdFixture.Create(),
libraryId ?? _libraryIdFixture.Create(),
occurredOnUtc ?? DateTime.UtcNow);
}
}
@@ -0,0 +1,33 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
/// <summary>
/// Fixture class for the <see cref="LibraryScanStartedDomainEvent"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class LibraryScanStartedDomainEventFixture
{
private readonly LibraryScanFixture _libraryScanFixture = new();
/// <summary>
/// Creates a random valid <see cref="LibraryScanStartedDomainEvent"/>.
/// </summary>
/// <param name="id">Optional. The Id of the domain event.</param>
/// <param name="libraryScan">Optional. The library scan that was started.</param>
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
/// <returns>The created <see cref="LibraryScanStartedDomainEvent"/>.</returns>
public LibraryScanStartedDomainEvent Create(Guid? id = null, LibraryScan? libraryScan = null, DateTime? occurredOnUtc = null)
{
return new LibraryScanStartedDomainEvent(
id ?? Guid.NewGuid(),
libraryScan ?? _libraryScanFixture.Create(),
occurredOnUtc ?? DateTime.UtcNow);
}
}
@@ -0,0 +1,57 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate;
/// <summary>
/// Fixture class for the <see cref="LibraryScan"/> domain aggregate.
/// </summary>
[ExcludeFromCodeCoverage]
public class LibraryScanFixture
{
/// <summary>
/// Creates a random valid <see cref="LibraryScan"/> domain aggregate.
/// </summary>
/// <param name="id">Optional. The scan Id.</param>
/// <param name="libraryId">Optional. The Id of the media library that is scanned.</param>
/// <param name="userId">Optional. The Id of the user that initiated the scan.</param>
/// <param name="status">Optional. The status of the media library scan.</param>
/// <param name="pastScans">Optional. The list of past scans of the scanned media library.</param>
/// <returns>The created <see cref="LibraryScan"/>.</returns>
public LibraryScan Create(
Guid? id = null,
Guid? libraryId = null,
Guid? userId = null,
LibraryScanJobStatus? status = null,
List<LibraryScan>? pastScans = null)
{
Result<LibraryScan> scan = LibraryScan.Create(
ScanId.Create(id ?? Guid.NewGuid()),
LibraryId.Create(libraryId ?? Guid.NewGuid()),
UserId.Create(userId ?? Guid.NewGuid()),
status ?? LibraryScanJobStatus.Pending,
pastScans ?? []);
return scan.Value;
}
/// <summary>
/// Creates multiple <see cref="LibraryScan"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="LibraryScan"/> instances.</returns>
public List<LibraryScan> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,134 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Jobs;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Jobs;
/// <summary>
/// Controllable test double for the <see cref="IMediaLibraryScanDiscoveryJob"/> interface.
/// </summary>
[ExcludeFromCodeCoverage]
public sealed class FakeMediaLibraryScanDiscoveryJob : IMediaLibraryScanDiscoveryJob
{
private readonly TaskCompletionSource _executionStarted = new(TaskCreationOptions.RunContinuationsAsynchronously);
private readonly TaskCompletionSource _executionCompleted = new(TaskCreationOptions.RunContinuationsAsynchronously);
/// <summary>
/// Gets or sets the Id of the media library scan that this job is part of.
/// </summary>
public required ScanId ScanId { get; set; }
/// <summary>
/// Gets or sets the Id of the user that initiated the media library scan that this job is part of.
/// </summary>
public required UserId UserId { get; set; }
/// <summary>
/// Gets or sets the unique identifier of the media library upon which the scan is performed.
/// </summary>
public required LibraryId LibraryId { get; set; }
/// <summary>
/// Gets the list of child media scan jobs that will be triggered when this job's payload completes execution.
/// </summary>
public List<IMediaLibraryScanJob> Children { get; } = [];
/// <summary>
/// Gets the list of parent media scan jobs that will trigger this job when their payload will complete execution.
/// </summary>
public List<IMediaLibraryScanJob> Parents { get; } = [];
/// <summary>
/// Gets the status of the current media library scan job.
/// </summary>
public LibraryScanJobStatus Status { get; private set; } = LibraryScanJobStatus.Pending;
/// <summary>
/// Gets the number of times this job was executed.
/// </summary>
public int ExecutionCount { get; private set; }
/// <summary>
/// Gets a value indicating whether this job is currently executing.
/// </summary>
public bool IsExecuting { get; private set; }
/// <summary>
/// Gets the Id this job was last executed with.
/// </summary>
public Guid? LastExecutionId { get; private set; }
/// <summary>
/// Gets the cancellation token this job was last executed with.
/// </summary>
public CancellationToken LastCancellationToken { get; private set; }
/// <summary>
/// Gets or sets the optional callback invoked while the job executes, allowing a test to block or throw.
/// </summary>
public Func<CancellationToken, Task>? OnExecute { get; set; }
/// <summary>
/// Gets a task that completes as soon as the job starts executing.
/// </summary>
public Task ExecutionStarted => _executionStarted.Task;
/// <summary>
/// Gets a task that completes as soon as the job finishes executing successfully.
/// </summary>
public Task ExecutionCompleted => _executionCompleted.Task;
/// <summary>
/// Adds a media library scan job to the list of child media library scan jobs that will be triggered when this job's payload completes execution.
/// </summary>
/// <param name="job">The child media library scan job to be added.</param>
public void AddChild(IMediaLibraryScanJob job)
{
if (!Children.Contains(job) && !Parents.Contains(job))
Children.Add(job);
}
/// <summary>
/// Adds a media library scan job to the list of parent media library scan jobs that will trigger this job when their payload will complete execution.
/// </summary>
/// <param name="job">The child media library scan job to be added.</param>
public void AddParent(IMediaLibraryScanJob job)
{
if (!Parents.Contains(job) && !Children.Contains(job))
Parents.Add(job);
}
/// <summary>
/// Executes the payload of the media library scan job.
/// </summary>
/// <typeparam name="TInput">The type of the input parameter representing the data to be processed by this payload.</typeparam>
/// <param name="id">The id of the media library scan job.</param>
/// <param name="input">The input data to be processed by this payload.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>A task that represents the asynchronous operation.</returns>
public async Task ExecuteAsync<TInput>(Guid id, TInput input, CancellationToken cancellationToken)
{
ExecutionCount++;
LastExecutionId = id;
LastCancellationToken = cancellationToken;
IsExecuting = true;
Status = LibraryScanJobStatus.Running;
_executionStarted.TrySetResult();
if (OnExecute is not null)
await OnExecute(cancellationToken).ConfigureAwait(false);
Status = LibraryScanJobStatus.Completed;
IsExecuting = false;
_executionCompleted.TrySetResult();
}
}
@@ -0,0 +1,57 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Jobs;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Jobs;
/// <summary>
/// Fixture class for the <see cref="IMediaLibraryScanDiscoveryJob"/> interface.
/// </summary>
[ExcludeFromCodeCoverage]
public class MediaLibraryScanDiscoveryJobFixture
{
private readonly ScanIdFixture _scanIdFixture = new();
private readonly UserIdFixture _userIdFixture = new();
private readonly LibraryIdFixture _libraryIdFixture = new();
/// <summary>
/// Creates a controllable <see cref="FakeMediaLibraryScanDiscoveryJob"/>.
/// </summary>
/// <param name="scanId">Optional. The Id of the media library scan that the job is part of.</param>
/// <param name="userId">Optional. The Id of the user that initiated the media library scan.</param>
/// <param name="libraryId">Optional. The Id of the media library that is scanned.</param>
/// <param name="children">Optional. The child jobs of the created job.</param>
/// <param name="onExecute">Optional. The callback invoked while the job executes.</param>
/// <returns>The created <see cref="FakeMediaLibraryScanDiscoveryJob"/>.</returns>
public FakeMediaLibraryScanDiscoveryJob Create(
ScanId? scanId = null,
UserId? userId = null,
LibraryId? libraryId = null,
List<IMediaLibraryScanJob>? children = null,
Func<CancellationToken, Task>? onExecute = null)
{
FakeMediaLibraryScanDiscoveryJob job = new()
{
ScanId = scanId ?? _scanIdFixture.Create(),
UserId = userId ?? _userIdFixture.Create(),
LibraryId = libraryId ?? _libraryIdFixture.Create(),
OnExecute = onExecute
};
foreach (IMediaLibraryScanJob child in children ?? [])
job.AddChild(child);
return job;
}
}
@@ -0,0 +1,50 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
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.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
/// <summary>
/// Fixture class for the <see cref="LibraryPathPartDefinition"/> domain value object.
/// </summary>
[ExcludeFromCodeCoverage]
public class LibraryPathPartDefinitionFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="LibraryPathPartDefinition"/>.
/// </summary>
/// <param name="kind">Optional. The kind of the described part.</param>
/// <param name="valueType">Optional. The value type captured by the described part.</param>
/// <param name="defaultRepresentation">Optional. The default representation of the described part.</param>
/// <param name="isOptionalByDefault">Whether the described part is optional by default.</param>
/// <returns>The created <see cref="LibraryPathPartDefinition"/>.</returns>
public LibraryPathPartDefinition Create(
LibraryPathPartKind? kind = null,
LibraryPathValueType? valueType = null,
string? defaultRepresentation = null,
bool isOptionalByDefault = false)
{
return new LibraryPathPartDefinition(
kind ?? _faker.PickRandom<LibraryPathPartKind>(),
valueType ?? _faker.PickRandom<LibraryPathValueType>(),
defaultRepresentation ?? "{0}",
isOptionalByDefault);
}
/// <summary>
/// Creates multiple <see cref="LibraryPathPartDefinition"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="LibraryPathPartDefinition"/> instances.</returns>
public List<LibraryPathPartDefinition> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,43 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
/// <summary>
/// Fixture class for the <see cref="MediaLibraryScanCompositeId"/> value object.
/// </summary>
[ExcludeFromCodeCoverage]
public class MediaLibraryScanCompositeIdFixture
{
private readonly ScanIdFixture _scanIdFixture = new();
private readonly UserIdFixture _userIdFixture = new();
/// <summary>
/// Creates a random valid <see cref="MediaLibraryScanCompositeId"/>.
/// </summary>
/// <param name="scanId">Optional. The scan Id of the composite scan identifier.</param>
/// <param name="userId">Optional. The user Id of the composite scan identifier.</param>
/// <returns>The created <see cref="MediaLibraryScanCompositeId"/>.</returns>
public MediaLibraryScanCompositeId Create(ScanId? scanId = null, UserId? userId = null)
{
return MediaLibraryScanCompositeId.Create(
scanId ?? _scanIdFixture.Create(),
userId ?? _userIdFixture.Create());
}
/// <summary>
/// Creates a list of <see cref="MediaLibraryScanCompositeId"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="MediaLibraryScanCompositeId"/> instances.</returns>
public List<MediaLibraryScanCompositeId> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,49 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
/// <summary>
/// Fixture class for the <see cref="MediaLibraryScanJobProgress"/> value object.
/// </summary>
[ExcludeFromCodeCoverage]
public class MediaLibraryScanJobProgressFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="MediaLibraryScanJobProgress"/>.
/// </summary>
/// <param name="completedItems">Optional. The number of completed items of the scan job.</param>
/// <param name="totalItems">Optional. The total number of items of the scan job.</param>
/// <param name="currentOperation">Optional. The current operation being performed by the scan job.</param>
/// <returns>The created <see cref="MediaLibraryScanJobProgress"/>.</returns>
public MediaLibraryScanJobProgress Create(
int? completedItems = null,
int? totalItems = null,
string? currentOperation = null)
{
Result<MediaLibraryScanJobProgress> progress = MediaLibraryScanJobProgress.Create(
completedItems ?? _faker.Random.Number(0, 100),
totalItems ?? _faker.Random.Number(100, 200),
currentOperation ?? _faker.Random.Words());
return progress.Value;
}
/// <summary>
/// Creates a list of <see cref="MediaLibraryScanJobProgress"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="MediaLibraryScanJobProgress"/> instances.</returns>
public List<MediaLibraryScanJobProgress> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,67 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
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.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
/// <summary>
/// Fixture class for the <see cref="MediaLibraryScanProgress"/> value object.
/// </summary>
[ExcludeFromCodeCoverage]
public class MediaLibraryScanProgressFixture
{
private readonly ScanIdFixture _scanIdFixture = new();
private readonly UserIdFixture _userIdFixture = new();
private readonly LibraryIdFixture _libraryIdFixture = new();
/// <summary>
/// Creates a random valid <see cref="MediaLibraryScanProgress"/>.
/// </summary>
/// <param name="scanId">Optional. The scan Id of the media library scan.</param>
/// <param name="userId">Optional. The user Id of the user initiating the media library scan.</param>
/// <param name="libraryId">Optional. The library Id of the scanned media library.</param>
/// <param name="completedJobs">Optional. The number of completed jobs of the media library scan.</param>
/// <param name="totalJobs">Optional. The total number of jobs of the media library scan.</param>
/// <param name="status">Optional. The status of the media library scan.</param>
/// <param name="currentJobProgress">Optional. The current job progress of the media library scan. When <see langword="null"/>, no current job progress is set.</param>
/// <returns>The created <see cref="MediaLibraryScanProgress"/>.</returns>
public MediaLibraryScanProgress Create(
ScanId? scanId = null,
UserId? userId = null,
LibraryId? libraryId = null,
int? completedJobs = null,
int? totalJobs = null,
LibraryScanJobStatus? status = null,
Optional<MediaLibraryScanJobProgress>? currentJobProgress = null)
{
Result<MediaLibraryScanProgress> progress = MediaLibraryScanProgress.Create(
scanId ?? _scanIdFixture.Create(),
userId ?? _userIdFixture.Create(),
libraryId ?? _libraryIdFixture.Create(),
completedJobs ?? 1,
totalJobs ?? 2,
status ?? LibraryScanJobStatus.Pending,
currentJobProgress ?? Optional<MediaLibraryScanJobProgress>.None());
return progress.Value;
}
/// <summary>
/// Creates a list of <see cref="MediaLibraryScanProgress"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="MediaLibraryScanProgress"/> instances.</returns>
public List<MediaLibraryScanProgress> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,65 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
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.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
/// <summary>
/// Fixture class for the <see cref="ParsedLibraryPath"/> domain value object.
/// </summary>
[ExcludeFromCodeCoverage]
public class ParsedLibraryPathFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="ParsedLibraryPath"/>.
/// </summary>
/// <param name="values">Optional. The captured values, keyed by their part kind.</param>
/// <param name="includeValues">Whether the parsed path should carry captured values. When <see langword="false"/>, an empty set of values is created.</param>
/// <returns>The created <see cref="ParsedLibraryPath"/>.</returns>
public ParsedLibraryPath Create(
IReadOnlyDictionary<LibraryPathPartKind, string>? values = null,
bool includeValues = true)
{
if (!includeValues)
return ParsedLibraryPath.Create(new Dictionary<LibraryPathPartKind, string>());
return ParsedLibraryPath.Create(values ?? CreateRandomValues());
}
/// <summary>
/// Creates multiple <see cref="ParsedLibraryPath"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="ParsedLibraryPath"/> instances.</returns>
public List<ParsedLibraryPath> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
/// <summary>
/// Creates a bounded set of random captured values.
/// </summary>
/// <returns>The captured values, keyed by their part kind.</returns>
private Dictionary<LibraryPathPartKind, string> CreateRandomValues()
{
LibraryPathPartKind[] candidateKinds =
[
LibraryPathPartKind.Artist,
LibraryPathPartKind.ReleaseName,
LibraryPathPartKind.TrackName,
LibraryPathPartKind.Title,
LibraryPathPartKind.Author
];
Dictionary<LibraryPathPartKind, string> values = [];
foreach (LibraryPathPartKind kind in candidateKinds.Take(_faker.Random.Int(1, candidateKinds.Length)))
values[kind] = _faker.Lorem.Word();
return values;
}
}
@@ -0,0 +1,36 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
/// <summary>
/// Fixture class for the <see cref="ScanId"/> value object.
/// </summary>
[ExcludeFromCodeCoverage]
public class ScanIdFixture
{
/// <summary>
/// Creates a random valid <see cref="ScanId"/>.
/// </summary>
/// <param name="value">Optional. The raw value of the scan Id.</param>
/// <returns>The created <see cref="ScanId"/>.</returns>
public ScanId Create(Guid? value = null)
{
return ScanId.Create(value ?? Guid.NewGuid());
}
/// <summary>
/// Creates a list of <see cref="ScanId"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="ScanId"/> instances.</returns>
public List<ScanId> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,55 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.Common.ValueObjects;
using Lumina.Domain.SharedKernel.Common.Enums.MediaConsumption;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.Common.ValueObjects;
/// <summary>
/// Fixture class for the <see cref="MediaPosition"/> value object.
/// </summary>
[ExcludeFromCodeCoverage]
public class MediaPositionFixture
{
private const int MAXIMUM_OFFSET_MILLISECONDS = 7_200_000;
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="MediaPosition"/>.
/// </summary>
/// <param name="kind">Optional. The kind of representation that the position uses. Defaults to a random valid kind.</param>
/// <param name="timeOffset">Optional. The time offset of the position. Only used when <paramref name="kind"/> is <see cref="MediaPositionKind.TimeOffset"/>.</param>
/// <param name="location">Optional. The location of the position. Only used when <paramref name="kind"/> is <see cref="MediaPositionKind.Location"/>.</param>
/// <returns>The created <see cref="MediaPosition"/>.</returns>
/// <remarks>
/// The kind selects which representation is populated, so exactly one of <paramref name="timeOffset"/> and <paramref name="location"/> is used. A
/// position always carries the representation of its own kind and can never carry both or neither, so no include flag is offered for them.
/// There is no flag for an explicit empty <paramref name="location"/> either, because an empty string is already an explicit value.
/// </remarks>
public MediaPosition Create(
MediaPositionKind? kind = null,
TimeSpan? timeOffset = null,
string? location = null)
{
MediaPositionKind resolvedKind = kind ?? _faker.Random.ArrayElement([MediaPositionKind.TimeOffset, MediaPositionKind.Location]);
if (resolvedKind == MediaPositionKind.Location)
return MediaPosition.CreateLocation(location ?? _faker.Lorem.Word());
return MediaPosition.CreateTimeOffset(timeOffset ?? TimeSpan.FromMilliseconds(_faker.Random.Int(0, MAXIMUM_OFFSET_MILLISECONDS)));
}
/// <summary>
/// Creates a list of <see cref="MediaPosition"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="MediaPosition"/> instances.</returns>
public List<MediaPosition> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,37 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
/// <summary>
/// Fixture class for the <see cref="LibraryId"/> 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 LibraryId.Create(value ?? Guid.NewGuid());
}
/// <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())];
}
}
@@ -0,0 +1,37 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
/// <summary>
/// Fixture class for the <see cref="MediaItemId"/> value object.
/// </summary>
[ExcludeFromCodeCoverage]
public class MediaItemIdFixture
{
/// <summary>
/// Creates a random valid <see cref="MediaItemId"/>.
/// </summary>
/// <param name="value">Optional. The raw value of the media item Id.</param>
/// <returns>The created <see cref="MediaItemId"/>.</returns>
public MediaItemId Create(
Guid? value = null)
{
return MediaItemId.Create(value ?? Guid.NewGuid());
}
/// <summary>
/// Creates a list of <see cref="MediaItemId"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="MediaItemId"/> instances.</returns>
public List<MediaItemId> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,37 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
/// <summary>
/// Fixture class for the <see cref="UserId"/> value object.
/// </summary>
[ExcludeFromCodeCoverage]
public class UserIdFixture
{
/// <summary>
/// Creates a random valid <see cref="UserId"/>.
/// </summary>
/// <param name="value">Optional. The raw value of the user Id.</param>
/// <returns>The created <see cref="UserId"/>.</returns>
public UserId Create(
Guid? value = null)
{
return UserId.Create(value ?? Guid.NewGuid());
}
/// <summary>
/// Creates a list of <see cref="UserId"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="UserId"/> instances.</returns>
public List<UserId> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,108 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.Common.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.Events;
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.Common.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.Events;
/// <summary>
/// Fixture class for the <see cref="MediaConsumptionCompletedDomainEvent"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class MediaConsumptionCompletedDomainEventFixture
{
private readonly Faker _faker = new();
private readonly MediaConsumptionRecordIdFixture _mediaConsumptionRecordIdFixture = new();
private readonly UserIdFixture _userIdFixture = new();
private readonly LibraryIdFixture _libraryIdFixture = new();
private readonly MediaItemIdFixture _mediaItemIdFixture = new();
private readonly MediaPositionFixture _mediaPositionFixture = new();
private readonly MediaKind[] _supportedMediaKinds =
[
MediaKind.MusicTrack,
MediaKind.PodcastEpisode,
MediaKind.Audiobook,
MediaKind.Movie,
MediaKind.TvEpisode,
MediaKind.Book,
MediaKind.Photo,
MediaKind.Video
];
/// <summary>
/// Creates a random valid <see cref="MediaConsumptionCompletedDomainEvent"/>.
/// </summary>
/// <param name="id">Optional. The Id of the domain event.</param>
/// <param name="mediaConsumptionRecordId">Optional. The unique identifier of the consumption record.</param>
/// <param name="userId">Optional. The unique identifier of the user that owns the consumption record.</param>
/// <param name="libraryId">Optional. The unique identifier of the media library that contains the consumed item.</param>
/// <param name="mediaItemId">Optional. The unique identifier of the consumed media item.</param>
/// <param name="mediaKind">Optional. The kind of media that was consumed. Defaults to a random supported kind.</param>
/// <param name="lastPosition">Optional. The last known position for the media item. Defaults to no position, unless <paramref name="includeLastPosition"/> is set.</param>
/// <param name="includeLastPosition">Whether to generate a last position when none is supplied. Must be <see langword="false"/> for a photo, which has no position kind and accepts no position at all.</param>
/// <param name="lastProgressFraction">Optional. The final progress fraction reported for the media item. Defaults to a bounded random fraction between zero and one.</param>
/// <param name="consumedDuration">Optional. The active duration consumed by the session. Defaults to a bounded random duration.</param>
/// <param name="consecutivePagesRead">Optional. The number of consecutive pages read in the session. Defaults to a bounded random count for a page based kind, and to zero for every other kind.</param>
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
/// <returns>The created <see cref="MediaConsumptionCompletedDomainEvent"/>.</returns>
public MediaConsumptionCompletedDomainEvent Create(
Guid? id = null,
MediaConsumptionRecordId? mediaConsumptionRecordId = null,
UserId? userId = null,
LibraryId? libraryId = null,
MediaItemId? mediaItemId = null,
MediaKind? mediaKind = null,
Optional<MediaPosition>? lastPosition = null,
bool includeLastPosition = false,
double? lastProgressFraction = null,
TimeSpan? consumedDuration = null,
int? consecutivePagesRead = null,
DateTime? occurredOnUtc = null)
{
MediaKind resolvedMediaKind = mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds);
Optional<MediaConsumptionRule> ruleResult = MediaConsumptionRule.For(resolvedMediaKind);
bool isPageBased = ruleResult.HasValue && ruleResult.Value is PageThresholdConsumptionRule;
return new MediaConsumptionCompletedDomainEvent(
id ?? Guid.NewGuid(),
mediaConsumptionRecordId ?? _mediaConsumptionRecordIdFixture.Create(),
userId ?? _userIdFixture.Create(),
libraryId ?? _libraryIdFixture.Create(),
mediaItemId ?? _mediaItemIdFixture.Create(),
resolvedMediaKind,
lastPosition ?? ResolveLastPosition(includeLastPosition, ruleResult),
lastProgressFraction ?? _faker.Random.Double(0, 1),
consumedDuration ?? TimeSpan.FromSeconds(_faker.Random.Int(0, 36000)),
consecutivePagesRead ?? (isPageBased ? _faker.Random.Int(0, 100) : 0),
occurredOnUtc ?? DateTime.UtcNow);
}
/// <summary>
/// Resolves the last position of the domain event, keeping it consistent with the position kind of the media kind rule.
/// </summary>
/// <param name="includeLastPosition">Whether to generate a position.</param>
/// <param name="ruleResult">The consumption rule of the media kind of the domain event, if the kind has one.</param>
/// <returns>The resolved last position, or no value when the domain event carries no position.</returns>
private Optional<MediaPosition> ResolveLastPosition(bool includeLastPosition, Optional<MediaConsumptionRule> ruleResult)
{
if (!includeLastPosition)
return Optional<MediaPosition>.None();
if (!ruleResult.HasValue || !ruleResult.Value.PositionKind.HasValue)
return Optional<MediaPosition>.None();
return Optional<MediaPosition>.Some(_mediaPositionFixture.Create(kind: ruleResult.Value.PositionKind.Value));
}
}
@@ -0,0 +1,108 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.Common.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.Events;
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.Common.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.Events;
/// <summary>
/// Fixture class for the <see cref="MediaConsumptionProgressedDomainEvent"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class MediaConsumptionProgressedDomainEventFixture
{
private readonly Faker _faker = new();
private readonly MediaConsumptionRecordIdFixture _mediaConsumptionRecordIdFixture = new();
private readonly UserIdFixture _userIdFixture = new();
private readonly LibraryIdFixture _libraryIdFixture = new();
private readonly MediaItemIdFixture _mediaItemIdFixture = new();
private readonly MediaPositionFixture _mediaPositionFixture = new();
private readonly MediaKind[] _supportedMediaKinds =
[
MediaKind.MusicTrack,
MediaKind.PodcastEpisode,
MediaKind.Audiobook,
MediaKind.Movie,
MediaKind.TvEpisode,
MediaKind.Book,
MediaKind.Photo,
MediaKind.Video
];
/// <summary>
/// Creates a random valid <see cref="MediaConsumptionProgressedDomainEvent"/>.
/// </summary>
/// <param name="id">Optional. The Id of the domain event.</param>
/// <param name="mediaConsumptionRecordId">Optional. The unique identifier of the consumption record.</param>
/// <param name="userId">Optional. The unique identifier of the user that owns the consumption record.</param>
/// <param name="libraryId">Optional. The unique identifier of the media library that contains the consumed item.</param>
/// <param name="mediaItemId">Optional. The unique identifier of the consumed media item.</param>
/// <param name="mediaKind">Optional. The kind of media that is being consumed. Defaults to a random supported kind.</param>
/// <param name="lastPosition">Optional. The last known position for the media item. Defaults to no position, unless <paramref name="includeLastPosition"/> is set.</param>
/// <param name="includeLastPosition">Whether to generate a last position when none is supplied. Must be <see langword="false"/> for a photo, which has no position kind and accepts no position at all.</param>
/// <param name="lastProgressFraction">Optional. The last progress fraction reported by the client. Defaults to a bounded random fraction between zero and one.</param>
/// <param name="consumedDuration">Optional. The active duration consumed so far. Defaults to a bounded random duration.</param>
/// <param name="consecutivePagesRead">Optional. The number of consecutive pages read so far. Defaults to a bounded random count for a page based kind, and to zero for every other kind.</param>
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
/// <returns>The created <see cref="MediaConsumptionProgressedDomainEvent"/>.</returns>
public MediaConsumptionProgressedDomainEvent Create(
Guid? id = null,
MediaConsumptionRecordId? mediaConsumptionRecordId = null,
UserId? userId = null,
LibraryId? libraryId = null,
MediaItemId? mediaItemId = null,
MediaKind? mediaKind = null,
Optional<MediaPosition>? lastPosition = null,
bool includeLastPosition = false,
double? lastProgressFraction = null,
TimeSpan? consumedDuration = null,
int? consecutivePagesRead = null,
DateTime? occurredOnUtc = null)
{
MediaKind resolvedMediaKind = mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds);
Optional<MediaConsumptionRule> ruleResult = MediaConsumptionRule.For(resolvedMediaKind);
bool isPageBased = ruleResult.HasValue && ruleResult.Value is PageThresholdConsumptionRule;
return new MediaConsumptionProgressedDomainEvent(
id ?? Guid.NewGuid(),
mediaConsumptionRecordId ?? _mediaConsumptionRecordIdFixture.Create(),
userId ?? _userIdFixture.Create(),
libraryId ?? _libraryIdFixture.Create(),
mediaItemId ?? _mediaItemIdFixture.Create(),
resolvedMediaKind,
lastPosition ?? ResolveLastPosition(includeLastPosition, ruleResult),
lastProgressFraction ?? _faker.Random.Double(0, 1),
consumedDuration ?? TimeSpan.FromSeconds(_faker.Random.Int(0, 36000)),
consecutivePagesRead ?? (isPageBased ? _faker.Random.Int(0, 100) : 0),
occurredOnUtc ?? DateTime.UtcNow);
}
/// <summary>
/// Resolves the last position of the domain event, keeping it consistent with the position kind of the media kind rule.
/// </summary>
/// <param name="includeLastPosition">Whether to generate a position.</param>
/// <param name="ruleResult">The consumption rule of the media kind of the domain event, if the kind has one.</param>
/// <returns>The resolved last position, or no value when the domain event carries no position.</returns>
private Optional<MediaPosition> ResolveLastPosition(bool includeLastPosition, Optional<MediaConsumptionRule> ruleResult)
{
if (!includeLastPosition)
return Optional<MediaPosition>.None();
if (!ruleResult.HasValue || !ruleResult.Value.PositionKind.HasValue)
return Optional<MediaPosition>.None();
return Optional<MediaPosition>.Some(_mediaPositionFixture.Create(kind: ruleResult.Value.PositionKind.Value));
}
}
@@ -0,0 +1,71 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.Events;
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.Events;
/// <summary>
/// Fixture class for the <see cref="MediaConsumptionStartedDomainEvent"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class MediaConsumptionStartedDomainEventFixture
{
private readonly Faker _faker = new();
private readonly MediaConsumptionRecordIdFixture _mediaConsumptionRecordIdFixture = new();
private readonly UserIdFixture _userIdFixture = new();
private readonly LibraryIdFixture _libraryIdFixture = new();
private readonly MediaItemIdFixture _mediaItemIdFixture = new();
private readonly MediaKind[] _supportedMediaKinds =
[
MediaKind.MusicTrack,
MediaKind.PodcastEpisode,
MediaKind.Audiobook,
MediaKind.Movie,
MediaKind.TvEpisode,
MediaKind.Book,
MediaKind.Photo,
MediaKind.Video
];
/// <summary>
/// Creates a random valid <see cref="MediaConsumptionStartedDomainEvent"/>.
/// </summary>
/// <param name="id">Optional. The Id of the domain event.</param>
/// <param name="mediaConsumptionRecordId">Optional. The unique identifier of the consumption record.</param>
/// <param name="userId">Optional. The unique identifier of the user that started the session.</param>
/// <param name="libraryId">Optional. The unique identifier of the media library that contains the consumed item.</param>
/// <param name="mediaItemId">Optional. The unique identifier of the consumed media item.</param>
/// <param name="mediaKind">Optional. The kind of media that is being consumed. Defaults to a random supported kind.</param>
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
/// <returns>The created <see cref="MediaConsumptionStartedDomainEvent"/>.</returns>
public MediaConsumptionStartedDomainEvent Create(
Guid? id = null,
MediaConsumptionRecordId? mediaConsumptionRecordId = null,
UserId? userId = null,
LibraryId? libraryId = null,
MediaItemId? mediaItemId = null,
MediaKind? mediaKind = null,
DateTime? occurredOnUtc = null)
{
return new MediaConsumptionStartedDomainEvent(
id ?? Guid.NewGuid(),
mediaConsumptionRecordId ?? _mediaConsumptionRecordIdFixture.Create(),
userId ?? _userIdFixture.Create(),
libraryId ?? _libraryIdFixture.Create(),
mediaItemId ?? _mediaItemIdFixture.Create(),
mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds),
occurredOnUtc ?? DateTime.UtcNow);
}
}
@@ -0,0 +1,108 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.Common.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.Events;
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.Common.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.Events;
/// <summary>
/// Fixture class for the <see cref="MediaConsumptionStoppedDomainEvent"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class MediaConsumptionStoppedDomainEventFixture
{
private readonly Faker _faker = new();
private readonly MediaConsumptionRecordIdFixture _mediaConsumptionRecordIdFixture = new();
private readonly UserIdFixture _userIdFixture = new();
private readonly LibraryIdFixture _libraryIdFixture = new();
private readonly MediaItemIdFixture _mediaItemIdFixture = new();
private readonly MediaPositionFixture _mediaPositionFixture = new();
private readonly MediaKind[] _supportedMediaKinds =
[
MediaKind.MusicTrack,
MediaKind.PodcastEpisode,
MediaKind.Audiobook,
MediaKind.Movie,
MediaKind.TvEpisode,
MediaKind.Book,
MediaKind.Photo,
MediaKind.Video
];
/// <summary>
/// Creates a random valid <see cref="MediaConsumptionStoppedDomainEvent"/>.
/// </summary>
/// <param name="id">Optional. The Id of the domain event.</param>
/// <param name="mediaConsumptionRecordId">Optional. The unique identifier of the consumption record.</param>
/// <param name="userId">Optional. The unique identifier of the user that owns the consumption record.</param>
/// <param name="libraryId">Optional. The unique identifier of the media library that contains the consumed item.</param>
/// <param name="mediaItemId">Optional. The unique identifier of the consumed media item.</param>
/// <param name="mediaKind">Optional. The kind of media that was consumed. Defaults to a random supported kind.</param>
/// <param name="lastPosition">Optional. The last known position for the media item. Defaults to no position, unless <paramref name="includeLastPosition"/> is set.</param>
/// <param name="includeLastPosition">Whether to generate a last position when none is supplied. Must be <see langword="false"/> for a photo, which has no position kind and accepts no position at all.</param>
/// <param name="lastProgressFraction">Optional. The final progress fraction reported for the media item. Defaults to a bounded random fraction between zero and one.</param>
/// <param name="consumedDuration">Optional. The active duration consumed by the session. Defaults to a bounded random duration.</param>
/// <param name="consecutivePagesRead">Optional. The number of consecutive pages read in the session. Defaults to a bounded random count for a page based kind, and to zero for every other kind.</param>
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
/// <returns>The created <see cref="MediaConsumptionStoppedDomainEvent"/>.</returns>
public MediaConsumptionStoppedDomainEvent Create(
Guid? id = null,
MediaConsumptionRecordId? mediaConsumptionRecordId = null,
UserId? userId = null,
LibraryId? libraryId = null,
MediaItemId? mediaItemId = null,
MediaKind? mediaKind = null,
Optional<MediaPosition>? lastPosition = null,
bool includeLastPosition = false,
double? lastProgressFraction = null,
TimeSpan? consumedDuration = null,
int? consecutivePagesRead = null,
DateTime? occurredOnUtc = null)
{
MediaKind resolvedMediaKind = mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds);
Optional<MediaConsumptionRule> ruleResult = MediaConsumptionRule.For(resolvedMediaKind);
bool isPageBased = ruleResult.HasValue && ruleResult.Value is PageThresholdConsumptionRule;
return new MediaConsumptionStoppedDomainEvent(
id ?? Guid.NewGuid(),
mediaConsumptionRecordId ?? _mediaConsumptionRecordIdFixture.Create(),
userId ?? _userIdFixture.Create(),
libraryId ?? _libraryIdFixture.Create(),
mediaItemId ?? _mediaItemIdFixture.Create(),
resolvedMediaKind,
lastPosition ?? ResolveLastPosition(includeLastPosition, ruleResult),
lastProgressFraction ?? _faker.Random.Double(0, 1),
consumedDuration ?? TimeSpan.FromSeconds(_faker.Random.Int(0, 36000)),
consecutivePagesRead ?? (isPageBased ? _faker.Random.Int(0, 100) : 0),
occurredOnUtc ?? DateTime.UtcNow);
}
/// <summary>
/// Resolves the last position of the domain event, keeping it consistent with the position kind of the media kind rule.
/// </summary>
/// <param name="includeLastPosition">Whether to generate a position.</param>
/// <param name="ruleResult">The consumption rule of the media kind of the domain event, if the kind has one.</param>
/// <returns>The resolved last position, or no value when the domain event carries no position.</returns>
private Optional<MediaPosition> ResolveLastPosition(bool includeLastPosition, Optional<MediaConsumptionRule> ruleResult)
{
if (!includeLastPosition)
return Optional<MediaPosition>.None();
if (!ruleResult.HasValue || !ruleResult.Value.PositionKind.HasValue)
return Optional<MediaPosition>.None();
return Optional<MediaPosition>.Some(_mediaPositionFixture.Create(kind: ruleResult.Value.PositionKind.Value));
}
}
@@ -0,0 +1,144 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.Common.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate;
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.Common.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
using Lumina.Domain.SharedKernel.Common.Enums.MediaConsumption;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate;
/// <summary>
/// Fixture class for the <see cref="MediaConsumptionRecord"/> domain aggregate.
/// </summary>
[ExcludeFromCodeCoverage]
public class MediaConsumptionRecordFixture
{
private readonly Faker _faker = new();
private readonly MediaConsumptionRecordIdFixture _mediaConsumptionRecordIdFixture = new();
private readonly UserIdFixture _userIdFixture = new();
private readonly LibraryIdFixture _libraryIdFixture = new();
private readonly MediaItemIdFixture _mediaItemIdFixture = new();
private readonly MediaPositionFixture _mediaPositionFixture = new();
private readonly MediaKind[] _supportedMediaKinds =
[
MediaKind.MusicTrack,
MediaKind.PodcastEpisode,
MediaKind.Audiobook,
MediaKind.Movie,
MediaKind.TvEpisode,
MediaKind.Book,
MediaKind.Photo,
MediaKind.Video
];
/// <summary>
/// Creates a random valid <see cref="MediaConsumptionRecord"/> domain aggregate, with pre-existing data.
/// </summary>
/// <param name="id">Optional. The Id of the consumption record.</param>
/// <param name="userId">Optional. The Id of the user that owns the consumption record.</param>
/// <param name="libraryId">Optional. The Id of the media library that contains the consumed media item.</param>
/// <param name="mediaItemId">Optional. The Id of the consumed media item.</param>
/// <param name="mediaKind">Optional. The kind of media that is consumed. Defaults to a random supported kind.</param>
/// <param name="status">Optional. The status of the consumption session. Defaults to a random valid status.</param>
/// <param name="startedOnUtc">Optional. The date and time when the consumption session started. Defaults to a few days in the past.</param>
/// <param name="lastActivityOnUtc">Optional. The date and time of the last activity of the consumption session. Defaults to a moment at or after the start.</param>
/// <param name="endedOnUtc">Optional. The date and time when the consumption session ended. Defaults to no value for an in-progress session, and to a moment at or after the last activity for a terminal session.</param>
/// <param name="consumedDuration">Optional. The active duration consumed by the session. Defaults to a bounded random duration.</param>
/// <param name="lastPosition">Optional. The last position of the session. When omitted, a position matching the position kind of the media kind rule is generated.</param>
/// <param name="includeLastPosition">Whether to generate a last position when <paramref name="lastPosition"/> is not supplied. Must be <see langword="false"/> for a photo, which has no position kind and accepts no position at all.</param>
/// <param name="lastProgressFraction">Optional. The last progress fraction of the session. Defaults to a bounded random fraction between zero and one.</param>
/// <param name="consecutivePagesRead">Optional. The number of consecutive pages read. Defaults to a bounded random count for a page based kind, and to zero for every other kind.</param>
/// <returns>The created <see cref="MediaConsumptionRecord"/>.</returns>
/// <remarks>
/// The record is built through <see cref="MediaConsumptionRecord.Reconstitute"/>, so every default produced here is internally consistent: the
/// start is in the past, the last activity never precedes it, an end time exists exactly when the status is terminal and never precedes the last
/// activity, consecutive pages are only counted for a book, and a generated position always uses the position kind of its media kind.
/// </remarks>
public MediaConsumptionRecord Create(
MediaConsumptionRecordId? id = null,
UserId? userId = null,
LibraryId? libraryId = null,
MediaItemId? mediaItemId = null,
MediaKind? mediaKind = null,
ConsumptionStatus? status = null,
DateTime? startedOnUtc = null,
DateTime? lastActivityOnUtc = null,
Optional<DateTime>? endedOnUtc = null,
TimeSpan? consumedDuration = null,
Optional<MediaPosition>? lastPosition = null,
bool includeLastPosition = true,
double? lastProgressFraction = null,
int? consecutivePagesRead = null)
{
MediaKind resolvedMediaKind = mediaKind ?? _faker.Random.ArrayElement(_supportedMediaKinds);
ConsumptionStatus resolvedStatus = status ?? _faker.Random.ArrayElement([ConsumptionStatus.InProgress, ConsumptionStatus.Completed, ConsumptionStatus.Stopped]);
DateTime resolvedStartedOnUtc = startedOnUtc ?? DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)).AddMinutes(-_faker.Random.Int(0, 59));
DateTime resolvedLastActivityOnUtc = lastActivityOnUtc ?? resolvedStartedOnUtc.AddMinutes(_faker.Random.Int(0, 120));
Optional<DateTime> resolvedEndedOnUtc = endedOnUtc ?? (resolvedStatus == ConsumptionStatus.InProgress
? Optional<DateTime>.None()
: Optional<DateTime>.Some(resolvedLastActivityOnUtc == DateTime.MaxValue
? DateTime.MaxValue
: resolvedLastActivityOnUtc.AddMinutes(_faker.Random.Int(0, 60))));
Optional<MediaConsumptionRule> ruleResult = MediaConsumptionRule.For(resolvedMediaKind);
bool isPageBased = ruleResult.HasValue && ruleResult.Value is PageThresholdConsumptionRule;
Result<MediaConsumptionRecord> result = MediaConsumptionRecord.Reconstitute(
id ?? _mediaConsumptionRecordIdFixture.Create(),
userId ?? _userIdFixture.Create(),
libraryId ?? _libraryIdFixture.Create(),
mediaItemId ?? _mediaItemIdFixture.Create(),
resolvedMediaKind,
resolvedStatus,
resolvedStartedOnUtc,
resolvedLastActivityOnUtc,
resolvedEndedOnUtc,
consumedDuration ?? TimeSpan.FromSeconds(_faker.Random.Int(0, 36000)),
ResolveLastPosition(lastPosition, includeLastPosition, ruleResult),
lastProgressFraction ?? _faker.Random.Double(0, 1),
consecutivePagesRead ?? (isPageBased ? _faker.Random.Int(0, 100) : 0));
return result.Value;
}
/// <summary>
/// Creates multiple <see cref="MediaConsumptionRecord"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="MediaConsumptionRecord"/> instances.</returns>
public List<MediaConsumptionRecord> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
/// <summary>
/// Resolves the last position of the record, keeping it consistent with the position kind of its media kind rule.
/// </summary>
/// <param name="lastPosition">The explicitly supplied last position, if any.</param>
/// <param name="includeLastPosition">Whether to generate a position when none is supplied.</param>
/// <param name="ruleResult">The consumption rule of the media kind of the record, if the kind has one.</param>
/// <returns>The resolved last position, or no value when the record carries no position.</returns>
private Optional<MediaPosition> ResolveLastPosition(Optional<MediaPosition>? lastPosition, bool includeLastPosition, Optional<MediaConsumptionRule> ruleResult)
{
if (!includeLastPosition)
return Optional<MediaPosition>.None();
if (lastPosition.HasValue)
return lastPosition.Value;
if (!ruleResult.HasValue || !ruleResult.Value.PositionKind.HasValue)
return Optional<MediaPosition>.None();
return Optional<MediaPosition>.Some(_mediaPositionFixture.Create(kind: ruleResult.Value.PositionKind.Value));
}
}
@@ -0,0 +1,34 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
/// <summary>
/// Fixture class for the <see cref="AudiobookConsumptionRule"/> domain value object.
/// </summary>
[ExcludeFromCodeCoverage]
public class AudiobookConsumptionRuleFixture
{
/// <summary>
/// Creates a valid <see cref="AudiobookConsumptionRule"/>.
/// </summary>
/// <returns>The created <see cref="AudiobookConsumptionRule"/>.</returns>
public AudiobookConsumptionRule Create()
{
return new AudiobookConsumptionRule();
}
/// <summary>
/// Creates multiple <see cref="AudiobookConsumptionRule"/> instances.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="AudiobookConsumptionRule"/> instances.</returns>
public List<AudiobookConsumptionRule> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,34 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
/// <summary>
/// Fixture class for the <see cref="BookConsumptionRule"/> domain value object.
/// </summary>
[ExcludeFromCodeCoverage]
public class BookConsumptionRuleFixture
{
/// <summary>
/// Creates a valid <see cref="BookConsumptionRule"/>.
/// </summary>
/// <returns>The created <see cref="BookConsumptionRule"/>.</returns>
public BookConsumptionRule Create()
{
return new BookConsumptionRule();
}
/// <summary>
/// Creates multiple <see cref="BookConsumptionRule"/> instances.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="BookConsumptionRule"/> instances.</returns>
public List<BookConsumptionRule> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,37 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
/// <summary>
/// Fixture class for the <see cref="MediaConsumptionRecordId"/> value object.
/// </summary>
[ExcludeFromCodeCoverage]
public class MediaConsumptionRecordIdFixture
{
/// <summary>
/// Creates a random valid <see cref="MediaConsumptionRecordId"/>.
/// </summary>
/// <param name="value">Optional. The raw value of the consumption record Id.</param>
/// <returns>The created <see cref="MediaConsumptionRecordId"/>.</returns>
public MediaConsumptionRecordId Create(
Guid? value = null)
{
return MediaConsumptionRecordId.Create(value ?? Guid.NewGuid());
}
/// <summary>
/// Creates a list of <see cref="MediaConsumptionRecordId"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="MediaConsumptionRecordId"/> instances.</returns>
public List<MediaConsumptionRecordId> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,34 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
/// <summary>
/// Fixture class for the <see cref="MovieConsumptionRule"/> domain value object.
/// </summary>
[ExcludeFromCodeCoverage]
public class MovieConsumptionRuleFixture
{
/// <summary>
/// Creates a valid <see cref="MovieConsumptionRule"/>.
/// </summary>
/// <returns>The created <see cref="MovieConsumptionRule"/>.</returns>
public MovieConsumptionRule Create()
{
return new MovieConsumptionRule();
}
/// <summary>
/// Creates multiple <see cref="MovieConsumptionRule"/> instances.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="MovieConsumptionRule"/> instances.</returns>
public List<MovieConsumptionRule> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,34 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
/// <summary>
/// Fixture class for the <see cref="MusicTrackConsumptionRule"/> domain value object.
/// </summary>
[ExcludeFromCodeCoverage]
public class MusicTrackConsumptionRuleFixture
{
/// <summary>
/// Creates a valid <see cref="MusicTrackConsumptionRule"/>.
/// </summary>
/// <returns>The created <see cref="MusicTrackConsumptionRule"/>.</returns>
public MusicTrackConsumptionRule Create()
{
return new MusicTrackConsumptionRule();
}
/// <summary>
/// Creates multiple <see cref="MusicTrackConsumptionRule"/> instances.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="MusicTrackConsumptionRule"/> instances.</returns>
public List<MusicTrackConsumptionRule> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,34 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
/// <summary>
/// Fixture class for the <see cref="PhotoConsumptionRule"/> domain value object.
/// </summary>
[ExcludeFromCodeCoverage]
public class PhotoConsumptionRuleFixture
{
/// <summary>
/// Creates a valid <see cref="PhotoConsumptionRule"/>.
/// </summary>
/// <returns>The created <see cref="PhotoConsumptionRule"/>.</returns>
public PhotoConsumptionRule Create()
{
return new PhotoConsumptionRule();
}
/// <summary>
/// Creates multiple <see cref="PhotoConsumptionRule"/> instances.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="PhotoConsumptionRule"/> instances.</returns>
public List<PhotoConsumptionRule> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,34 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
/// <summary>
/// Fixture class for the <see cref="PodcastEpisodeConsumptionRule"/> domain value object.
/// </summary>
[ExcludeFromCodeCoverage]
public class PodcastEpisodeConsumptionRuleFixture
{
/// <summary>
/// Creates a valid <see cref="PodcastEpisodeConsumptionRule"/>.
/// </summary>
/// <returns>The created <see cref="PodcastEpisodeConsumptionRule"/>.</returns>
public PodcastEpisodeConsumptionRule Create()
{
return new PodcastEpisodeConsumptionRule();
}
/// <summary>
/// Creates multiple <see cref="PodcastEpisodeConsumptionRule"/> instances.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="PodcastEpisodeConsumptionRule"/> instances.</returns>
public List<PodcastEpisodeConsumptionRule> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,34 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
/// <summary>
/// Fixture class for the <see cref="TvEpisodeConsumptionRule"/> domain value object.
/// </summary>
[ExcludeFromCodeCoverage]
public class TvEpisodeConsumptionRuleFixture
{
/// <summary>
/// Creates a valid <see cref="TvEpisodeConsumptionRule"/>.
/// </summary>
/// <returns>The created <see cref="TvEpisodeConsumptionRule"/>.</returns>
public TvEpisodeConsumptionRule Create()
{
return new TvEpisodeConsumptionRule();
}
/// <summary>
/// Creates multiple <see cref="TvEpisodeConsumptionRule"/> instances.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="TvEpisodeConsumptionRule"/> instances.</returns>
public List<TvEpisodeConsumptionRule> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,34 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaConsumptionRecordAggregate.ValueObjects;
/// <summary>
/// Fixture class for the <see cref="VideoConsumptionRule"/> domain value object.
/// </summary>
[ExcludeFromCodeCoverage]
public class VideoConsumptionRuleFixture
{
/// <summary>
/// Creates a valid <see cref="VideoConsumptionRule"/>.
/// </summary>
/// <returns>The created <see cref="VideoConsumptionRule"/>.</returns>
public VideoConsumptionRule Create()
{
return new VideoConsumptionRule();
}
/// <summary>
/// Creates multiple <see cref="VideoConsumptionRule"/> instances.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="VideoConsumptionRule"/> instances.</returns>
public List<VideoConsumptionRule> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,108 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.Common.ValueObjects;
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaResumePointAggregate;
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaResumePointAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.Common.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.LibraryManagementBoundedContext.LibraryAggregate;
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaResumePointAggregate.ValueObjects;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaResumePointAggregate;
/// <summary>
/// Fixture class for the <see cref="MediaResumePoint"/> domain aggregate.
/// </summary>
[ExcludeFromCodeCoverage]
public class MediaResumePointFixture
{
private readonly Faker _faker = new();
private readonly MediaResumePointIdFixture _mediaResumePointIdFixture = new();
private readonly UserIdFixture _userIdFixture = new();
private readonly LibraryIdFixture _libraryIdFixture = new();
private readonly MediaItemIdFixture _mediaItemIdFixture = new();
private readonly MediaPositionFixture _mediaPositionFixture = new();
private readonly MediaKind[] _resumableMediaKinds =
[
MediaKind.MusicTrack,
MediaKind.PodcastEpisode,
MediaKind.Audiobook,
MediaKind.Movie,
MediaKind.TvEpisode,
MediaKind.Book,
MediaKind.Video
];
/// <summary>
/// Creates a random valid <see cref="MediaResumePoint"/> domain aggregate, with pre-existing data.
/// </summary>
/// <param name="id">Optional. The Id of the resume point.</param>
/// <param name="userId">Optional. The Id of the user that owns the resume point.</param>
/// <param name="libraryId">Optional. The Id of the media library that contains the media item.</param>
/// <param name="mediaItemId">Optional. The Id of the media item to resume.</param>
/// <param name="mediaKind">Optional. The kind of media that is resumed. Defaults to a random resumable kind.</param>
/// <param name="lastPosition">Optional. The position at which the media item can be resumed. When omitted, a position matching the position kind of the media kind rule is generated.</param>
/// <param name="lastProgressFraction">Optional. The progress fraction at which the media item can be resumed. Defaults to a bounded random fraction between zero and one.</param>
/// <param name="lastConsumedOnUtc">Optional. The date and time when the media item was last consumed. Defaults to a moment in the past.</param>
/// <param name="createdOnUtc">Optional. The date and time when the resume point was created. Defaults to the resolved last consumption time.</param>
/// <param name="updatedOnUtc">Optional. The date and time when the resume point was last updated. Defaults to no value.</param>
/// <returns>The created <see cref="MediaResumePoint"/>.</returns>
/// <remarks>
/// The resume point is built through <see cref="MediaResumePoint.Reconstitute"/>, so every default produced here is internally consistent: the
/// media kind is always one that can be resumed, a generated position always uses the position kind of its media kind rule, the progress fraction
/// stays within its boundaries, the last consumption time is in the past and the creation time defaults to it. The fixture must never be used with a
/// non-resumable kind, such as <see cref="MediaKind.Photo"/>, or with an unsupported kind, because no valid resume point exists for them. A resume
/// point always carries a position, so the fixture generates one whenever <paramref name="lastPosition"/> is omitted.
/// </remarks>
public MediaResumePoint Create(
MediaResumePointId? id = null,
UserId? userId = null,
LibraryId? libraryId = null,
MediaItemId? mediaItemId = null,
MediaKind? mediaKind = null,
MediaPosition? lastPosition = null,
double? lastProgressFraction = null,
DateTime? lastConsumedOnUtc = null,
DateTime? createdOnUtc = null,
Optional<DateTime>? updatedOnUtc = null)
{
MediaKind resolvedMediaKind = mediaKind ?? _faker.Random.ArrayElement(_resumableMediaKinds);
MediaConsumptionRule rule = MediaConsumptionRule.For(resolvedMediaKind).Value;
DateTime resolvedLastConsumedOnUtc = lastConsumedOnUtc ?? DateTime.UtcNow.AddHours(-_faker.Random.Int(1, 720));
MediaPosition resolvedLastPosition = lastPosition ?? _mediaPositionFixture.Create(kind: rule.PositionKind.Value);
Result<MediaResumePoint> result = MediaResumePoint.Reconstitute(
id ?? _mediaResumePointIdFixture.Create(),
userId ?? _userIdFixture.Create(),
libraryId ?? _libraryIdFixture.Create(),
mediaItemId ?? _mediaItemIdFixture.Create(),
resolvedMediaKind,
resolvedLastPosition,
lastProgressFraction ?? _faker.Random.Double(0, 1),
resolvedLastConsumedOnUtc,
createdOnUtc ?? resolvedLastConsumedOnUtc,
updatedOnUtc ?? Optional<DateTime>.None());
return result.Value;
}
/// <summary>
/// Creates multiple <see cref="MediaResumePoint"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="MediaResumePoint"/> instances.</returns>
public List<MediaResumePoint> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,37 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaResumePointAggregate.ValueObjects;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaConsumptionBoundedContext.MediaResumePointAggregate.ValueObjects;
/// <summary>
/// Fixture class for the <see cref="MediaResumePointId"/> value object.
/// </summary>
[ExcludeFromCodeCoverage]
public class MediaResumePointIdFixture
{
/// <summary>
/// Creates a random valid <see cref="MediaResumePointId"/>.
/// </summary>
/// <param name="value">Optional. The raw value of the resume point Id.</param>
/// <returns>The created <see cref="MediaResumePointId"/>.</returns>
public MediaResumePointId Create(
Guid? value = null)
{
return MediaResumePointId.Create(value ?? Guid.NewGuid());
}
/// <summary>
/// Creates a list of <see cref="MediaResumePointId"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="MediaResumePointId"/> instances.</returns>
public List<MediaResumePointId> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,64 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.MediaContributorBoundedContext.MediaContributorAggregate;
using Lumina.Domain.Core.BoundedContexts.MediaContributorBoundedContext.MediaContributorAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaContributorBoundedContext.MediaContributorAggregate.ValueObjects;
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.MediaContributorBoundedContext.MediaContributorAggregate;
/// <summary>
/// Fixture class for the <see cref="MediaContributor"/> domain aggregate.
/// </summary>
[ExcludeFromCodeCoverage]
public class MediaContributorFixture
{
private readonly MediaContributorIdFixture _mediaContributorIdFixture = new();
private readonly MediaContributorNameFixture _mediaContributorNameFixture = new();
/// <summary>
/// Creates a random valid <see cref="MediaContributor"/> domain aggregate.
/// </summary>
/// <param name="id">Optional. The Id of the contributor.</param>
/// <param name="type">Optional. The type of the contributor.</param>
/// <param name="name">Optional. The name of the contributor.</param>
/// <param name="biography">Optional. The biography of the contributor.</param>
/// <param name="dateOfBirth">Optional. The date of birth of the contributor.</param>
/// <param name="dateOfDeath">Optional. The date of death of the contributor.</param>
/// <returns>The created <see cref="MediaContributor"/> domain aggregate.</returns>
public MediaContributor Create(
MediaContributorId? id = null,
MediaContributorType? type = null,
MediaContributorName? name = null,
Optional<string>? biography = null,
Optional<DateOnly>? dateOfBirth = null,
Optional<DateOnly>? dateOfDeath = null)
{
Result<MediaContributor> result = MediaContributor.Create(
id ?? _mediaContributorIdFixture.Create(),
type ?? MediaContributorType.Person,
name ?? _mediaContributorNameFixture.Create(),
biography ?? Optional<string>.None(),
dateOfBirth ?? Optional<DateOnly>.None(),
dateOfDeath ?? Optional<DateOnly>.None());
if (result.IsFailure)
throw new InvalidOperationException("Failed to create MediaContributor: " + string.Join(", ", result.Errors));
return result.Value;
}
/// <summary>
/// Creates multiple <see cref="MediaContributor"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="MediaContributor"/> instances.</returns>
public List<MediaContributor> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,36 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.MediaContributorBoundedContext.MediaContributorAggregate.ValueObjects;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaContributorBoundedContext.MediaContributorAggregate.ValueObjects;
/// <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 value used to create the <see cref="MediaContributorId"/>. If not provided, a random value is generated.</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 multiple <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())];
}
}
@@ -0,0 +1,47 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.MediaContributorBoundedContext.MediaContributorAggregate.ValueObjects;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaContributorBoundedContext.MediaContributorAggregate.ValueObjects;
/// <summary>
/// Fixture class for the <see cref="MediaContributorName"/> domain value object.
/// </summary>
[ExcludeFromCodeCoverage]
public class MediaContributorNameFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="MediaContributorName"/>.
/// </summary>
/// <param name="displayName">Optional. The name by which the contributor is popularly known. If not provided, a random name is generated.</param>
/// <param name="legalName">Optional. The legal name of the contributor. If not provided, a random legal name is generated.</param>
/// <returns>The created <see cref="MediaContributorName"/>.</returns>
public MediaContributorName Create(string? displayName = null, Optional<string>? legalName = null)
{
Result<MediaContributorName> nameResult = MediaContributorName.Create(
displayName ?? _faker.Person.FullName,
legalName ?? Optional<string>.Some(_faker.Person.FullName));
if (nameResult.IsFailure)
throw new InvalidOperationException("Failed to create MediaContributorName: " + string.Join(", ", nameResult.Errors));
return nameResult.Value;
}
/// <summary>
/// Creates multiple <see cref="MediaContributorName"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="MediaContributorName"/> instances.</returns>
public List<MediaContributorName> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,37 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.PlaylistBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
/// <summary>
/// Fixture class for the <see cref="MediaItemId"/> value object.
/// </summary>
[ExcludeFromCodeCoverage]
public class MediaItemIdFixture
{
/// <summary>
/// Creates a random valid <see cref="MediaItemId"/>.
/// </summary>
/// <param name="value">Optional. The raw value of the media item Id.</param>
/// <returns>The created <see cref="MediaItemId"/>.</returns>
public MediaItemId Create(
Guid? value = null)
{
return MediaItemId.Create(value ?? Guid.NewGuid());
}
/// <summary>
/// Creates a list of <see cref="MediaItemId"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="MediaItemId"/> instances.</returns>
public List<MediaItemId> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,37 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.PlaylistBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
/// <summary>
/// Fixture class for the <see cref="UserId"/> value object.
/// </summary>
[ExcludeFromCodeCoverage]
public class UserIdFixture
{
/// <summary>
/// Creates a random valid <see cref="UserId"/>.
/// </summary>
/// <param name="value">Optional. The raw value of the user Id.</param>
/// <returns>The created <see cref="UserId"/>.</returns>
public UserId Create(
Guid? value = null)
{
return UserId.Create(value ?? Guid.NewGuid());
}
/// <summary>
/// Creates a list of <see cref="UserId"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="UserId"/> instances.</returns>
public List<UserId> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,63 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.Entities;
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.PlaylistBoundedContext.ExternalIdentifiers.MediaLibraryBoundedContext.MediaItemAggregate;
using Lumina.Domain.Fixtures.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.ValueObjects;
using Lumina.Domain.SharedKernel.Common.Enums.Playlists;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.Entities;
/// <summary>
/// Fixture class for the <see cref="PlaylistEntry"/> entity.
/// </summary>
[ExcludeFromCodeCoverage]
public class PlaylistEntryFixture
{
private const long MAXIMUM_RANDOM_POSITION = 1_000_000_000L;
private readonly Faker _faker = new();
private readonly PlaylistEntryIdFixture _playlistEntryIdFixture = new();
private readonly MediaItemIdFixture _mediaItemIdFixture = new();
/// <summary>
/// Creates a random valid <see cref="PlaylistEntry"/>.
/// </summary>
/// <param name="id">Optional. The Id of the entry.</param>
/// <param name="mediaItemId">Optional. The Id of the media item referenced by the entry.</param>
/// <param name="mediaItemType">Optional. The kind of media item referenced by the entry. Defaults to a music track, which is the kind a music playlist accepts.</param>
/// <param name="position">Optional. The sparse order key of the entry. Defaults to a bounded random key.</param>
/// <returns>The created <see cref="PlaylistEntry"/>.</returns>
public PlaylistEntry Create(
PlaylistEntryId? id = null,
MediaItemId? mediaItemId = null,
PlaylistMediaItemType? mediaItemType = null,
long? position = null)
{
return PlaylistEntry.Create(
id ?? _playlistEntryIdFixture.Create(),
mediaItemId ?? _mediaItemIdFixture.Create(),
mediaItemType ?? PlaylistMediaItemType.MusicTrack,
position ?? _faker.Random.Long(0, MAXIMUM_RANDOM_POSITION)).Value;
}
/// <summary>
/// Creates multiple <see cref="PlaylistEntry"/> instances with randomized test data and distinct positions.
/// </summary>
/// <remarks>
/// The positions are spaced apart and unique, so the created entries can be placed in the same playlist without violating the
/// uniqueness invariant of the sparse order keys.
/// </remarks>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="PlaylistEntry"/> instances.</returns>
public List<PlaylistEntry> CreateMany(int count = 3)
{
long firstPosition = _faker.Random.Long(0, MAXIMUM_RANDOM_POSITION);
return [.. Enumerable.Range(0, count).Select(index => Create(position: firstPosition + index))];
}
}
@@ -0,0 +1,63 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.Events;
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.PlaylistBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
using Lumina.Domain.Fixtures.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.ValueObjects;
using Lumina.Domain.SharedKernel.Common.Enums.Playlists;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.Events;
/// <summary>
/// Fixture class for the <see cref="PlaylistCreatedDomainEvent"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class PlaylistCreatedDomainEventFixture
{
private readonly Faker _faker = new();
private readonly PlaylistIdFixture _playlistIdFixture = new();
private readonly UserIdFixture _userIdFixture = new();
/// <summary>
/// Creates a random valid <see cref="PlaylistCreatedDomainEvent"/>.
/// </summary>
/// <param name="id">Optional. The Id of the domain event.</param>
/// <param name="playlistId">Optional. The unique identifier of the playlist.</param>
/// <param name="userId">Optional. The unique identifier of the user that owns the playlist.</param>
/// <param name="name">Optional. The name of the playlist.</param>
/// <param name="type">Optional. The kind of media the playlist holds. Defaults to the only supported kind.</param>
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
/// <returns>The created <see cref="PlaylistCreatedDomainEvent"/>.</returns>
public PlaylistCreatedDomainEvent Create(
Guid? id = null,
PlaylistId? playlistId = null,
UserId? userId = null,
string? name = null,
PlaylistType? type = null,
DateTime? occurredOnUtc = null)
{
return new PlaylistCreatedDomainEvent(
id ?? Guid.NewGuid(),
playlistId ?? _playlistIdFixture.Create(),
userId ?? _userIdFixture.Create(),
name ?? _faker.Lorem.Sentence(3),
type ?? PlaylistType.Music,
occurredOnUtc ?? DateTime.UtcNow);
}
/// <summary>
/// Creates multiple <see cref="PlaylistCreatedDomainEvent"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="PlaylistCreatedDomainEvent"/> instances.</returns>
public List<PlaylistCreatedDomainEvent> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,54 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.Events;
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.PlaylistBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
using Lumina.Domain.Fixtures.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.ValueObjects;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.Events;
/// <summary>
/// Fixture class for the <see cref="PlaylistDeletedDomainEvent"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class PlaylistDeletedDomainEventFixture
{
private readonly PlaylistIdFixture _playlistIdFixture = new();
private readonly UserIdFixture _userIdFixture = new();
/// <summary>
/// Creates a random valid <see cref="PlaylistDeletedDomainEvent"/>.
/// </summary>
/// <param name="id">Optional. The Id of the domain event.</param>
/// <param name="playlistId">Optional. The unique identifier of the playlist.</param>
/// <param name="userId">Optional. The unique identifier of the user that owned the playlist.</param>
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
/// <returns>The created <see cref="PlaylistDeletedDomainEvent"/>.</returns>
public PlaylistDeletedDomainEvent Create(
Guid? id = null,
PlaylistId? playlistId = null,
UserId? userId = null,
DateTime? occurredOnUtc = null)
{
return new PlaylistDeletedDomainEvent(
id ?? Guid.NewGuid(),
playlistId ?? _playlistIdFixture.Create(),
userId ?? _userIdFixture.Create(),
occurredOnUtc ?? DateTime.UtcNow);
}
/// <summary>
/// Creates multiple <see cref="PlaylistDeletedDomainEvent"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="PlaylistDeletedDomainEvent"/> instances.</returns>
public List<PlaylistDeletedDomainEvent> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,59 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.Events;
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.PlaylistBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
using Lumina.Domain.Fixtures.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.ValueObjects;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.Events;
/// <summary>
/// Fixture class for the <see cref="PlaylistDetailsUpdatedDomainEvent"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class PlaylistDetailsUpdatedDomainEventFixture
{
private readonly Faker _faker = new();
private readonly PlaylistIdFixture _playlistIdFixture = new();
private readonly UserIdFixture _userIdFixture = new();
/// <summary>
/// Creates a random valid <see cref="PlaylistDetailsUpdatedDomainEvent"/>.
/// </summary>
/// <param name="id">Optional. The Id of the domain event.</param>
/// <param name="playlistId">Optional. The unique identifier of the playlist.</param>
/// <param name="userId">Optional. The unique identifier of the user that owns the playlist.</param>
/// <param name="name">Optional. The new name of the playlist.</param>
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
/// <returns>The created <see cref="PlaylistDetailsUpdatedDomainEvent"/>.</returns>
public PlaylistDetailsUpdatedDomainEvent Create(
Guid? id = null,
PlaylistId? playlistId = null,
UserId? userId = null,
string? name = null,
DateTime? occurredOnUtc = null)
{
return new PlaylistDetailsUpdatedDomainEvent(
id ?? Guid.NewGuid(),
playlistId ?? _playlistIdFixture.Create(),
userId ?? _userIdFixture.Create(),
name ?? _faker.Lorem.Sentence(3),
occurredOnUtc ?? DateTime.UtcNow);
}
/// <summary>
/// Creates multiple <see cref="PlaylistDetailsUpdatedDomainEvent"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="PlaylistDetailsUpdatedDomainEvent"/> instances.</returns>
public List<PlaylistDetailsUpdatedDomainEvent> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,79 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate;
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.Entities;
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.PlaylistBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
using Lumina.Domain.Fixtures.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.ValueObjects;
using Lumina.Domain.SharedKernel.Common.Enums.Playlists;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate;
/// <summary>
/// Fixture class for the <see cref="Playlist"/> domain aggregate.
/// </summary>
[ExcludeFromCodeCoverage]
public class PlaylistFixture
{
private readonly Faker _faker = new();
private readonly PlaylistIdFixture _playlistIdFixture = new();
private readonly UserIdFixture _userIdFixture = new();
/// <summary>
/// Creates a random valid <see cref="Playlist"/> domain aggregate, with pre-existing data.
/// </summary>
/// <param name="id">Optional. The Id of the playlist.</param>
/// <param name="userId">Optional. The Id of the user that owns the playlist.</param>
/// <param name="name">Optional. The name of the playlist.</param>
/// <param name="description">Optional. The description of the playlist.</param>
/// <param name="type">Optional. The kind of media the playlist holds. Defaults to the only supported kind.</param>
/// <param name="entries">Optional. The ordered entries of the playlist. Defaults to no entries.</param>
/// <param name="createdOnUtc">Optional. The date and time when the playlist was created. Defaults to a few days in the past.</param>
/// <param name="updatedOnUtc">Optional. The date and time when the playlist was last updated.</param>
/// <param name="includeDescription">Whether the description should be included, or forced to no value.</param>
/// <param name="includeUpdatedOnUtc">Whether the update date and time should be included, or forced to no value.</param>
/// <returns>The created <see cref="Playlist"/>.</returns>
/// <remarks>
/// The playlist is built through the rehydrating <see cref="Playlist.Create(PlaylistId, UserId, string, Optional{string}, PlaylistType, List{PlaylistEntry}, DateTime, Optional{DateTime})"/>
/// overload, so it carries no domain events and is never marked as deleted.
/// </remarks>
public Playlist Create(
PlaylistId? id = null,
UserId? userId = null,
string? name = null,
string? description = null,
PlaylistType? type = null,
IEnumerable<PlaylistEntry>? entries = null,
DateTime? createdOnUtc = null,
DateTime? updatedOnUtc = null,
bool includeDescription = true,
bool includeUpdatedOnUtc = false)
{
return Playlist.Create(
id ?? _playlistIdFixture.Create(),
userId ?? _userIdFixture.Create(),
name ?? _faker.Lorem.Sentence(3),
includeDescription ? Optional<string>.FromNullable(description ?? _faker.Lorem.Sentence()) : Optional<string>.None(),
type ?? PlaylistType.Music,
entries is null ? [] : [.. entries],
createdOnUtc ?? DateTime.UtcNow.AddDays(-_faker.Random.Int(1, 30)).AddMinutes(-_faker.Random.Int(0, 59)),
includeUpdatedOnUtc ? Optional<DateTime>.Some(updatedOnUtc ?? DateTime.UtcNow) : Optional<DateTime>.None()).Value;
}
/// <summary>
/// Creates multiple <see cref="Playlist"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="Playlist"/> instances.</returns>
public List<Playlist> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,37 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.ValueObjects;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.ValueObjects;
/// <summary>
/// Fixture class for the <see cref="PlaylistEntryId"/> value object.
/// </summary>
[ExcludeFromCodeCoverage]
public class PlaylistEntryIdFixture
{
/// <summary>
/// Creates a random valid <see cref="PlaylistEntryId"/>.
/// </summary>
/// <param name="value">Optional. The raw value of the playlist entry Id.</param>
/// <returns>The created <see cref="PlaylistEntryId"/>.</returns>
public PlaylistEntryId Create(
Guid? value = null)
{
return PlaylistEntryId.Create(value ?? Guid.NewGuid());
}
/// <summary>
/// Creates a list of <see cref="PlaylistEntryId"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="PlaylistEntryId"/> instances.</returns>
public List<PlaylistEntryId> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,37 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.ValueObjects;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.PlaylistBoundedContext.PlaylistAggregate.ValueObjects;
/// <summary>
/// Fixture class for the <see cref="PlaylistId"/> value object.
/// </summary>
[ExcludeFromCodeCoverage]
public class PlaylistIdFixture
{
/// <summary>
/// Creates a random valid <see cref="PlaylistId"/>.
/// </summary>
/// <param name="value">Optional. The raw value of the playlist Id.</param>
/// <returns>The created <see cref="PlaylistId"/>.</returns>
public PlaylistId Create(
Guid? value = null)
{
return PlaylistId.Create(value ?? Guid.NewGuid());
}
/// <summary>
/// Creates a list of <see cref="PlaylistId"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="PlaylistId"/> instances.</returns>
public List<PlaylistId> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,37 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ExternalIdentifiers.UserManagementBoundedContext.UserAggregate;
/// <summary>
/// Fixture class for the <see cref="UserId"/> value object.
/// </summary>
[ExcludeFromCodeCoverage]
public class UserIdFixture
{
/// <summary>
/// Creates a random valid <see cref="UserId"/>.
/// </summary>
/// <param name="value">Optional. The raw value of the user Id.</param>
/// <returns>The created <see cref="UserId"/>.</returns>
public UserId Create(
Guid? value = null)
{
return UserId.Create(value ?? Guid.NewGuid());
}
/// <summary>
/// Creates a list of <see cref="UserId"/> instances with randomized test data.
/// </summary>
/// <param name="count">Number of instances to create.</param>
/// <returns>List of configured <see cref="UserId"/> instances.</returns>
public List<UserId> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,36 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
/// <summary>
/// Fixture class for the <see cref="ScheduledJobAddedDomainEvent"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ScheduledJobAddedDomainEventFixture
{
private readonly ScheduledJobIdFixture _scheduledJobIdFixture = new();
/// <summary>
/// Creates a random valid <see cref="ScheduledJobAddedDomainEvent"/>.
/// </summary>
/// <param name="id">Optional. The Id of the domain event.</param>
/// <param name="scheduledJobId">Optional. The unique identifier of the scheduled job that was added.</param>
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
/// <returns>The created <see cref="ScheduledJobAddedDomainEvent"/>.</returns>
public ScheduledJobAddedDomainEvent Create(
Guid? id = null,
ScheduledJobId? scheduledJobId = null,
DateTime? occurredOnUtc = null)
{
return new ScheduledJobAddedDomainEvent(
id ?? Guid.NewGuid(),
scheduledJobId ?? _scheduledJobIdFixture.Create(),
occurredOnUtc ?? DateTime.UtcNow);
}
}
@@ -0,0 +1,36 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
/// <summary>
/// Fixture class for the <see cref="ScheduledJobCycleStartedDomainEvent"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ScheduledJobCycleStartedDomainEventFixture
{
private readonly ScheduledJobIdFixture _scheduledJobIdFixture = new();
/// <summary>
/// Creates a random valid <see cref="ScheduledJobCycleStartedDomainEvent"/>.
/// </summary>
/// <param name="id">Optional. The Id of the domain event.</param>
/// <param name="scheduledJobId">Optional. The unique identifier of the scheduled job whose execution cycle was started.</param>
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
/// <returns>The created <see cref="ScheduledJobCycleStartedDomainEvent"/>.</returns>
public ScheduledJobCycleStartedDomainEvent Create(
Guid? id = null,
ScheduledJobId? scheduledJobId = null,
DateTime? occurredOnUtc = null)
{
return new ScheduledJobCycleStartedDomainEvent(
id ?? Guid.NewGuid(),
scheduledJobId ?? _scheduledJobIdFixture.Create(),
occurredOnUtc ?? DateTime.UtcNow);
}
}
@@ -0,0 +1,36 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
/// <summary>
/// Fixture class for the <see cref="ScheduledJobCycleStoppedDomainEvent"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ScheduledJobCycleStoppedDomainEventFixture
{
private readonly ScheduledJobIdFixture _scheduledJobIdFixture = new();
/// <summary>
/// Creates a random valid <see cref="ScheduledJobCycleStoppedDomainEvent"/>.
/// </summary>
/// <param name="id">Optional. The Id of the domain event.</param>
/// <param name="scheduledJobId">Optional. The unique identifier of the scheduled job whose execution cycle was stopped.</param>
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
/// <returns>The created <see cref="ScheduledJobCycleStoppedDomainEvent"/>.</returns>
public ScheduledJobCycleStoppedDomainEvent Create(
Guid? id = null,
ScheduledJobId? scheduledJobId = null,
DateTime? occurredOnUtc = null)
{
return new ScheduledJobCycleStoppedDomainEvent(
id ?? Guid.NewGuid(),
scheduledJobId ?? _scheduledJobIdFixture.Create(),
occurredOnUtc ?? DateTime.UtcNow);
}
}
@@ -0,0 +1,46 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
/// <summary>
/// Fixture class for the <see cref="ScheduledJobExecutionCompletedDomainEvent"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ScheduledJobExecutionCompletedDomainEventFixture
{
private readonly ScheduledJobIdFixture _scheduledJobIdFixture = new();
/// <summary>
/// Creates a random valid <see cref="ScheduledJobExecutionCompletedDomainEvent"/>.
/// </summary>
/// <param name="id">Optional. The Id of the domain event.</param>
/// <param name="scheduledJobId">Optional. The unique identifier of the scheduled job whose task completed its execution.</param>
/// <param name="runId">Optional. The unique identifier of the current execution of the task of the scheduled job.</param>
/// <param name="taskType">The type of the task that completed its execution.</param>
/// <param name="isCycleRun">Whether the execution was triggered by the execution cycle of the scheduled job.</param>
/// <param name="completedOnUtc">Optional. The date and time when the execution completed.</param>
/// <returns>The created <see cref="ScheduledJobExecutionCompletedDomainEvent"/>.</returns>
public ScheduledJobExecutionCompletedDomainEvent Create(
Guid? id = null,
ScheduledJobId? scheduledJobId = null,
Guid? runId = null,
ScheduledTaskType taskType = ScheduledTaskType.ScanMediaLibraries,
bool isCycleRun = false,
DateTime? completedOnUtc = null)
{
return new ScheduledJobExecutionCompletedDomainEvent(
id ?? Guid.NewGuid(),
scheduledJobId ?? _scheduledJobIdFixture.Create(),
runId ?? Guid.NewGuid(),
taskType,
isCycleRun,
completedOnUtc ?? DateTime.UtcNow);
}
}
@@ -0,0 +1,46 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
/// <summary>
/// Fixture class for the <see cref="ScheduledJobExecutionStartedDomainEvent"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ScheduledJobExecutionStartedDomainEventFixture
{
private readonly ScheduledJobIdFixture _scheduledJobIdFixture = new();
/// <summary>
/// Creates a random valid <see cref="ScheduledJobExecutionStartedDomainEvent"/>.
/// </summary>
/// <param name="id">Optional. The Id of the domain event.</param>
/// <param name="scheduledJobId">Optional. The unique identifier of the scheduled job whose task started executing.</param>
/// <param name="runId">Optional. The unique identifier of the current execution of the task of the scheduled job.</param>
/// <param name="taskType">The type of the task that started executing.</param>
/// <param name="isCycleRun">Whether the execution was triggered by the execution cycle of the scheduled job.</param>
/// <param name="startedOnUtc">Optional. The date and time when the execution started.</param>
/// <returns>The created <see cref="ScheduledJobExecutionStartedDomainEvent"/>.</returns>
public ScheduledJobExecutionStartedDomainEvent Create(
Guid? id = null,
ScheduledJobId? scheduledJobId = null,
Guid? runId = null,
ScheduledTaskType taskType = ScheduledTaskType.ScanMediaLibraries,
bool isCycleRun = false,
DateTime? startedOnUtc = null)
{
return new ScheduledJobExecutionStartedDomainEvent(
id ?? Guid.NewGuid(),
scheduledJobId ?? _scheduledJobIdFixture.Create(),
runId ?? Guid.NewGuid(),
taskType,
isCycleRun,
startedOnUtc ?? DateTime.UtcNow);
}
}
@@ -0,0 +1,36 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
/// <summary>
/// Fixture class for the <see cref="ScheduledJobExecutionStoppedDomainEvent"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ScheduledJobExecutionStoppedDomainEventFixture
{
private readonly ScheduledJobIdFixture _scheduledJobIdFixture = new();
/// <summary>
/// Creates a random valid <see cref="ScheduledJobExecutionStoppedDomainEvent"/>.
/// </summary>
/// <param name="id">Optional. The Id of the domain event.</param>
/// <param name="scheduledJobId">Optional. The unique identifier of the scheduled job whose running execution was stopped.</param>
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
/// <returns>The created <see cref="ScheduledJobExecutionStoppedDomainEvent"/>.</returns>
public ScheduledJobExecutionStoppedDomainEvent Create(
Guid? id = null,
ScheduledJobId? scheduledJobId = null,
DateTime? occurredOnUtc = null)
{
return new ScheduledJobExecutionStoppedDomainEvent(
id ?? Guid.NewGuid(),
scheduledJobId ?? _scheduledJobIdFixture.Create(),
occurredOnUtc ?? DateTime.UtcNow);
}
}
@@ -0,0 +1,36 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
/// <summary>
/// Fixture class for the <see cref="ScheduledJobFiredDomainEvent"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ScheduledJobFiredDomainEventFixture
{
private readonly ScheduledJobIdFixture _scheduledJobIdFixture = new();
/// <summary>
/// Creates a random valid <see cref="ScheduledJobFiredDomainEvent"/>.
/// </summary>
/// <param name="id">Optional. The Id of the domain event.</param>
/// <param name="scheduledJobId">Optional. The unique identifier of the scheduled job whose task was fired.</param>
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
/// <returns>The created <see cref="ScheduledJobFiredDomainEvent"/>.</returns>
public ScheduledJobFiredDomainEvent Create(
Guid? id = null,
ScheduledJobId? scheduledJobId = null,
DateTime? occurredOnUtc = null)
{
return new ScheduledJobFiredDomainEvent(
id ?? Guid.NewGuid(),
scheduledJobId ?? _scheduledJobIdFixture.Create(),
occurredOnUtc ?? DateTime.UtcNow);
}
}
@@ -0,0 +1,36 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
using Lumina.Domain.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
using Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.ValueObjects;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.SchedulingBoundedContext.ScheduledJobAggregate.Events;
/// <summary>
/// Fixture class for the <see cref="ScheduledJobRemovedDomainEvent"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ScheduledJobRemovedDomainEventFixture
{
private readonly ScheduledJobIdFixture _scheduledJobIdFixture = new();
/// <summary>
/// Creates a random valid <see cref="ScheduledJobRemovedDomainEvent"/>.
/// </summary>
/// <param name="id">Optional. The Id of the domain event.</param>
/// <param name="scheduledJobId">Optional. The unique identifier of the scheduled job that was removed.</param>
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
/// <returns>The created <see cref="ScheduledJobRemovedDomainEvent"/>.</returns>
public ScheduledJobRemovedDomainEvent Create(
Guid? id = null,
ScheduledJobId? scheduledJobId = null,
DateTime? occurredOnUtc = null)
{
return new ScheduledJobRemovedDomainEvent(
id ?? Guid.NewGuid(),
scheduledJobId ?? _scheduledJobIdFixture.Create(),
occurredOnUtc ?? DateTime.UtcNow);
}
}
Loaded 100 of 6450 files, more files were not shown because too many files have changed in this diff. Show more