Removes the umbrella include flag from the fixtures and their consumers

This commit is contained in:
BinaryAlley committed 2026-09-27 23:05:06 +03:00
1 parent ab5cbfb949
commit 4d96fe10dd
43 files changed
+930 -349

No files matched your search

@@ -23,17 +23,17 @@ public class RoleEntityFixture
/// <param name="id">Optional. The Id of the role.</param>
/// <param name="roleName">Optional. The name of the role.</param>
/// <param name="rolePermissions">Optional. The role permission associations of the role.</param>
/// <param name="includeRolePermissions">Whether the role permission associations should be included, or forced to an empty collection.</param>
/// <param name="createdBy">Optional. The Id of the user that created the role.</param>
/// <param name="createdOnUtc">Optional. The time and date when the role was added.</param>
/// <param name="includeRolePermissions">Whether the role permission associations should be included, or forced to an empty collection.</param>
/// <returns>The created <see cref="RoleEntity"/>.</returns>
public RoleEntity Create(
Guid? id = null,
string? roleName = null,
IEnumerable<RolePermissionEntity>? rolePermissions = null,
bool includeRolePermissions = false,
Guid? createdBy = null,
DateTime? createdOnUtc = null)
DateTime? createdOnUtc = null,
bool includeRolePermissions = false)
{
return new Faker<RoleEntity>()
.CustomInstantiator(faker => new RoleEntity
@@ -20,7 +20,6 @@ namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Au
[ExcludeFromCodeCoverage]
public class TrackEntityFixture
{
private readonly Random _random = new();
private readonly Faker _faker = new();
private readonly TagEntityFixture _tagEntityFixture = new();
private readonly GenreEntityFixture _genreEntityFixture = new();
@@ -38,11 +37,11 @@ public class TrackEntityFixture
/// <param name="path">Optional. The file system path of the track.</param>
/// <param name="title">Optional. The title of the track.</param>
/// <param name="trackNumber">Optional. The number of the track on its disc.</param>
/// <param name="includeMetadata">Whether the owned metadata collections (Tags, Genres, Moods, ISRCs, Contributors, Ratings) should be included, or forced to empty collections.</param>
/// <param name="originalReleaseDate">Optional. The original release date of the track.</param>
/// <param name="originalReleaseYear">Optional. The original release year of the track.</param>
/// <param name="reReleaseDate">Optional. The re-release date of the track.</param>
/// <param name="reReleaseYear">Optional. The re-release year of the track.</param>
/// <param name="includeMetadata">Whether the owned metadata collections (Tags, Genres, Moods, ISRCs, Contributors, Ratings) should be included, or forced to empty collections.</param>
/// <param name="includeOriginalReleaseDate">Whether the original release date should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeOriginalReleaseYear">Whether the original release year should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeReReleaseDate">Whether the re-release date should be included, or forced to <see langword="null"/>.</param>
@@ -55,11 +54,11 @@ public class TrackEntityFixture
string? path = null,
string? title = null,
int? trackNumber = null,
bool includeMetadata = true,
DateOnly? originalReleaseDate = null,
int? originalReleaseYear = null,
DateOnly? reReleaseDate = null,
int? reReleaseYear = null,
bool includeMetadata = true,
bool includeOriginalReleaseDate = true,
bool includeOriginalReleaseYear = true,
bool includeReReleaseDate = true,
@@ -69,9 +68,9 @@ public class TrackEntityFixture
Guid resolvedAlbumId = albumId ?? Guid.NewGuid();
Guid resolvedLibraryId = libraryId ?? Guid.NewGuid();
const int MAXIMUM_RELEASE_YEAR = 2026;
int resolvedOriginalReleaseYear = originalReleaseYear ?? _random.Next(1900, MAXIMUM_RELEASE_YEAR);
int resolvedOriginalReleaseYear = originalReleaseYear ?? Random.Shared.Next(1900, MAXIMUM_RELEASE_YEAR);
int resolvedReReleaseYearUpperBound = Math.Max(resolvedOriginalReleaseYear + 1, MAXIMUM_RELEASE_YEAR);
int resolvedReReleaseYear = reReleaseYear ?? _random.Next(resolvedOriginalReleaseYear, resolvedReReleaseYearUpperBound);
int resolvedReReleaseYear = reReleaseYear ?? Random.Shared.Next(resolvedOriginalReleaseYear, resolvedReReleaseYearUpperBound);
DateOnly resolvedOriginalReleaseDate = originalReleaseDate ?? _faker.DateOnlyBetween(new DateOnly(resolvedOriginalReleaseYear, 1, 1), new DateOnly(resolvedOriginalReleaseYear, 12, 31));
DateOnly resolvedReReleaseDate = reReleaseDate ?? _faker.DateOnlyBetween(resolvedReReleaseYear == resolvedOriginalReleaseYear ? resolvedOriginalReleaseDate : new DateOnly(resolvedReReleaseYear, 1, 1), new DateOnly(resolvedReReleaseYear, 12, 31));
@@ -103,17 +102,17 @@ public class TrackEntityFixture
.RuleFor(x => x.OriginalLanguageCode, f => f.Random.String2(2))
.RuleFor(x => x.OriginalLanguageName, f => f.Random.String2(f.Random.Number(1, 50)))
.RuleFor(x => x.OriginalLanguageNativeName, f => f.Random.String2(f.Random.Number(1, 50)))
.RuleFor(x => x.DurationInSeconds, _random.Next(60, 7200))
.RuleFor(x => x.DurationInSeconds, Random.Shared.Next(60, 7200))
.RuleFor(x => x.SampleRate, f => f.PickRandom(44100, 48000, 96000))
.RuleFor(x => x.Channels, f => f.PickRandom(1, 2, 6))
.RuleFor(x => x.BitDepth, _random.Next(8, 32))
.RuleFor(x => x.BitDepth, Random.Shared.Next(8, 32))
.RuleFor(x => x.AudioCodec, f => f.PickRandom("FLAC", "MP3", "AAC", "ALAC"))
.RuleFor(x => x.Bitrate, _random.Next(96, 1411))
.RuleFor(x => x.Bitrate, Random.Shared.Next(96, 1411))
.RuleFor(x => x.TrackNumber, f => trackNumber ?? f.Random.Int(1, 20))
.RuleFor(x => x.DiscNumber, _random.Next(1, 3))
.RuleFor(x => x.DiscNumber, Random.Shared.Next(1, 3))
.RuleFor(x => x.Script, f => f.Random.String2(f.Random.Number(1, 50)))
.RuleFor(x => x.Key, f => f.PickRandom<MusicKey>())
.RuleFor(x => x.Bpm, _random.Next(40, 240))
.RuleFor(x => x.Bpm, Random.Shared.Next(40, 240))
.RuleFor(x => x.Work, f => f.Music.Genre())
.RuleFor(x => x.MusicBrainzRecordingId, f => f.Random.Guid())
.RuleFor(x => x.MusicBrainzTrackId, f => f.Random.Guid())
@@ -26,17 +26,17 @@ public class ThemeEntityFixture
/// <param name="author">Optional author of the theme.</param>
/// <param name="version">Optional version of the theme.</param>
/// <param name="previewPath">Optional preview image path of the theme, or <see langword="null"/> when the theme has no preview.</param>
/// <param name="includePreviewPath">Whether the preview path should be included, or forced to <see langword="null"/>.</param>
/// <param name="installSource">Optional source the theme was installed from.</param>
/// <param name="isCurrent">Optional value indicating whether the theme is the currently active one.</param>
/// <param name="includeIsCurrent">Whether the currently active flag should be included, or forced to <see langword="null"/>.</param>
/// <param name="isDeleted">Optional value indicating whether the theme was soft deleted.</param>
/// <param name="installedAtUtc">Optional UTC timestamp when the theme was installed.</param>
/// <param name="createdOnUtc">Optional UTC timestamp when the entity was created.</param>
/// <param name="createdBy">Optional Id of the user that created the entity.</param>
/// <param name="updatedOnUtc">Optional UTC timestamp when the entity was updated.</param>
/// <param name="includeUpdatedOnUtc">Whether the updated-on timestamp should be included, or forced to <see langword="null"/>.</param>
/// <param name="updatedBy">Optional Id of the user that updated the entity.</param>
/// <param name="includePreviewPath">Whether the preview path should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeIsCurrent">Whether the currently active flag should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeUpdatedOnUtc">Whether the updated-on timestamp should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeUpdatedBy">Whether the updated-by user Id should be included, or forced to <see langword="null"/>.</param>
/// <returns>A configured <see cref="ThemeEntity"/> instance.</returns>
public ThemeEntity Create(
@@ -47,17 +47,17 @@ public class ThemeEntityFixture
string? author = null,
string? version = null,
string? previewPath = null,
bool includePreviewPath = false,
ThemeInstallSource? installSource = null,
bool? isCurrent = null,
bool includeIsCurrent = false,
bool? isDeleted = null,
DateTime? installedAtUtc = null,
DateTime? createdOnUtc = null,
Guid? createdBy = null,
DateTime? updatedOnUtc = null,
bool includeUpdatedOnUtc = false,
Guid? updatedBy = null,
bool includePreviewPath = false,
bool includeIsCurrent = false,
bool includeUpdatedOnUtc = false,
bool includeUpdatedBy = false)
{
Guid resolvedCreatedBy = createdBy ?? Guid.NewGuid();
@@ -29,9 +29,9 @@ public class UserEntityFixture
/// <param name="id">Optional Id to pin, or <see langword="null"/> to generate a random one.</param>
/// <param name="userRole">Optional user role association to pin when including it.</param>
/// <param name="userPermissions">Optional user permission associations to pin when including them.</param>
/// <param name="libraries">Optional collection of libraries to pin for the user, or <see langword="null"/> to generate them based on <paramref name="libraryCount"/>.</param>
/// <param name="includeUserRole">Whether the user role association should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeUserPermissions">Whether the user permission associations should be included, or forced to an empty collection.</param>
/// <param name="libraries">Optional collection of libraries to pin for the user, or <see langword="null"/> to generate them based on <paramref name="libraryCount"/>.</param>
/// <returns>The created user entity.</returns>
public UserEntity Create(
int libraryCount = 0,
@@ -40,9 +40,9 @@ public class UserEntityFixture
Guid? id = null,
UserRoleEntity? userRole = null,
IEnumerable<UserPermissionEntity>? userPermissions = null,
ICollection<LibraryEntity>? libraries = null,
bool includeUserRole = false,
bool includeUserPermissions = false,
ICollection<LibraryEntity>? libraries = null)
bool includeUserPermissions = false)
{
Guid userId = id ?? Guid.NewGuid();
ICollection<LibraryEntity> resolvedLibraries = libraries ?? (libraryCount > 0
@@ -25,8 +25,8 @@ public class ThemeManifestDtoFixture
/// <param name="author">Optional author of the theme.</param>
/// <param name="version">Optional version of the theme.</param>
/// <param name="preview">Optional preview image path of the theme, or <see langword="null"/> when the theme has no preview.</param>
/// <param name="includePreview">Whether the preview path should be included, or forced to <see langword="null"/>.</param>
/// <param name="templates">Optional template mappings of the theme.</param>
/// <param name="includePreview">Whether the preview path should be included, or forced to <see langword="null"/>.</param>
/// <returns>A configured <see cref="ThemeManifestDto"/> instance.</returns>
public ThemeManifestDto Create(
int? schemaVersion = null,
@@ -36,8 +36,8 @@ public class ThemeManifestDtoFixture
string? author = null,
string? version = null,
string? preview = null,
bool includePreview = false,
Dictionary<string, string>? templates = null)
Dictionary<string, string>? templates = null,
bool includePreview = false)
{
return new Faker<ThemeManifestDto>()
.CustomInstantiator(f => new ThemeManifestDto
@@ -60,7 +60,16 @@ public class AddTrackCommandFixture
/// <param name="includePath">Whether the path should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMetadata">Whether the metadata should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeTrackNumber">Whether the track number should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeOptionalProperties">Whether the properties that are not explicitly provided should be randomized, or forced to <see langword="null"/>.</param>
/// <param name="includeDiscNumber">Whether the disc number should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeScript">Whether the script should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeKey">Whether the musical key should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeBpm">Whether the tempo should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeWork">Whether the work should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzRecordingId">Whether the MusicBrainz recording Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzTrackId">Whether the MusicBrainz track Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzWorkId">Whether the MusicBrainz work Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMoods">Whether the moods should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeIsrcs">Whether the ISRC codes should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeContributors">Whether the contributors should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeRatings">Whether the ratings should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created command to add a track.</returns>
@@ -90,7 +99,16 @@ public class AddTrackCommandFixture
bool includePath = true,
bool includeMetadata = true,
bool includeTrackNumber = true,
bool includeOptionalProperties = true,
bool includeDiscNumber = true,
bool includeScript = true,
bool includeKey = true,
bool includeBpm = true,
bool includeWork = true,
bool includeMusicBrainzRecordingId = true,
bool includeMusicBrainzTrackId = true,
bool includeMusicBrainzWorkId = true,
bool includeMoods = true,
bool includeIsrcs = true,
bool includeContributors = true,
bool includeRatings = true)
{
@@ -101,16 +119,16 @@ public class AddTrackCommandFixture
includePath ? path ?? Path.Combine(Path.GetTempPath(), "lumina-tracks", _faker.System.FileName()) : null,
includeMetadata ? metadata ?? _audioMetadataDtoFixture.Create() : null,
includeTrackNumber ? trackNumber ?? _faker.Random.Int(1, 30) : null,
includeOptionalProperties ? discNumber ?? _faker.Random.Int(1, 3) : null,
includeOptionalProperties ? script ?? _faker.Random.AlphaNumeric(4) : null,
includeOptionalProperties ? key ?? _faker.PickRandom<MusicKey>() : null,
includeOptionalProperties ? bpm ?? _faker.Random.Int(40, 220) : null,
includeOptionalProperties ? work ?? _faker.Lorem.Sentence() : null,
includeOptionalProperties ? musicBrainzRecordingId ?? _faker.Random.Guid() : null,
includeOptionalProperties ? musicBrainzTrackId ?? _faker.Random.Guid() : null,
includeOptionalProperties ? musicBrainzWorkId ?? _faker.Random.Guid() : null,
includeOptionalProperties ? moods ?? _moodDtoFixture.CreateMany(_faker.Random.Int(1, 3)) : null,
includeOptionalProperties ? isrcs ?? _isrcDtoFixture.CreateMany(_faker.Random.Int(1, 3)) : null,
includeDiscNumber ? discNumber ?? _faker.Random.Int(1, 3) : null,
includeScript ? script ?? _faker.Random.AlphaNumeric(4) : null,
includeKey ? key ?? _faker.PickRandom<MusicKey>() : null,
includeBpm ? bpm ?? _faker.Random.Int(40, 220) : null,
includeWork ? work ?? _faker.Lorem.Sentence() : null,
includeMusicBrainzRecordingId ? musicBrainzRecordingId ?? _faker.Random.Guid() : null,
includeMusicBrainzTrackId ? musicBrainzTrackId ?? _faker.Random.Guid() : null,
includeMusicBrainzWorkId ? musicBrainzWorkId ?? _faker.Random.Guid() : null,
includeMoods ? moods ?? _moodDtoFixture.CreateMany(_faker.Random.Int(1, 3)) : null,
includeIsrcs ? isrcs ?? _isrcDtoFixture.CreateMany(_faker.Random.Int(1, 3)) : null,
includeContributors ? contributors ?? _mediaContributorReferenceDtoFixture.CreateMany(_faker.Random.Int(1, 3)) : null,
includeRatings ? ratings ?? _audioRatingDtoFixture.CreateMany(_faker.Random.Int(1, 3)) : null,
trackId);
@@ -53,7 +53,16 @@ public class UpdateTrackCommandFixture
/// <param name="isrcs">Optional. The ISRC codes of the track.</param>
/// <param name="contributors">Optional. The media contributors that performed on the track.</param>
/// <param name="ratings">Optional. The ratings of the track.</param>
/// <param name="includeOptionalProperties">Whether the optional properties that are not explicitly provided should be randomized, or forced to <see langword="null"/>.</param>
/// <param name="includeDiscNumber">Whether the disc number should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeScript">Whether the script should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeKey">Whether the musical key should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeBpm">Whether the tempo should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeWork">Whether the work should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzRecordingId">Whether the MusicBrainz recording Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzTrackId">Whether the MusicBrainz track Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzWorkId">Whether the MusicBrainz work Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMoods">Whether the moods should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeIsrcs">Whether the ISRC codes should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMetadata">Whether the metadata should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeContributors">Whether the contributors list should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeRatings">Whether the ratings list should be included, or forced to <see langword="null"/>.</param>
@@ -84,7 +93,16 @@ public class UpdateTrackCommandFixture
List<IsrcDto>? isrcs = null,
List<MediaContributorReferenceDto>? contributors = null,
List<AudioRatingDto>? ratings = null,
bool includeOptionalProperties = true,
bool includeDiscNumber = true,
bool includeScript = true,
bool includeKey = true,
bool includeBpm = true,
bool includeWork = true,
bool includeMusicBrainzRecordingId = true,
bool includeMusicBrainzTrackId = true,
bool includeMusicBrainzWorkId = true,
bool includeMoods = true,
bool includeIsrcs = true,
bool includeMetadata = true,
bool includeContributors = true,
bool includeRatings = true,
@@ -103,16 +121,16 @@ public class UpdateTrackCommandFixture
includePath ? (path ?? _faker.System.FilePath()) : null,
includeMetadata ? (metadata ?? _audioMetadataDtoFixture.Create()) : null,
includeTrackNumber ? (trackNumber ?? _faker.Random.Int(1, 20)) : null,
includeOptionalProperties ? (discNumber ?? _faker.Random.Int(1, 3)) : null,
includeOptionalProperties ? (script ?? _faker.Random.String2(_faker.Random.Number(1, 50))) : null,
includeOptionalProperties ? (key ?? _faker.PickRandom<MusicKey>()) : null,
includeOptionalProperties ? (bpm ?? _faker.Random.Int(40, 240)) : null,
includeOptionalProperties ? (work ?? _faker.Music.Genre()) : null,
includeOptionalProperties ? (musicBrainzRecordingId ?? _faker.Random.Guid()) : null,
includeOptionalProperties ? (musicBrainzTrackId ?? _faker.Random.Guid()) : null,
includeOptionalProperties ? (musicBrainzWorkId ?? _faker.Random.Guid()) : null,
includeOptionalProperties ? (moods ?? [.. _moodDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null,
includeOptionalProperties ? (isrcs ?? [.. _isrcDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null,
includeDiscNumber ? (discNumber ?? _faker.Random.Int(1, 3)) : null,
includeScript ? (script ?? _faker.Random.String2(_faker.Random.Number(1, 50))) : null,
includeKey ? (key ?? _faker.PickRandom<MusicKey>()) : null,
includeBpm ? (bpm ?? _faker.Random.Int(40, 240)) : null,
includeWork ? (work ?? _faker.Music.Genre()) : null,
includeMusicBrainzRecordingId ? (musicBrainzRecordingId ?? _faker.Random.Guid()) : null,
includeMusicBrainzTrackId ? (musicBrainzTrackId ?? _faker.Random.Guid()) : null,
includeMusicBrainzWorkId ? (musicBrainzWorkId ?? _faker.Random.Guid()) : null,
includeMoods ? (moods ?? [.. _moodDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null,
includeIsrcs ? (isrcs ?? [.. _isrcDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null,
includeContributors ? (contributors ?? [.. _mediaContributorReferenceDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null,
includeRatings ? (ratings ?? [.. _audioRatingDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null);
}
@@ -51,7 +51,21 @@ public class AddBookCommandFixture
/// <param name="contributors">Optional. The contributors of the book.</param>
/// <param name="ratings">Optional. The ratings of the book.</param>
/// <param name="includeMetadata">Whether the metadata should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeOptionalProperties">Whether the properties that are not explicitly provided should be randomized, or forced to <see langword="null"/>.</param>
/// <param name="includeFormat">Whether the format should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeEdition">Whether the edition should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeVolumeNumber">Whether the volume number should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAsin">Whether the ASIN should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeGoodreadsId">Whether the Goodreads Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLccn">Whether the LCCN should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeOclcNumber">Whether the OCLC number should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeOpenLibraryId">Whether the Open Library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLibraryThingId">Whether the LibraryThing Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeGoogleBooksId">Whether the Google Books Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeBarnesAndNobleId">Whether the Barnes and Noble Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAppleBooksId">Whether the Apple Books Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeIsbns">Whether the ISBNs should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeRatings">Whether the ratings should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeContributors">Whether the contributors should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created command to add a book.</returns>
public AddBookCommand Create(
string? libraryId = null,
@@ -74,7 +88,21 @@ public class AddBookCommandFixture
List<MediaContributorReferenceDto>? contributors = null,
List<BookRatingDto>? ratings = null,
bool includeMetadata = true,
bool includeOptionalProperties = true)
bool includeFormat = true,
bool includeEdition = true,
bool includeVolumeNumber = true,
bool includeAsin = true,
bool includeGoodreadsId = true,
bool includeLccn = true,
bool includeOclcNumber = true,
bool includeOpenLibraryId = true,
bool includeLibraryThingId = true,
bool includeGoogleBooksId = true,
bool includeBarnesAndNobleId = true,
bool includeAppleBooksId = true,
bool includeIsbns = true,
bool includeRatings = true,
bool includeContributors = true)
{
return new Faker<AddBookCommand>()
.CustomInstantiator(f => new AddBookCommand(
@@ -101,22 +129,22 @@ public class AddBookCommandFixture
.RuleFor(x => x.LibraryId, libraryId ?? Guid.NewGuid().ToString())
.RuleFor(x => x.Path, f => path ?? Path.Combine(Path.GetTempPath(), "lumina-books", f.System.FileName()))
.RuleFor(x => x.Metadata, includeMetadata ? (metadata ?? _writtenContentMetadataDtoFixture.Create()) : null)
.RuleFor(x => x.Format, f => format ?? (includeOptionalProperties ? f.PickRandom<BookFormat>() : null))
.RuleFor(x => x.Edition, f => edition ?? (includeOptionalProperties ? f.Random.String2(f.Random.Number(1, 50)) : null))
.RuleFor(x => x.VolumeNumber, f => volumeNumber ?? (includeOptionalProperties ? (float?)f.Random.Number(1, 3) : null))
.RuleFor(x => x.Format, f => format ?? (includeFormat ? f.PickRandom<BookFormat>() : null))
.RuleFor(x => x.Edition, f => edition ?? (includeEdition ? f.Random.String2(f.Random.Number(1, 50)) : null))
.RuleFor(x => x.VolumeNumber, f => volumeNumber ?? (includeVolumeNumber ? (float?)f.Random.Number(1, 3) : null))
.RuleFor(x => x.Series, series)
.RuleFor(x => x.ASIN, f => asin ?? (includeOptionalProperties ? f.Random.String2(10) : null))
.RuleFor(x => x.GoodreadsId, f => goodreadsId ?? (includeOptionalProperties ? f.Random.Number(100000, 500000).ToString() : null))
.RuleFor(x => x.LCCN, f => lccn ?? (includeOptionalProperties ? CreateLccn(f) : null))
.RuleFor(x => x.OCLCNumber, f => oclcNumber ?? (includeOptionalProperties ? CreateOclcNumber(f) : null))
.RuleFor(x => x.OpenLibraryId, f => openLibraryId ?? (includeOptionalProperties ? CreateOpenLibraryId(f) : null))
.RuleFor(x => x.LibraryThingId, f => libraryThingId ?? (includeOptionalProperties ? f.Random.String2(f.Random.Number(1, 50)) : null))
.RuleFor(x => x.GoogleBooksId, f => googleBooksId ?? (includeOptionalProperties ? CreateGoogleBooksId(f) : null))
.RuleFor(x => x.BarnesAndNobleId, f => barnesAndNobleId ?? (includeOptionalProperties ? f.Random.String2(10, "0123456789") : null))
.RuleFor(x => x.AppleBooksId, f => appleBooksId ?? (includeOptionalProperties ? $"id{f.Random.Number(1, 999999)}" : null))
.RuleFor(p => p.ISBNs, f => isbns ?? (includeOptionalProperties ? [.. _isbnDtoFixture.CreateMany(f.Random.Number(1, 3))] : null))
.RuleFor(p => p.Ratings, f => ratings ?? (includeOptionalProperties ? [.. _bookRatingDtoFixture.CreateMany(f.Random.Number(1, 3))] : null))
.RuleFor(x => x.Contributors, f => contributors ?? (includeOptionalProperties ? [.. _mediaContributorReferenceDtoFixture.CreateMany(f.Random.Number(1, 3))] : null));
.RuleFor(x => x.ASIN, f => asin ?? (includeAsin ? f.Random.String2(10) : null))
.RuleFor(x => x.GoodreadsId, f => goodreadsId ?? (includeGoodreadsId ? f.Random.Number(100000, 500000).ToString() : null))
.RuleFor(x => x.LCCN, f => lccn ?? (includeLccn ? CreateLccn(f) : null))
.RuleFor(x => x.OCLCNumber, f => oclcNumber ?? (includeOclcNumber ? CreateOclcNumber(f) : null))
.RuleFor(x => x.OpenLibraryId, f => openLibraryId ?? (includeOpenLibraryId ? CreateOpenLibraryId(f) : null))
.RuleFor(x => x.LibraryThingId, f => libraryThingId ?? (includeLibraryThingId ? f.Random.String2(f.Random.Number(1, 50)) : null))
.RuleFor(x => x.GoogleBooksId, f => googleBooksId ?? (includeGoogleBooksId ? CreateGoogleBooksId(f) : null))
.RuleFor(x => x.BarnesAndNobleId, f => barnesAndNobleId ?? (includeBarnesAndNobleId ? f.Random.String2(10, "0123456789") : null))
.RuleFor(x => x.AppleBooksId, f => appleBooksId ?? (includeAppleBooksId ? $"id{f.Random.Number(1, 999999)}" : null))
.RuleFor(p => p.ISBNs, f => isbns ?? (includeIsbns ? [.. _isbnDtoFixture.CreateMany(f.Random.Number(1, 3))] : null))
.RuleFor(p => p.Ratings, f => ratings ?? (includeRatings ? [.. _bookRatingDtoFixture.CreateMany(f.Random.Number(1, 3))] : null))
.RuleFor(x => x.Contributors, f => contributors ?? (includeContributors ? [.. _mediaContributorReferenceDtoFixture.CreateMany(f.Random.Number(1, 3))] : null));
}
/// <summary>
@@ -51,7 +51,21 @@ public class UpdateBookCommandFixture
/// <param name="contributors">Optional. The contributors of the book.</param>
/// <param name="ratings">Optional. The ratings of the book.</param>
/// <param name="includeMetadata">Whether the metadata should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeOptionalProperties">Whether the properties that are not explicitly provided should be randomized, or forced to <see langword="null"/>.</param>
/// <param name="includeFormat">Whether the format should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeEdition">Whether the edition should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeVolumeNumber">Whether the volume number should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAsin">Whether the ASIN should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeGoodreadsId">Whether the Goodreads Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLccn">Whether the LCCN should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeOclcNumber">Whether the OCLC number should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeOpenLibraryId">Whether the Open Library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLibraryThingId">Whether the LibraryThing Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeGoogleBooksId">Whether the Google Books Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeBarnesAndNobleId">Whether the Barnes and Noble Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAppleBooksId">Whether the Apple Books Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeIsbns">Whether the ISBNs should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeRatings">Whether the ratings should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeContributors">Whether the contributors should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created command to update a book.</returns>
public UpdateBookCommand Create(
string? libraryId = null,
@@ -74,7 +88,21 @@ public class UpdateBookCommandFixture
List<MediaContributorReferenceDto>? contributors = null,
List<BookRatingDto>? ratings = null,
bool includeMetadata = true,
bool includeOptionalProperties = true)
bool includeFormat = true,
bool includeEdition = true,
bool includeVolumeNumber = true,
bool includeAsin = true,
bool includeGoodreadsId = true,
bool includeLccn = true,
bool includeOclcNumber = true,
bool includeOpenLibraryId = true,
bool includeLibraryThingId = true,
bool includeGoogleBooksId = true,
bool includeBarnesAndNobleId = true,
bool includeAppleBooksId = true,
bool includeIsbns = true,
bool includeRatings = true,
bool includeContributors = true)
{
return new Faker<UpdateBookCommand>()
.CustomInstantiator(f => new UpdateBookCommand(
@@ -101,22 +129,22 @@ public class UpdateBookCommandFixture
.RuleFor(x => x.LibraryId, libraryId ?? Guid.NewGuid().ToString())
.RuleFor(x => x.BookId, bookId ?? Guid.NewGuid().ToString())
.RuleFor(x => x.Metadata, includeMetadata ? (metadata ?? _writtenContentMetadataDtoFixture.Create()) : null)
.RuleFor(x => x.Format, f => format ?? (includeOptionalProperties ? f.PickRandom<BookFormat>() : null))
.RuleFor(x => x.Edition, f => edition ?? (includeOptionalProperties ? f.Random.String2(f.Random.Number(1, 50)) : null))
.RuleFor(x => x.VolumeNumber, f => volumeNumber ?? (includeOptionalProperties ? (float?)f.Random.Number(1, 3) : null))
.RuleFor(x => x.Format, f => format ?? (includeFormat ? f.PickRandom<BookFormat>() : null))
.RuleFor(x => x.Edition, f => edition ?? (includeEdition ? f.Random.String2(f.Random.Number(1, 50)) : null))
.RuleFor(x => x.VolumeNumber, f => volumeNumber ?? (includeVolumeNumber ? (float?)f.Random.Number(1, 3) : null))
.RuleFor(x => x.Series, series)
.RuleFor(x => x.ASIN, f => asin ?? (includeOptionalProperties ? f.Random.String2(10) : null))
.RuleFor(x => x.GoodreadsId, f => goodreadsId ?? (includeOptionalProperties ? f.Random.Number(100000, 500000).ToString() : null))
.RuleFor(x => x.LCCN, f => lccn ?? (includeOptionalProperties ? CreateLccn(f) : null))
.RuleFor(x => x.OCLCNumber, f => oclcNumber ?? (includeOptionalProperties ? CreateOclcNumber(f) : null))
.RuleFor(x => x.OpenLibraryId, f => openLibraryId ?? (includeOptionalProperties ? CreateOpenLibraryId(f) : null))
.RuleFor(x => x.LibraryThingId, f => libraryThingId ?? (includeOptionalProperties ? f.Random.String2(f.Random.Number(1, 50)) : null))
.RuleFor(x => x.GoogleBooksId, f => googleBooksId ?? (includeOptionalProperties ? CreateGoogleBooksId(f) : null))
.RuleFor(x => x.BarnesAndNobleId, f => barnesAndNobleId ?? (includeOptionalProperties ? f.Random.String2(10, "0123456789") : null))
.RuleFor(x => x.AppleBooksId, f => appleBooksId ?? (includeOptionalProperties ? $"id{f.Random.Number(1, 999999)}" : null))
.RuleFor(p => p.ISBNs, f => isbns ?? (includeOptionalProperties ? [.. _isbnDtoFixture.CreateMany(f.Random.Number(1, 3))] : null))
.RuleFor(p => p.Ratings, f => ratings ?? (includeOptionalProperties ? [.. _bookRatingDtoFixture.CreateMany(f.Random.Number(1, 3))] : null))
.RuleFor(x => x.Contributors, f => contributors ?? (includeOptionalProperties ? [.. _mediaContributorReferenceDtoFixture.CreateMany(f.Random.Number(1, 3))] : null));
.RuleFor(x => x.ASIN, f => asin ?? (includeAsin ? f.Random.String2(10) : null))
.RuleFor(x => x.GoodreadsId, f => goodreadsId ?? (includeGoodreadsId ? f.Random.Number(100000, 500000).ToString() : null))
.RuleFor(x => x.LCCN, f => lccn ?? (includeLccn ? CreateLccn(f) : null))
.RuleFor(x => x.OCLCNumber, f => oclcNumber ?? (includeOclcNumber ? CreateOclcNumber(f) : null))
.RuleFor(x => x.OpenLibraryId, f => openLibraryId ?? (includeOpenLibraryId ? CreateOpenLibraryId(f) : null))
.RuleFor(x => x.LibraryThingId, f => libraryThingId ?? (includeLibraryThingId ? f.Random.String2(f.Random.Number(1, 50)) : null))
.RuleFor(x => x.GoogleBooksId, f => googleBooksId ?? (includeGoogleBooksId ? CreateGoogleBooksId(f) : null))
.RuleFor(x => x.BarnesAndNobleId, f => barnesAndNobleId ?? (includeBarnesAndNobleId ? f.Random.String2(10, "0123456789") : null))
.RuleFor(x => x.AppleBooksId, f => appleBooksId ?? (includeAppleBooksId ? $"id{f.Random.Number(1, 999999)}" : null))
.RuleFor(p => p.ISBNs, f => isbns ?? (includeIsbns ? [.. _isbnDtoFixture.CreateMany(f.Random.Number(1, 3))] : null))
.RuleFor(p => p.Ratings, f => ratings ?? (includeRatings ? [.. _bookRatingDtoFixture.CreateMany(f.Random.Number(1, 3))] : null))
.RuleFor(x => x.Contributors, f => contributors ?? (includeContributors ? [.. _mediaContributorReferenceDtoFixture.CreateMany(f.Random.Number(1, 3))] : null));
}
/// <summary>
@@ -17,7 +17,6 @@ namespace Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary;
public class AudioRatingDtoFixture
{
private readonly Fixture _fixture = new();
private readonly Random _random = new();
/// <summary>
/// Creates a random valid <see cref="AudioRatingDto"/>.
@@ -26,6 +25,8 @@ public class AudioRatingDtoFixture
/// <param name="maxValue">Optional. The maximum possible rating value.</param>
/// <param name="source">Optional. The rating source.</param>
/// <param name="voteCount">Optional. The number of votes.</param>
/// <param name="includeValue">Whether the rating value should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMaxValue">Whether the maximum possible rating value should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeSource">Whether the rating source should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeVoteCount">Whether the number of votes should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="AudioRatingDto"/>.</returns>
@@ -34,14 +35,16 @@ public class AudioRatingDtoFixture
decimal? maxValue = null,
AudioRatingSource? source = null,
int? voteCount = null,
bool includeValue = true,
bool includeMaxValue = true,
bool includeSource = true,
bool includeVoteCount = true)
{
return new AudioRatingDto(
value ?? _random.Next(1, 5),
maxValue ?? 5,
includeValue ? (value ?? Random.Shared.Next(1, 5)) : null,
includeMaxValue ? (maxValue ?? 5) : null,
includeSource ? (source ?? _fixture.Create<AudioRatingSource>()) : null,
includeVoteCount ? (voteCount ?? _random.Next(1, 1000)) : null
includeVoteCount ? (voteCount ?? Random.Shared.Next(1, 1000)) : null
);
}
@@ -57,7 +57,12 @@ public class BookMetadataDtoFixture
/// <param name="ratings">Optional. The ratings of the book.</param>
/// <param name="coverImagePath">Optional. The path of the cover image of the book.</param>
/// <param name="includeTitle">Whether the title should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeOptionalProperties">Whether the properties that are not explicitly provided should be randomized, or forced to <see langword="null"/>.</param>
/// <param name="includeReleaseInfo">Whether the release info should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeGenres">Whether the genres should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeTags">Whether the tags should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLanguage">Whether the language should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeFormat">Whether the format should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeVolumeNumber">Whether the volume number should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="BookMetadataDto"/>.</returns>
public BookMetadataDto Create(
string? title = null,
@@ -88,26 +93,31 @@ public class BookMetadataDtoFixture
List<BookRatingDto>? ratings = null,
string? coverImagePath = null,
bool includeTitle = true,
bool includeOptionalProperties = true)
bool includeReleaseInfo = true,
bool includeGenres = true,
bool includeTags = true,
bool includeLanguage = true,
bool includeFormat = true,
bool includeVolumeNumber = true)
{
int releaseYear = _faker.Random.Int(1900, 2024);
return new BookMetadataDto(
includeTitle ? title ?? (includeOptionalProperties ? _faker.Lorem.Sentence(3) : null) : null,
includeTitle ? title ?? _faker.Lorem.Sentence(3) : null,
originalTitle,
description,
releaseInfo ?? (includeOptionalProperties ? _releaseInfoDtoFixture.Create(
includeReleaseInfo ? (releaseInfo ?? _releaseInfoDtoFixture.Create(
originalReleaseDate: new DateOnly(releaseYear, 1, 1),
originalReleaseYear: releaseYear,
releaseCountry: _faker.PickRandom<ReleaseCountry>()) : null),
genres ?? (includeOptionalProperties ? [_genreDtoFixture.Create()] : null),
tags ?? (includeOptionalProperties ? [_tagDtoFixture.Create()] : null),
language ?? (includeOptionalProperties ? _languageInfoDtoFixture.Create() : null),
releaseCountry: _faker.PickRandom<ReleaseCountry>())) : null,
includeGenres ? (genres ?? [_genreDtoFixture.Create()]) : null,
includeTags ? (tags ?? [_tagDtoFixture.Create()]) : null,
includeLanguage ? (language ?? _languageInfoDtoFixture.Create()) : null,
originalLanguage,
publisher,
pageCount,
format ?? (includeOptionalProperties ? _faker.PickRandom<BookFormat>() : null),
includeFormat ? (format ?? _faker.PickRandom<BookFormat>()) : null,
edition,
volumeNumber ?? (includeOptionalProperties ? _faker.Random.Int(1, 10) : null),
includeVolumeNumber ? (volumeNumber ?? _faker.Random.Int(1, 10)) : null,
series,
asin,
goodreadsId,
@@ -17,7 +17,6 @@ namespace Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary.
public class BookRatingDtoFixture
{
private readonly Fixture _fixture = new();
private readonly Random _random = new();
/// <summary>
/// Creates a <see cref="BookRatingDto"/>.
@@ -26,20 +25,22 @@ public class BookRatingDtoFixture
/// <param name="maxValue">Optional. The maximum possible rating value.</param>
/// <param name="source">Optional. The rating source.</param>
/// <param name="voteCount">Optional. The number of votes.</param>
/// <param name="includeOptionalProperties">Whether the optional source and vote count should be randomized, or forced to <see langword="null"/>.</param>
/// <param name="includeSource">Whether the source should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeVoteCount">Whether the vote count should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="BookRatingDto"/>.</returns>
public BookRatingDto Create(
decimal? value = null,
decimal? maxValue = null,
BookRatingSource? source = null,
int? voteCount = null,
bool includeOptionalProperties = true)
bool includeSource = true,
bool includeVoteCount = true)
{
return new BookRatingDto(
value ?? _random.Next(1, 5),
value ?? Random.Shared.Next(1, 5),
maxValue ?? 5,
source ?? (includeOptionalProperties ? _fixture.Create<BookRatingSource>() : null),
voteCount ?? (includeOptionalProperties ? _random.Next(1, 1000) : null)
includeSource ? (source ?? _fixture.Create<BookRatingSource>()) : null,
includeVoteCount ? (voteCount ?? Random.Shared.Next(1, 1000)) : null
);
}
@@ -53,7 +53,16 @@ public class AddTrackRequestFixture
/// <param name="includePath">Whether the path should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMetadata">Whether the metadata should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeTrackNumber">Whether the track number should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeOptionalProperties">Whether the properties that are not explicitly provided should be randomized, or forced to <see langword="null"/>.</param>
/// <param name="includeDiscNumber">Whether the disc number should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeScript">Whether the script should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeKey">Whether the musical key should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeBpm">Whether the tempo should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeWork">Whether the work should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzRecordingId">Whether the MusicBrainz recording Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzTrackId">Whether the MusicBrainz track Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzWorkId">Whether the MusicBrainz work Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMoods">Whether the moods should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeIsrcs">Whether the ISRC codes should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeContributors">Whether the contributors should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeRatings">Whether the ratings should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created request to add a track.</returns>
@@ -76,7 +85,16 @@ public class AddTrackRequestFixture
bool includePath = true,
bool includeMetadata = true,
bool includeTrackNumber = true,
bool includeOptionalProperties = true,
bool includeDiscNumber = true,
bool includeScript = true,
bool includeKey = true,
bool includeBpm = true,
bool includeWork = true,
bool includeMusicBrainzRecordingId = true,
bool includeMusicBrainzTrackId = true,
bool includeMusicBrainzWorkId = true,
bool includeMoods = true,
bool includeIsrcs = true,
bool includeContributors = true,
bool includeRatings = true)
{
@@ -84,16 +102,16 @@ public class AddTrackRequestFixture
includePath ? path ?? Path.Combine(Path.GetTempPath(), "lumina-tracks", _faker.System.FileName()) : null,
includeMetadata ? metadata ?? _audioMetadataDtoFixture.Create() : null,
includeTrackNumber ? trackNumber ?? _faker.Random.Int(1, 30) : null,
includeOptionalProperties ? discNumber ?? _faker.Random.Int(1, 3) : null,
includeOptionalProperties ? script ?? _faker.Random.AlphaNumeric(4) : null,
includeOptionalProperties ? key ?? _faker.PickRandom<MusicKey>() : null,
includeOptionalProperties ? bpm ?? _faker.Random.Int(40, 220) : null,
includeOptionalProperties ? work ?? _faker.Lorem.Sentence() : null,
includeOptionalProperties ? musicBrainzRecordingId ?? _faker.Random.Guid() : null,
includeOptionalProperties ? musicBrainzTrackId ?? _faker.Random.Guid() : null,
includeOptionalProperties ? musicBrainzWorkId ?? _faker.Random.Guid() : null,
includeOptionalProperties ? moods ?? _moodDtoFixture.CreateMany(_faker.Random.Int(1, 3)) : null,
includeOptionalProperties ? isrcs ?? _isrcDtoFixture.CreateMany(_faker.Random.Int(1, 3)) : null,
includeDiscNumber ? discNumber ?? _faker.Random.Int(1, 3) : null,
includeScript ? script ?? _faker.Random.AlphaNumeric(4) : null,
includeKey ? key ?? _faker.PickRandom<MusicKey>() : null,
includeBpm ? bpm ?? _faker.Random.Int(40, 220) : null,
includeWork ? work ?? _faker.Lorem.Sentence() : null,
includeMusicBrainzRecordingId ? musicBrainzRecordingId ?? _faker.Random.Guid() : null,
includeMusicBrainzTrackId ? musicBrainzTrackId ?? _faker.Random.Guid() : null,
includeMusicBrainzWorkId ? musicBrainzWorkId ?? _faker.Random.Guid() : null,
includeMoods ? moods ?? _moodDtoFixture.CreateMany(_faker.Random.Int(1, 3)) : null,
includeIsrcs ? isrcs ?? _isrcDtoFixture.CreateMany(_faker.Random.Int(1, 3)) : null,
includeContributors ? contributors ?? _mediaContributorReferenceDtoFixture.CreateMany(_faker.Random.Int(1, 3)) : null,
includeRatings ? ratings ?? _audioRatingDtoFixture.CreateMany(_faker.Random.Int(1, 3)) : null);
}
@@ -49,7 +49,16 @@ public class UpdateTrackRequestFixture
/// <param name="isrcs">Optional. The ISRC codes of the track.</param>
/// <param name="contributors">Optional. The media contributors that performed on the track.</param>
/// <param name="ratings">Optional. The ratings of the track.</param>
/// <param name="includeOptionalProperties">Whether the optional properties that are not explicitly provided should be randomized, or forced to <see langword="null"/>.</param>
/// <param name="includeDiscNumber">Whether the disc number should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeScript">Whether the script should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeKey">Whether the musical key should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeBpm">Whether the tempo should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeWork">Whether the work should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzRecordingId">Whether the MusicBrainz recording Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzTrackId">Whether the MusicBrainz track Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMusicBrainzWorkId">Whether the MusicBrainz work Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeMoods">Whether the moods should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeIsrcs">Whether the ISRC codes should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeContributors">Whether the contributors list should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeRatings">Whether the ratings list should be included, or forced to <see langword="null"/>.</param>
/// <param name="includePath">Whether the path should be included, or forced to <see langword="null"/>.</param>
@@ -72,7 +81,16 @@ public class UpdateTrackRequestFixture
List<IsrcDto>? isrcs = null,
List<MediaContributorReferenceDto>? contributors = null,
List<AudioRatingDto>? ratings = null,
bool includeOptionalProperties = true,
bool includeDiscNumber = true,
bool includeScript = true,
bool includeKey = true,
bool includeBpm = true,
bool includeWork = true,
bool includeMusicBrainzRecordingId = true,
bool includeMusicBrainzTrackId = true,
bool includeMusicBrainzWorkId = true,
bool includeMoods = true,
bool includeIsrcs = true,
bool includeContributors = true,
bool includeRatings = true,
bool includePath = true,
@@ -83,16 +101,16 @@ public class UpdateTrackRequestFixture
includePath ? (path ?? _faker.System.FilePath()) : null,
includeMetadata ? (metadata ?? _audioMetadataDtoFixture.Create()) : null,
includeTrackNumber ? (trackNumber ?? _faker.Random.Int(1, 20)) : null,
includeOptionalProperties ? (discNumber ?? _faker.Random.Int(1, 3)) : null,
includeOptionalProperties ? (script ?? _faker.Random.String2(_faker.Random.Number(1, 50))) : null,
includeOptionalProperties ? (key ?? _faker.PickRandom<MusicKey>()) : null,
includeOptionalProperties ? (bpm ?? _faker.Random.Int(40, 240)) : null,
includeOptionalProperties ? (work ?? _faker.Music.Genre()) : null,
includeOptionalProperties ? (musicBrainzRecordingId ?? _faker.Random.Guid()) : null,
includeOptionalProperties ? (musicBrainzTrackId ?? _faker.Random.Guid()) : null,
includeOptionalProperties ? (musicBrainzWorkId ?? _faker.Random.Guid()) : null,
includeOptionalProperties ? (moods ?? [.. _moodDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null,
includeOptionalProperties ? (isrcs ?? [.. _isrcDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null,
includeDiscNumber ? (discNumber ?? _faker.Random.Int(1, 3)) : null,
includeScript ? (script ?? _faker.Random.String2(_faker.Random.Number(1, 50))) : null,
includeKey ? (key ?? _faker.PickRandom<MusicKey>()) : null,
includeBpm ? (bpm ?? _faker.Random.Int(40, 240)) : null,
includeWork ? (work ?? _faker.Music.Genre()) : null,
includeMusicBrainzRecordingId ? (musicBrainzRecordingId ?? _faker.Random.Guid()) : null,
includeMusicBrainzTrackId ? (musicBrainzTrackId ?? _faker.Random.Guid()) : null,
includeMusicBrainzWorkId ? (musicBrainzWorkId ?? _faker.Random.Guid()) : null,
includeMoods ? (moods ?? [.. _moodDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null,
includeIsrcs ? (isrcs ?? [.. _isrcDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null,
includeContributors ? (contributors ?? [.. _mediaContributorReferenceDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null,
includeRatings ? (ratings ?? [.. _audioRatingDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null);
}
@@ -49,7 +49,21 @@ public class AddBookRequestFixture
/// <param name="isbns">Optional. The ISBNs of the book.</param>
/// <param name="contributors">Optional. The contributors of the book.</param>
/// <param name="ratings">Optional. The ratings of the book.</param>
/// <param name="includeOptionalProperties">Whether the properties that are not explicitly provided should be randomized, or forced to <see langword="null"/>.</param>
/// <param name="includeFormat">Whether the format should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeEdition">Whether the edition should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeVolumeNumber">Whether the volume number should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAsin">Whether the ASIN should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeGoodreadsId">Whether the Goodreads Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLccn">Whether the LCCN should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeOclcNumber">Whether the OCLC number should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeOpenLibraryId">Whether the Open Library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLibraryThingId">Whether the LibraryThing Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeGoogleBooksId">Whether the Google Books Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeBarnesAndNobleId">Whether the Barnes and Noble Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAppleBooksId">Whether the Apple Books Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeIsbns">Whether the ISBNs should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeRatings">Whether the ratings should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeContributors">Whether the contributors should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created request to add a book.</returns>
public AddBookRequest Create(
string? path = null,
@@ -70,7 +84,21 @@ public class AddBookRequestFixture
List<IsbnDto>? isbns = null,
List<MediaContributorReferenceDto>? contributors = null,
List<BookRatingDto>? ratings = null,
bool includeOptionalProperties = true)
bool includeFormat = true,
bool includeEdition = true,
bool includeVolumeNumber = true,
bool includeAsin = true,
bool includeGoodreadsId = true,
bool includeLccn = true,
bool includeOclcNumber = true,
bool includeOpenLibraryId = true,
bool includeLibraryThingId = true,
bool includeGoogleBooksId = true,
bool includeBarnesAndNobleId = true,
bool includeAppleBooksId = true,
bool includeIsbns = true,
bool includeRatings = true,
bool includeContributors = true)
{
return new Faker<AddBookRequest>()
.CustomInstantiator(f => new AddBookRequest(
@@ -95,22 +123,22 @@ public class AddBookRequestFixture
))
.RuleFor(x => x.Path, f => path ?? Path.Combine(Path.GetTempPath(), "lumina-books", f.System.FileName()))
.RuleFor(x => x.Metadata, metadata ?? _writtenContentMetadataDtoFixture.Create())
.RuleFor(x => x.Format, f => format ?? (includeOptionalProperties ? f.PickRandom<BookFormat>() : null))
.RuleFor(x => x.Edition, f => edition ?? (includeOptionalProperties ? f.Random.String2(f.Random.Number(1, 50)) : null))
.RuleFor(x => x.VolumeNumber, f => volumeNumber ?? (includeOptionalProperties ? (float?)f.Random.Number(1, 3) : null))
.RuleFor(x => x.Format, f => format ?? (includeFormat ? f.PickRandom<BookFormat>() : null))
.RuleFor(x => x.Edition, f => edition ?? (includeEdition ? f.Random.String2(f.Random.Number(1, 50)) : null))
.RuleFor(x => x.VolumeNumber, f => volumeNumber ?? (includeVolumeNumber ? (float?)f.Random.Number(1, 3) : null))
.RuleFor(x => x.Series, series)
.RuleFor(x => x.ASIN, f => asin ?? (includeOptionalProperties ? f.Random.String2(10) : null))
.RuleFor(x => x.GoodreadsId, f => goodreadsId ?? (includeOptionalProperties ? f.Random.Number(100000, 500000).ToString() : null))
.RuleFor(x => x.LCCN, f => lccn ?? (includeOptionalProperties ? CreateLccn(f) : null))
.RuleFor(x => x.OCLCNumber, f => oclcNumber ?? (includeOptionalProperties ? CreateOclcNumber(f) : null))
.RuleFor(x => x.OpenLibraryId, f => openLibraryId ?? (includeOptionalProperties ? CreateOpenLibraryId(f) : null))
.RuleFor(x => x.LibraryThingId, f => libraryThingId ?? (includeOptionalProperties ? f.Random.String2(f.Random.Number(1, 50)) : null))
.RuleFor(x => x.GoogleBooksId, f => googleBooksId ?? (includeOptionalProperties ? CreateGoogleBooksId(f) : null))
.RuleFor(x => x.BarnesAndNobleId, f => barnesAndNobleId ?? (includeOptionalProperties ? f.Random.String2(10, "0123456789") : null))
.RuleFor(x => x.AppleBooksId, f => appleBooksId ?? (includeOptionalProperties ? $"id{f.Random.Number(1, 999999)}" : null))
.RuleFor(p => p.ISBNs, f => isbns ?? (includeOptionalProperties ? [.. _isbnDtoFixture.CreateMany(f.Random.Number(1, 3))] : null))
.RuleFor(p => p.Ratings, f => ratings ?? (includeOptionalProperties ? [.. _bookRatingDtoFixture.CreateMany(f.Random.Number(1, 3))] : null))
.RuleFor(x => x.Contributors, f => contributors ?? (includeOptionalProperties ? [.. _mediaContributorReferenceDtoFixture.CreateMany(f.Random.Number(1, 3))] : null));
.RuleFor(x => x.ASIN, f => asin ?? (includeAsin ? f.Random.String2(10) : null))
.RuleFor(x => x.GoodreadsId, f => goodreadsId ?? (includeGoodreadsId ? f.Random.Number(100000, 500000).ToString() : null))
.RuleFor(x => x.LCCN, f => lccn ?? (includeLccn ? CreateLccn(f) : null))
.RuleFor(x => x.OCLCNumber, f => oclcNumber ?? (includeOclcNumber ? CreateOclcNumber(f) : null))
.RuleFor(x => x.OpenLibraryId, f => openLibraryId ?? (includeOpenLibraryId ? CreateOpenLibraryId(f) : null))
.RuleFor(x => x.LibraryThingId, f => libraryThingId ?? (includeLibraryThingId ? f.Random.String2(f.Random.Number(1, 50)) : null))
.RuleFor(x => x.GoogleBooksId, f => googleBooksId ?? (includeGoogleBooksId ? CreateGoogleBooksId(f) : null))
.RuleFor(x => x.BarnesAndNobleId, f => barnesAndNobleId ?? (includeBarnesAndNobleId ? f.Random.String2(10, "0123456789") : null))
.RuleFor(x => x.AppleBooksId, f => appleBooksId ?? (includeAppleBooksId ? $"id{f.Random.Number(1, 999999)}" : null))
.RuleFor(p => p.ISBNs, f => isbns ?? (includeIsbns ? [.. _isbnDtoFixture.CreateMany(f.Random.Number(1, 3))] : null))
.RuleFor(p => p.Ratings, f => ratings ?? (includeRatings ? [.. _bookRatingDtoFixture.CreateMany(f.Random.Number(1, 3))] : null))
.RuleFor(x => x.Contributors, f => contributors ?? (includeContributors ? [.. _mediaContributorReferenceDtoFixture.CreateMany(f.Random.Number(1, 3))] : null));
}
/// <summary>
@@ -47,7 +47,21 @@ public class UpdateBookRequestFixture
/// <param name="isbns">Optional. The ISBNs of the book.</param>
/// <param name="contributors">Optional. The contributors of the book.</param>
/// <param name="ratings">Optional. The ratings of the book.</param>
/// <param name="includeOptionalProperties">Whether the properties that are not explicitly provided should be randomized, or forced to <see langword="null"/>.</param>
/// <param name="includeFormat">Whether the format should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeEdition">Whether the edition should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeVolumeNumber">Whether the volume number should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAsin">Whether the ASIN should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeGoodreadsId">Whether the Goodreads Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLccn">Whether the LCCN should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeOclcNumber">Whether the OCLC number should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeOpenLibraryId">Whether the Open Library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLibraryThingId">Whether the LibraryThing Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeGoogleBooksId">Whether the Google Books Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeBarnesAndNobleId">Whether the Barnes and Noble Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAppleBooksId">Whether the Apple Books Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeIsbns">Whether the ISBNs should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeRatings">Whether the ratings should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeContributors">Whether the contributors should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created request to update a book.</returns>
public UpdateBookRequest Create(
WrittenContentMetadataDto? metadata = null,
@@ -67,7 +81,21 @@ public class UpdateBookRequestFixture
List<IsbnDto>? isbns = null,
List<MediaContributorReferenceDto>? contributors = null,
List<BookRatingDto>? ratings = null,
bool includeOptionalProperties = true)
bool includeFormat = true,
bool includeEdition = true,
bool includeVolumeNumber = true,
bool includeAsin = true,
bool includeGoodreadsId = true,
bool includeLccn = true,
bool includeOclcNumber = true,
bool includeOpenLibraryId = true,
bool includeLibraryThingId = true,
bool includeGoogleBooksId = true,
bool includeBarnesAndNobleId = true,
bool includeAppleBooksId = true,
bool includeIsbns = true,
bool includeRatings = true,
bool includeContributors = true)
{
return new Faker<UpdateBookRequest>()
.CustomInstantiator(f => new UpdateBookRequest(
@@ -90,22 +118,22 @@ public class UpdateBookRequestFixture
default!
))
.RuleFor(x => x.Metadata, metadata ?? _writtenContentMetadataDtoFixture.Create())
.RuleFor(x => x.Format, f => format ?? (includeOptionalProperties ? f.PickRandom<BookFormat>() : null))
.RuleFor(x => x.Edition, f => edition ?? (includeOptionalProperties ? f.Random.String2(f.Random.Number(1, 50)) : null))
.RuleFor(x => x.VolumeNumber, f => volumeNumber ?? (includeOptionalProperties ? (float?)f.Random.Number(1, 3) : null))
.RuleFor(x => x.Format, f => format ?? (includeFormat ? f.PickRandom<BookFormat>() : null))
.RuleFor(x => x.Edition, f => edition ?? (includeEdition ? f.Random.String2(f.Random.Number(1, 50)) : null))
.RuleFor(x => x.VolumeNumber, f => volumeNumber ?? (includeVolumeNumber ? (float?)f.Random.Number(1, 3) : null))
.RuleFor(x => x.Series, series)
.RuleFor(x => x.ASIN, f => asin ?? (includeOptionalProperties ? f.Random.String2(10) : null))
.RuleFor(x => x.GoodreadsId, f => goodreadsId ?? (includeOptionalProperties ? f.Random.Number(100000, 500000).ToString() : null))
.RuleFor(x => x.LCCN, f => lccn ?? (includeOptionalProperties ? CreateLccn(f) : null))
.RuleFor(x => x.OCLCNumber, f => oclcNumber ?? (includeOptionalProperties ? CreateOclcNumber(f) : null))
.RuleFor(x => x.OpenLibraryId, f => openLibraryId ?? (includeOptionalProperties ? CreateOpenLibraryId(f) : null))
.RuleFor(x => x.LibraryThingId, f => libraryThingId ?? (includeOptionalProperties ? f.Random.String2(f.Random.Number(1, 50)) : null))
.RuleFor(x => x.GoogleBooksId, f => googleBooksId ?? (includeOptionalProperties ? CreateGoogleBooksId(f) : null))
.RuleFor(x => x.BarnesAndNobleId, f => barnesAndNobleId ?? (includeOptionalProperties ? f.Random.String2(10, "0123456789") : null))
.RuleFor(x => x.AppleBooksId, f => appleBooksId ?? (includeOptionalProperties ? $"id{f.Random.Number(1, 999999)}" : null))
.RuleFor(p => p.ISBNs, f => isbns ?? (includeOptionalProperties ? [.. _isbnDtoFixture.CreateMany(f.Random.Number(1, 3))] : null))
.RuleFor(p => p.Ratings, f => ratings ?? (includeOptionalProperties ? [.. _bookRatingDtoFixture.CreateMany(f.Random.Number(1, 3))] : null))
.RuleFor(x => x.Contributors, f => contributors ?? (includeOptionalProperties ? [.. _mediaContributorReferenceDtoFixture.CreateMany(f.Random.Number(1, 3))] : null));
.RuleFor(x => x.ASIN, f => asin ?? (includeAsin ? f.Random.String2(10) : null))
.RuleFor(x => x.GoodreadsId, f => goodreadsId ?? (includeGoodreadsId ? f.Random.Number(100000, 500000).ToString() : null))
.RuleFor(x => x.LCCN, f => lccn ?? (includeLccn ? CreateLccn(f) : null))
.RuleFor(x => x.OCLCNumber, f => oclcNumber ?? (includeOclcNumber ? CreateOclcNumber(f) : null))
.RuleFor(x => x.OpenLibraryId, f => openLibraryId ?? (includeOpenLibraryId ? CreateOpenLibraryId(f) : null))
.RuleFor(x => x.LibraryThingId, f => libraryThingId ?? (includeLibraryThingId ? f.Random.String2(f.Random.Number(1, 50)) : null))
.RuleFor(x => x.GoogleBooksId, f => googleBooksId ?? (includeGoogleBooksId ? CreateGoogleBooksId(f) : null))
.RuleFor(x => x.BarnesAndNobleId, f => barnesAndNobleId ?? (includeBarnesAndNobleId ? f.Random.String2(10, "0123456789") : null))
.RuleFor(x => x.AppleBooksId, f => appleBooksId ?? (includeAppleBooksId ? $"id{f.Random.Number(1, 999999)}" : null))
.RuleFor(p => p.ISBNs, f => isbns ?? (includeIsbns ? [.. _isbnDtoFixture.CreateMany(f.Random.Number(1, 3))] : null))
.RuleFor(p => p.Ratings, f => ratings ?? (includeRatings ? [.. _bookRatingDtoFixture.CreateMany(f.Random.Number(1, 3))] : null))
.RuleFor(x => x.Contributors, f => contributors ?? (includeContributors ? [.. _mediaContributorReferenceDtoFixture.CreateMany(f.Random.Number(1, 3))] : null));
}
/// <summary>
@@ -28,12 +28,12 @@ public class ThemeResponseFixture
/// <param name="author">Optional. The author of the theme.</param>
/// <param name="version">Optional. The version of the theme.</param>
/// <param name="previewPath">Optional. The preview image path of the theme, or <see langword="null"/> when the theme has no preview.</param>
/// <param name="includePreviewPath">Whether the preview path should be included, or forced to <see langword="null"/>.</param>
/// <param name="installSource">Optional. The source the theme was installed from.</param>
/// <param name="isCurrent">Optional. Whether the theme is the currently active one.</param>
/// <param name="includeIsCurrent">Whether the currently active flag should be included, or forced to <see langword="null"/>.</param>
/// <param name="installedAtUtc">Optional. The UTC timestamp when the theme was installed.</param>
/// <param name="isDeleted">Optional. Whether the theme was deleted by the user.</param>
/// <param name="includePreviewPath">Whether the preview path should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeIsCurrent">Whether the currently active flag should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="ThemeResponse"/>.</returns>
public ThemeResponse Create(
Guid? id = null,
@@ -43,12 +43,12 @@ public class ThemeResponseFixture
string? author = null,
string? version = null,
string? previewPath = null,
bool includePreviewPath = false,
ThemeInstallSource? installSource = null,
bool? isCurrent = null,
bool includeIsCurrent = false,
DateTime? installedAtUtc = null,
bool? isDeleted = null)
bool? isDeleted = null,
bool includePreviewPath = false,
bool includeIsCurrent = false)
{
return new ThemeResponse(
id ?? Guid.NewGuid(),
@@ -23,7 +23,6 @@ namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedCo
public class LibraryFixture
{
private readonly Faker _faker = new();
private readonly Random _random = new();
private readonly LibraryIdFixture _libraryIdFixture = new();
private readonly UserIdFixture _userIdFixture = new();
private readonly ScanIdFixture _scanIdFixture = new();
@@ -37,13 +36,13 @@ public class LibraryFixture
/// <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="includeCoverImage">Whether the cover image should be included, or left unset, meaning the library has no cover.</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="scanIds">Optional. The scan Ids associated with 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,
@@ -52,13 +51,13 @@ public class LibraryFixture
LibraryType? libraryType = null,
IEnumerable<string>? contentLocations = null,
string? coverImage = null,
bool includeCoverImage = true,
bool isEnabled = true,
bool isLocked = false,
bool canDownloadMetadataFromWeb = true,
bool shouldSaveMetadataInMediaDirectories = false,
bool shouldSkipUnchangedDirectoriesDuringScan = false,
IEnumerable<Guid>? scanIds = null)
IEnumerable<Guid>? scanIds = null,
bool includeCoverImage = true)
{
List<string> validPaths =
[
@@ -77,7 +76,7 @@ public class LibraryFixture
resolvedUserId,
title ?? _faker.Random.String2(_faker.Random.Number(1, 50)),
libraryType ?? _faker.PickRandom<LibraryType>(),
contentLocations ?? validPaths.Take(_random.Next(1, validPaths.Count)),
contentLocations ?? validPaths.Take(Random.Shared.Next(1, validPaths.Count)),
Optional<string>.FromNullable(resolvedCoverImage),
isEnabled,
isLocked,
@@ -91,7 +90,7 @@ public class LibraryFixture
resolvedUserId,
title ?? _faker.Random.String2(_faker.Random.Number(1, 50)),
libraryType ?? _faker.PickRandom<LibraryType>(),
contentLocations ?? validPaths.Take(_random.Next(1, validPaths.Count)),
contentLocations ?? validPaths.Take(Random.Shared.Next(1, validPaths.Count)),
Optional<string>.FromNullable(resolvedCoverImage),
isEnabled,
isLocked,
@@ -28,8 +28,8 @@ public sealed class ThemePackFixture
/// <param name="templates">Optional template mappings written to the manifest.</param>
/// <param name="preview">Optional preview path written to the manifest, or <see langword="null"/> to omit the preview.</param>
/// <param name="defaultTemplateContent">Optional content for the default template file.</param>
/// <param name="includePreviewAsset">Whether to include the preview asset file in the archive or not.</param>
/// <param name="additionalFiles">Optional additional files written into the archive.</param>
/// <param name="includePreviewAsset">Whether to include the preview asset file in the archive or not.</param>
/// <returns>The created theme pack ZIP archive.</returns>
public byte[] Create(
string themeId = "test-theme",
@@ -41,8 +41,8 @@ public sealed class ThemePackFixture
Dictionary<string, string>? templates = null,
string? preview = "assets/preview.png",
string? defaultTemplateContent = null,
bool includePreviewAsset = true,
IReadOnlyDictionary<string, string>? additionalFiles = null)
IReadOnlyDictionary<string, string>? additionalFiles = null,
bool includePreviewAsset = true)
{
Dictionary<string, string> manifestTemplates = templates ?? new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
{
@@ -21,18 +21,18 @@ public class ThemeNavEntryDtoFixture
/// </summary>
/// <param name="label">Optional label of the entry.</param>
/// <param name="url">Optional URL of the link, or <see langword="null"/> for a submenu.</param>
/// <param name="includeUrl">Whether the URL should be included, or forced to <see langword="null"/>.</param>
/// <param name="cssClass">Optional CSS classes of the link.</param>
/// <param name="includeCssClass">Whether the CSS class should be included, or forced to <see langword="null"/>.</param>
/// <param name="children">Optional child links of a submenu.</param>
/// <param name="includeUrl">Whether the URL should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeCssClass">Whether the CSS class should be included, or forced to <see langword="null"/>.</param>
/// <returns>The created <see cref="ThemeNavEntryDto"/>.</returns>
public ThemeNavEntryDto Create(
string? label = null,
string? url = null,
bool includeUrl = false,
string? cssClass = null,
bool includeCssClass = false,
IReadOnlyList<ThemeNavEntryDto>? children = null)
IReadOnlyList<ThemeNavEntryDto>? children = null,
bool includeUrl = false,
bool includeCssClass = false)
{
return new ThemeNavEntryDto(
Label: label ?? _faker.Lorem.Word(),
@@ -28,12 +28,12 @@ public class ThemeResponseDtoFixture
/// <param name="author">Optional author of the theme.</param>
/// <param name="version">Optional semantic version of the theme.</param>
/// <param name="previewPath">Optional preview image path of the theme, or <see langword="null"/> when the theme has no preview.</param>
/// <param name="includePreviewPath">Whether the preview path should be included, or forced to <see langword="null"/>.</param>
/// <param name="installSource">Optional source the theme was installed from.</param>
/// <param name="isCurrent">Optional value indicating whether the theme is the active one.</param>
/// <param name="includeIsCurrent">Whether the currently active flag should be included, or forced to <see langword="null"/>.</param>
/// <param name="installedAtUtc">Optional UTC timestamp at which the theme was installed.</param>
/// <param name="isDeleted">Optional value indicating whether the theme was deleted by the user.</param>
/// <param name="includePreviewPath">Whether the preview path should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeIsCurrent">Whether the currently active flag should be included, or forced to <see langword="null"/>.</param>
/// <returns>A configured <see cref="ThemeResponseDto"/> instance.</returns>
public ThemeResponseDto Create(
Guid? id = null,
@@ -43,12 +43,12 @@ public class ThemeResponseDtoFixture
string? author = null,
string? version = null,
string? previewPath = null,
bool includePreviewPath = false,
ThemeInstallSource? installSource = null,
bool? isCurrent = null,
bool includeIsCurrent = false,
DateTime? installedAtUtc = null,
bool? isDeleted = null)
bool? isDeleted = null,
bool includePreviewPath = false,
bool includeIsCurrent = false)
{
return new ThemeResponseDto(
Id: id ?? Guid.NewGuid(),
@@ -33,35 +33,67 @@ public class UpdateBookRequestFixture
/// <param name="id">Optional Id of the book to update.</param>
/// <param name="libraryId">Optional Id of the media library the book belongs to.</param>
/// <param name="metadata">Optional written content metadata of the book.</param>
/// <param name="includeOptionalProperties">Whether the properties that are not explicitly provided should be randomized, or forced to <see langword="null"/>.</param>
/// <param name="includeMetadata">Whether the metadata should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeFormat">Whether the format should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeEdition">Whether the edition should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeVolumeNumber">Whether the volume number should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeSeries">Whether the series should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAsin">Whether the ASIN should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeGoodreadsId">Whether the Goodreads Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLccn">Whether the LCCN should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeOclcNumber">Whether the OCLC number should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeOpenLibraryId">Whether the Open Library Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeLibraryThingId">Whether the LibraryThing Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeGoogleBooksId">Whether the Google Books Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeBarnesAndNobleId">Whether the Barnes and Noble Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeAppleBooksId">Whether the Apple Books Id should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeIsbns">Whether the ISBNs should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeContributors">Whether the contributors should be included, or forced to <see langword="null"/>.</param>
/// <param name="includeRatings">Whether the ratings should be included, or forced to <see langword="null"/>.</param>
/// <returns>A configured <see cref="UpdateBookRequest"/> instance.</returns>
public UpdateBookRequest Create(
Guid? id = null,
Guid? libraryId = null,
WrittenContentMetadataDto? metadata = null,
bool includeOptionalProperties = true)
bool includeMetadata = true,
bool includeFormat = true,
bool includeEdition = true,
bool includeVolumeNumber = true,
bool includeSeries = true,
bool includeAsin = true,
bool includeGoodreadsId = true,
bool includeLccn = true,
bool includeOclcNumber = true,
bool includeOpenLibraryId = true,
bool includeLibraryThingId = true,
bool includeGoogleBooksId = true,
bool includeBarnesAndNobleId = true,
bool includeAppleBooksId = true,
bool includeIsbns = true,
bool includeContributors = true,
bool includeRatings = true)
{
return new UpdateBookRequest
{
BookId = id?.ToString() ?? Guid.NewGuid().ToString(),
LibraryId = libraryId ?? Guid.NewGuid(),
Metadata = metadata ?? (includeOptionalProperties ? _writtenContentMetadataDtoFixture.Create() : null),
Format = includeOptionalProperties ? _faker.PickRandom<BookFormat>() : null,
Edition = includeOptionalProperties ? _faker.Random.String2(_faker.Random.Number(1, 50)) : null,
VolumeNumber = includeOptionalProperties ? _faker.Random.Number(1, 3) : null,
Series = includeOptionalProperties ? _bookSeriesDtoFixture.Create() : null,
ASIN = includeOptionalProperties ? _faker.Random.String2(10) : null,
GoodreadsId = includeOptionalProperties ? _faker.Random.Number(100000, 500000).ToString() : null,
LCCN = includeOptionalProperties ? "n78890351" : null,
OCLCNumber = includeOptionalProperties ? "ocm12345678" : null,
OpenLibraryId = includeOptionalProperties ? "OL123456M" : null,
LibraryThingId = includeOptionalProperties ? _faker.Random.String2(_faker.Random.Number(1, 50)) : null,
GoogleBooksId = includeOptionalProperties ? CreateGoogleBooksId() : null,
BarnesAndNobleId = includeOptionalProperties ? _faker.Random.String2(10, "0123456789") : null,
AppleBooksId = includeOptionalProperties ? $"id{_faker.Random.Number(1, 999999)}" : null,
ISBNs = includeOptionalProperties ? [.. _isbnDtoFixture.CreateMany(_faker.Random.Number(1, 3))] : null,
Contributors = includeOptionalProperties ? [.. _mediaContributorDtoFixture.CreateMany(_faker.Random.Number(1, 3))] : null,
Ratings = includeOptionalProperties ? [.. _bookRatingDtoFixture.CreateMany(_faker.Random.Number(1, 3))] : null
Metadata = includeMetadata ? (metadata ?? _writtenContentMetadataDtoFixture.Create()) : null,
Format = includeFormat ? _faker.PickRandom<BookFormat>() : null,
Edition = includeEdition ? _faker.Random.String2(_faker.Random.Number(1, 50)) : null,
VolumeNumber = includeVolumeNumber ? _faker.Random.Number(1, 3) : null,
Series = includeSeries ? _bookSeriesDtoFixture.Create() : null,
ASIN = includeAsin ? _faker.Random.String2(10) : null,
GoodreadsId = includeGoodreadsId ? _faker.Random.Number(100000, 500000).ToString() : null,
LCCN = includeLccn ? "n78890351" : null,
OCLCNumber = includeOclcNumber ? "ocm12345678" : null,
OpenLibraryId = includeOpenLibraryId ? "OL123456M" : null,
LibraryThingId = includeLibraryThingId ? _faker.Random.String2(_faker.Random.Number(1, 50)) : null,
GoogleBooksId = includeGoogleBooksId ? CreateGoogleBooksId() : null,
BarnesAndNobleId = includeBarnesAndNobleId ? _faker.Random.String2(10, "0123456789") : null,
AppleBooksId = includeAppleBooksId ? $"id{_faker.Random.Number(1, 999999)}" : null,
ISBNs = includeIsbns ? [.. _isbnDtoFixture.CreateMany(_faker.Random.Number(1, 3))] : null,
Contributors = includeContributors ? [.. _mediaContributorDtoFixture.CreateMany(_faker.Random.Number(1, 3))] : null,
Ratings = includeRatings ? [.. _bookRatingDtoFixture.CreateMany(_faker.Random.Number(1, 3))] : null
};
}