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>