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="id">Optional. The Id of the role.</param>
/// <param name="roleName">Optional. The name 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="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="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="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> /// <returns>The created <see cref="RoleEntity"/>.</returns>
public RoleEntity Create( public RoleEntity Create(
Guid? id = null, Guid? id = null,
string? roleName = null, string? roleName = null,
IEnumerable<RolePermissionEntity>? rolePermissions = null, IEnumerable<RolePermissionEntity>? rolePermissions = null,
bool includeRolePermissions = false,
Guid? createdBy = null, Guid? createdBy = null,
DateTime? createdOnUtc = null) DateTime? createdOnUtc = null,
bool includeRolePermissions = false)
{ {
return new Faker<RoleEntity>() return new Faker<RoleEntity>()
.CustomInstantiator(faker => new RoleEntity .CustomInstantiator(faker => new RoleEntity
@@ -20,7 +20,6 @@ namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Au
[ExcludeFromCodeCoverage] [ExcludeFromCodeCoverage]
public class TrackEntityFixture public class TrackEntityFixture
{ {
private readonly Random _random = new();
private readonly Faker _faker = new(); private readonly Faker _faker = new();
private readonly TagEntityFixture _tagEntityFixture = new(); private readonly TagEntityFixture _tagEntityFixture = new();
private readonly GenreEntityFixture _genreEntityFixture = 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="path">Optional. The file system path of the track.</param>
/// <param name="title">Optional. The title 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="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="originalReleaseDate">Optional. The original release date of the track.</param>
/// <param name="originalReleaseYear">Optional. The original release year 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="reReleaseDate">Optional. The re-release date of the track.</param>
/// <param name="reReleaseYear">Optional. The re-release year 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="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="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> /// <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? path = null,
string? title = null, string? title = null,
int? trackNumber = null, int? trackNumber = null,
bool includeMetadata = true,
DateOnly? originalReleaseDate = null, DateOnly? originalReleaseDate = null,
int? originalReleaseYear = null, int? originalReleaseYear = null,
DateOnly? reReleaseDate = null, DateOnly? reReleaseDate = null,
int? reReleaseYear = null, int? reReleaseYear = null,
bool includeMetadata = true,
bool includeOriginalReleaseDate = true, bool includeOriginalReleaseDate = true,
bool includeOriginalReleaseYear = true, bool includeOriginalReleaseYear = true,
bool includeReReleaseDate = true, bool includeReReleaseDate = true,
@@ -69,9 +68,9 @@ public class TrackEntityFixture
Guid resolvedAlbumId = albumId ?? Guid.NewGuid(); Guid resolvedAlbumId = albumId ?? Guid.NewGuid();
Guid resolvedLibraryId = libraryId ?? Guid.NewGuid(); Guid resolvedLibraryId = libraryId ?? Guid.NewGuid();
const int MAXIMUM_RELEASE_YEAR = 2026; 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 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 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)); 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.OriginalLanguageCode, f => f.Random.String2(2))
.RuleFor(x => x.OriginalLanguageName, f => f.Random.String2(f.Random.Number(1, 50))) .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.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.SampleRate, f => f.PickRandom(44100, 48000, 96000))
.RuleFor(x => x.Channels, f => f.PickRandom(1, 2, 6)) .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.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.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.Script, f => f.Random.String2(f.Random.Number(1, 50)))
.RuleFor(x => x.Key, f => f.PickRandom<MusicKey>()) .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.Work, f => f.Music.Genre())
.RuleFor(x => x.MusicBrainzRecordingId, f => f.Random.Guid()) .RuleFor(x => x.MusicBrainzRecordingId, f => f.Random.Guid())
.RuleFor(x => x.MusicBrainzTrackId, 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="author">Optional author of the theme.</param>
/// <param name="version">Optional version 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="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="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="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="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="installedAtUtc">Optional UTC timestamp when the theme was installed.</param>
/// <param name="createdOnUtc">Optional UTC timestamp when the entity was created.</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="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="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="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> /// <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> /// <returns>A configured <see cref="ThemeEntity"/> instance.</returns>
public ThemeEntity Create( public ThemeEntity Create(
@@ -47,17 +47,17 @@ public class ThemeEntityFixture
string? author = null, string? author = null,
string? version = null, string? version = null,
string? previewPath = null, string? previewPath = null,
bool includePreviewPath = false,
ThemeInstallSource? installSource = null, ThemeInstallSource? installSource = null,
bool? isCurrent = null, bool? isCurrent = null,
bool includeIsCurrent = false,
bool? isDeleted = null, bool? isDeleted = null,
DateTime? installedAtUtc = null, DateTime? installedAtUtc = null,
DateTime? createdOnUtc = null, DateTime? createdOnUtc = null,
Guid? createdBy = null, Guid? createdBy = null,
DateTime? updatedOnUtc = null, DateTime? updatedOnUtc = null,
bool includeUpdatedOnUtc = false,
Guid? updatedBy = null, Guid? updatedBy = null,
bool includePreviewPath = false,
bool includeIsCurrent = false,
bool includeUpdatedOnUtc = false,
bool includeUpdatedBy = false) bool includeUpdatedBy = false)
{ {
Guid resolvedCreatedBy = createdBy ?? Guid.NewGuid(); 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="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="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="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="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="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> /// <returns>The created user entity.</returns>
public UserEntity Create( public UserEntity Create(
int libraryCount = 0, int libraryCount = 0,
@@ -40,9 +40,9 @@ public class UserEntityFixture
Guid? id = null, Guid? id = null,
UserRoleEntity? userRole = null, UserRoleEntity? userRole = null,
IEnumerable<UserPermissionEntity>? userPermissions = null, IEnumerable<UserPermissionEntity>? userPermissions = null,
ICollection<LibraryEntity>? libraries = null,
bool includeUserRole = false, bool includeUserRole = false,
bool includeUserPermissions = false, bool includeUserPermissions = false)
ICollection<LibraryEntity>? libraries = null)
{ {
Guid userId = id ?? Guid.NewGuid(); Guid userId = id ?? Guid.NewGuid();
ICollection<LibraryEntity> resolvedLibraries = libraries ?? (libraryCount > 0 ICollection<LibraryEntity> resolvedLibraries = libraries ?? (libraryCount > 0
@@ -25,8 +25,8 @@ public class ThemeManifestDtoFixture
/// <param name="author">Optional author of the theme.</param> /// <param name="author">Optional author of the theme.</param>
/// <param name="version">Optional version 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="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="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> /// <returns>A configured <see cref="ThemeManifestDto"/> instance.</returns>
public ThemeManifestDto Create( public ThemeManifestDto Create(
int? schemaVersion = null, int? schemaVersion = null,
@@ -36,8 +36,8 @@ public class ThemeManifestDtoFixture
string? author = null, string? author = null,
string? version = null, string? version = null,
string? preview = null, string? preview = null,
bool includePreview = false, Dictionary<string, string>? templates = null,
Dictionary<string, string>? templates = null) bool includePreview = false)
{ {
return new Faker<ThemeManifestDto>() return new Faker<ThemeManifestDto>()
.CustomInstantiator(f => new 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="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="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="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="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> /// <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> /// <returns>The created command to add a track.</returns>
@@ -90,7 +99,16 @@ public class AddTrackCommandFixture
bool includePath = true, bool includePath = true,
bool includeMetadata = true, bool includeMetadata = true,
bool includeTrackNumber = 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 includeContributors = true,
bool includeRatings = true) bool includeRatings = true)
{ {
@@ -101,16 +119,16 @@ public class AddTrackCommandFixture
includePath ? path ?? Path.Combine(Path.GetTempPath(), "lumina-tracks", _faker.System.FileName()) : null, includePath ? path ?? Path.Combine(Path.GetTempPath(), "lumina-tracks", _faker.System.FileName()) : null,
includeMetadata ? metadata ?? _audioMetadataDtoFixture.Create() : null, includeMetadata ? metadata ?? _audioMetadataDtoFixture.Create() : null,
includeTrackNumber ? trackNumber ?? _faker.Random.Int(1, 30) : null, includeTrackNumber ? trackNumber ?? _faker.Random.Int(1, 30) : null,
includeOptionalProperties ? discNumber ?? _faker.Random.Int(1, 3) : null, includeDiscNumber ? discNumber ?? _faker.Random.Int(1, 3) : null,
includeOptionalProperties ? script ?? _faker.Random.AlphaNumeric(4) : null, includeScript ? script ?? _faker.Random.AlphaNumeric(4) : null,
includeOptionalProperties ? key ?? _faker.PickRandom<MusicKey>() : null, includeKey ? key ?? _faker.PickRandom<MusicKey>() : null,
includeOptionalProperties ? bpm ?? _faker.Random.Int(40, 220) : null, includeBpm ? bpm ?? _faker.Random.Int(40, 220) : null,
includeOptionalProperties ? work ?? _faker.Lorem.Sentence() : null, includeWork ? work ?? _faker.Lorem.Sentence() : null,
includeOptionalProperties ? musicBrainzRecordingId ?? _faker.Random.Guid() : null, includeMusicBrainzRecordingId ? musicBrainzRecordingId ?? _faker.Random.Guid() : null,
includeOptionalProperties ? musicBrainzTrackId ?? _faker.Random.Guid() : null, includeMusicBrainzTrackId ? musicBrainzTrackId ?? _faker.Random.Guid() : null,
includeOptionalProperties ? musicBrainzWorkId ?? _faker.Random.Guid() : null, includeMusicBrainzWorkId ? musicBrainzWorkId ?? _faker.Random.Guid() : null,
includeOptionalProperties ? moods ?? _moodDtoFixture.CreateMany(_faker.Random.Int(1, 3)) : null, includeMoods ? moods ?? _moodDtoFixture.CreateMany(_faker.Random.Int(1, 3)) : null,
includeOptionalProperties ? isrcs ?? _isrcDtoFixture.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, includeContributors ? contributors ?? _mediaContributorReferenceDtoFixture.CreateMany(_faker.Random.Int(1, 3)) : null,
includeRatings ? ratings ?? _audioRatingDtoFixture.CreateMany(_faker.Random.Int(1, 3)) : null, includeRatings ? ratings ?? _audioRatingDtoFixture.CreateMany(_faker.Random.Int(1, 3)) : null,
trackId); trackId);
@@ -53,7 +53,16 @@ public class UpdateTrackCommandFixture
/// <param name="isrcs">Optional. The ISRC codes of the track.</param> /// <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="contributors">Optional. The media contributors that performed on the track.</param>
/// <param name="ratings">Optional. The ratings of 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="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="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="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<IsrcDto>? isrcs = null,
List<MediaContributorReferenceDto>? contributors = null, List<MediaContributorReferenceDto>? contributors = null,
List<AudioRatingDto>? ratings = 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 includeMetadata = true,
bool includeContributors = true, bool includeContributors = true,
bool includeRatings = true, bool includeRatings = true,
@@ -103,16 +121,16 @@ public class UpdateTrackCommandFixture
includePath ? (path ?? _faker.System.FilePath()) : null, includePath ? (path ?? _faker.System.FilePath()) : null,
includeMetadata ? (metadata ?? _audioMetadataDtoFixture.Create()) : null, includeMetadata ? (metadata ?? _audioMetadataDtoFixture.Create()) : null,
includeTrackNumber ? (trackNumber ?? _faker.Random.Int(1, 20)) : null, includeTrackNumber ? (trackNumber ?? _faker.Random.Int(1, 20)) : null,
includeOptionalProperties ? (discNumber ?? _faker.Random.Int(1, 3)) : null, includeDiscNumber ? (discNumber ?? _faker.Random.Int(1, 3)) : null,
includeOptionalProperties ? (script ?? _faker.Random.String2(_faker.Random.Number(1, 50))) : null, includeScript ? (script ?? _faker.Random.String2(_faker.Random.Number(1, 50))) : null,
includeOptionalProperties ? (key ?? _faker.PickRandom<MusicKey>()) : null, includeKey ? (key ?? _faker.PickRandom<MusicKey>()) : null,
includeOptionalProperties ? (bpm ?? _faker.Random.Int(40, 240)) : null, includeBpm ? (bpm ?? _faker.Random.Int(40, 240)) : null,
includeOptionalProperties ? (work ?? _faker.Music.Genre()) : null, includeWork ? (work ?? _faker.Music.Genre()) : null,
includeOptionalProperties ? (musicBrainzRecordingId ?? _faker.Random.Guid()) : null, includeMusicBrainzRecordingId ? (musicBrainzRecordingId ?? _faker.Random.Guid()) : null,
includeOptionalProperties ? (musicBrainzTrackId ?? _faker.Random.Guid()) : null, includeMusicBrainzTrackId ? (musicBrainzTrackId ?? _faker.Random.Guid()) : null,
includeOptionalProperties ? (musicBrainzWorkId ?? _faker.Random.Guid()) : null, includeMusicBrainzWorkId ? (musicBrainzWorkId ?? _faker.Random.Guid()) : null,
includeOptionalProperties ? (moods ?? [.. _moodDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null, includeMoods ? (moods ?? [.. _moodDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null,
includeOptionalProperties ? (isrcs ?? [.. _isrcDtoFixture.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, includeContributors ? (contributors ?? [.. _mediaContributorReferenceDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null,
includeRatings ? (ratings ?? [.. _audioRatingDtoFixture.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="contributors">Optional. The contributors of the book.</param>
/// <param name="ratings">Optional. The ratings 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="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> /// <returns>The created command to add a book.</returns>
public AddBookCommand Create( public AddBookCommand Create(
string? libraryId = null, string? libraryId = null,
@@ -74,7 +88,21 @@ public class AddBookCommandFixture
List<MediaContributorReferenceDto>? contributors = null, List<MediaContributorReferenceDto>? contributors = null,
List<BookRatingDto>? ratings = null, List<BookRatingDto>? ratings = null,
bool includeMetadata = true, 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>() return new Faker<AddBookCommand>()
.CustomInstantiator(f => new AddBookCommand( .CustomInstantiator(f => new AddBookCommand(
@@ -101,22 +129,22 @@ public class AddBookCommandFixture
.RuleFor(x => x.LibraryId, libraryId ?? Guid.NewGuid().ToString()) .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.Path, f => path ?? Path.Combine(Path.GetTempPath(), "lumina-books", f.System.FileName()))
.RuleFor(x => x.Metadata, includeMetadata ? (metadata ?? _writtenContentMetadataDtoFixture.Create()) : null) .RuleFor(x => x.Metadata, includeMetadata ? (metadata ?? _writtenContentMetadataDtoFixture.Create()) : null)
.RuleFor(x => x.Format, f => format ?? (includeOptionalProperties ? f.PickRandom<BookFormat>() : null)) .RuleFor(x => x.Format, f => format ?? (includeFormat ? f.PickRandom<BookFormat>() : null))
.RuleFor(x => x.Edition, f => edition ?? (includeOptionalProperties ? f.Random.String2(f.Random.Number(1, 50)) : null)) .RuleFor(x => x.Edition, f => edition ?? (includeEdition ? 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.VolumeNumber, f => volumeNumber ?? (includeVolumeNumber ? (float?)f.Random.Number(1, 3) : null))
.RuleFor(x => x.Series, series) .RuleFor(x => x.Series, series)
.RuleFor(x => x.ASIN, f => asin ?? (includeOptionalProperties ? f.Random.String2(10) : null)) .RuleFor(x => x.ASIN, f => asin ?? (includeAsin ? f.Random.String2(10) : null))
.RuleFor(x => x.GoodreadsId, f => goodreadsId ?? (includeOptionalProperties ? f.Random.Number(100000, 500000).ToString() : null)) .RuleFor(x => x.GoodreadsId, f => goodreadsId ?? (includeGoodreadsId ? f.Random.Number(100000, 500000).ToString() : null))
.RuleFor(x => x.LCCN, f => lccn ?? (includeOptionalProperties ? CreateLccn(f) : null)) .RuleFor(x => x.LCCN, f => lccn ?? (includeLccn ? CreateLccn(f) : null))
.RuleFor(x => x.OCLCNumber, f => oclcNumber ?? (includeOptionalProperties ? CreateOclcNumber(f) : null)) .RuleFor(x => x.OCLCNumber, f => oclcNumber ?? (includeOclcNumber ? CreateOclcNumber(f) : null))
.RuleFor(x => x.OpenLibraryId, f => openLibraryId ?? (includeOptionalProperties ? CreateOpenLibraryId(f) : null)) .RuleFor(x => x.OpenLibraryId, f => openLibraryId ?? (includeOpenLibraryId ? CreateOpenLibraryId(f) : null))
.RuleFor(x => x.LibraryThingId, f => libraryThingId ?? (includeOptionalProperties ? f.Random.String2(f.Random.Number(1, 50)) : null)) .RuleFor(x => x.LibraryThingId, f => libraryThingId ?? (includeLibraryThingId ? f.Random.String2(f.Random.Number(1, 50)) : null))
.RuleFor(x => x.GoogleBooksId, f => googleBooksId ?? (includeOptionalProperties ? CreateGoogleBooksId(f) : null)) .RuleFor(x => x.GoogleBooksId, f => googleBooksId ?? (includeGoogleBooksId ? CreateGoogleBooksId(f) : null))
.RuleFor(x => x.BarnesAndNobleId, f => barnesAndNobleId ?? (includeOptionalProperties ? f.Random.String2(10, "0123456789") : null)) .RuleFor(x => x.BarnesAndNobleId, f => barnesAndNobleId ?? (includeBarnesAndNobleId ? f.Random.String2(10, "0123456789") : null))
.RuleFor(x => x.AppleBooksId, f => appleBooksId ?? (includeOptionalProperties ? $"id{f.Random.Number(1, 999999)}" : null)) .RuleFor(x => x.AppleBooksId, f => appleBooksId ?? (includeAppleBooksId ? $"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.ISBNs, f => isbns ?? (includeIsbns ? [.. _isbnDtoFixture.CreateMany(f.Random.Number(1, 3))] : null))
.RuleFor(p => p.Ratings, f => ratings ?? (includeOptionalProperties ? [.. _bookRatingDtoFixture.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 ?? (includeOptionalProperties ? [.. _mediaContributorReferenceDtoFixture.CreateMany(f.Random.Number(1, 3))] : null)); .RuleFor(x => x.Contributors, f => contributors ?? (includeContributors ? [.. _mediaContributorReferenceDtoFixture.CreateMany(f.Random.Number(1, 3))] : null));
} }
/// <summary> /// <summary>
@@ -51,7 +51,21 @@ public class UpdateBookCommandFixture
/// <param name="contributors">Optional. The contributors 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="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="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> /// <returns>The created command to update a book.</returns>
public UpdateBookCommand Create( public UpdateBookCommand Create(
string? libraryId = null, string? libraryId = null,
@@ -74,7 +88,21 @@ public class UpdateBookCommandFixture
List<MediaContributorReferenceDto>? contributors = null, List<MediaContributorReferenceDto>? contributors = null,
List<BookRatingDto>? ratings = null, List<BookRatingDto>? ratings = null,
bool includeMetadata = true, 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>() return new Faker<UpdateBookCommand>()
.CustomInstantiator(f => new UpdateBookCommand( .CustomInstantiator(f => new UpdateBookCommand(
@@ -101,22 +129,22 @@ public class UpdateBookCommandFixture
.RuleFor(x => x.LibraryId, libraryId ?? Guid.NewGuid().ToString()) .RuleFor(x => x.LibraryId, libraryId ?? Guid.NewGuid().ToString())
.RuleFor(x => x.BookId, bookId ?? Guid.NewGuid().ToString()) .RuleFor(x => x.BookId, bookId ?? Guid.NewGuid().ToString())
.RuleFor(x => x.Metadata, includeMetadata ? (metadata ?? _writtenContentMetadataDtoFixture.Create()) : null) .RuleFor(x => x.Metadata, includeMetadata ? (metadata ?? _writtenContentMetadataDtoFixture.Create()) : null)
.RuleFor(x => x.Format, f => format ?? (includeOptionalProperties ? f.PickRandom<BookFormat>() : null)) .RuleFor(x => x.Format, f => format ?? (includeFormat ? f.PickRandom<BookFormat>() : null))
.RuleFor(x => x.Edition, f => edition ?? (includeOptionalProperties ? f.Random.String2(f.Random.Number(1, 50)) : null)) .RuleFor(x => x.Edition, f => edition ?? (includeEdition ? 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.VolumeNumber, f => volumeNumber ?? (includeVolumeNumber ? (float?)f.Random.Number(1, 3) : null))
.RuleFor(x => x.Series, series) .RuleFor(x => x.Series, series)
.RuleFor(x => x.ASIN, f => asin ?? (includeOptionalProperties ? f.Random.String2(10) : null)) .RuleFor(x => x.ASIN, f => asin ?? (includeAsin ? f.Random.String2(10) : null))
.RuleFor(x => x.GoodreadsId, f => goodreadsId ?? (includeOptionalProperties ? f.Random.Number(100000, 500000).ToString() : null)) .RuleFor(x => x.GoodreadsId, f => goodreadsId ?? (includeGoodreadsId ? f.Random.Number(100000, 500000).ToString() : null))
.RuleFor(x => x.LCCN, f => lccn ?? (includeOptionalProperties ? CreateLccn(f) : null)) .RuleFor(x => x.LCCN, f => lccn ?? (includeLccn ? CreateLccn(f) : null))
.RuleFor(x => x.OCLCNumber, f => oclcNumber ?? (includeOptionalProperties ? CreateOclcNumber(f) : null)) .RuleFor(x => x.OCLCNumber, f => oclcNumber ?? (includeOclcNumber ? CreateOclcNumber(f) : null))
.RuleFor(x => x.OpenLibraryId, f => openLibraryId ?? (includeOptionalProperties ? CreateOpenLibraryId(f) : null)) .RuleFor(x => x.OpenLibraryId, f => openLibraryId ?? (includeOpenLibraryId ? CreateOpenLibraryId(f) : null))
.RuleFor(x => x.LibraryThingId, f => libraryThingId ?? (includeOptionalProperties ? f.Random.String2(f.Random.Number(1, 50)) : null)) .RuleFor(x => x.LibraryThingId, f => libraryThingId ?? (includeLibraryThingId ? f.Random.String2(f.Random.Number(1, 50)) : null))
.RuleFor(x => x.GoogleBooksId, f => googleBooksId ?? (includeOptionalProperties ? CreateGoogleBooksId(f) : null)) .RuleFor(x => x.GoogleBooksId, f => googleBooksId ?? (includeGoogleBooksId ? CreateGoogleBooksId(f) : null))
.RuleFor(x => x.BarnesAndNobleId, f => barnesAndNobleId ?? (includeOptionalProperties ? f.Random.String2(10, "0123456789") : null)) .RuleFor(x => x.BarnesAndNobleId, f => barnesAndNobleId ?? (includeBarnesAndNobleId ? f.Random.String2(10, "0123456789") : null))
.RuleFor(x => x.AppleBooksId, f => appleBooksId ?? (includeOptionalProperties ? $"id{f.Random.Number(1, 999999)}" : null)) .RuleFor(x => x.AppleBooksId, f => appleBooksId ?? (includeAppleBooksId ? $"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.ISBNs, f => isbns ?? (includeIsbns ? [.. _isbnDtoFixture.CreateMany(f.Random.Number(1, 3))] : null))
.RuleFor(p => p.Ratings, f => ratings ?? (includeOptionalProperties ? [.. _bookRatingDtoFixture.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 ?? (includeOptionalProperties ? [.. _mediaContributorReferenceDtoFixture.CreateMany(f.Random.Number(1, 3))] : null)); .RuleFor(x => x.Contributors, f => contributors ?? (includeContributors ? [.. _mediaContributorReferenceDtoFixture.CreateMany(f.Random.Number(1, 3))] : null));
} }
/// <summary> /// <summary>
@@ -17,7 +17,6 @@ namespace Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary;
public class AudioRatingDtoFixture public class AudioRatingDtoFixture
{ {
private readonly Fixture _fixture = new(); private readonly Fixture _fixture = new();
private readonly Random _random = new();
/// <summary> /// <summary>
/// Creates a random valid <see cref="AudioRatingDto"/>. /// 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="maxValue">Optional. The maximum possible rating value.</param>
/// <param name="source">Optional. The rating source.</param> /// <param name="source">Optional. The rating source.</param>
/// <param name="voteCount">Optional. The number of votes.</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="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> /// <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> /// <returns>The created <see cref="AudioRatingDto"/>.</returns>
@@ -34,14 +35,16 @@ public class AudioRatingDtoFixture
decimal? maxValue = null, decimal? maxValue = null,
AudioRatingSource? source = null, AudioRatingSource? source = null,
int? voteCount = null, int? voteCount = null,
bool includeValue = true,
bool includeMaxValue = true,
bool includeSource = true, bool includeSource = true,
bool includeVoteCount = true) bool includeVoteCount = true)
{ {
return new AudioRatingDto( return new AudioRatingDto(
value ?? _random.Next(1, 5), includeValue ? (value ?? Random.Shared.Next(1, 5)) : null,
maxValue ?? 5, includeMaxValue ? (maxValue ?? 5) : null,
includeSource ? (source ?? _fixture.Create<AudioRatingSource>()) : 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="ratings">Optional. The ratings of the book.</param>
/// <param name="coverImagePath">Optional. The path of the cover image 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="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> /// <returns>The created <see cref="BookMetadataDto"/>.</returns>
public BookMetadataDto Create( public BookMetadataDto Create(
string? title = null, string? title = null,
@@ -88,26 +93,31 @@ public class BookMetadataDtoFixture
List<BookRatingDto>? ratings = null, List<BookRatingDto>? ratings = null,
string? coverImagePath = null, string? coverImagePath = null,
bool includeTitle = true, 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); int releaseYear = _faker.Random.Int(1900, 2024);
return new BookMetadataDto( return new BookMetadataDto(
includeTitle ? title ?? (includeOptionalProperties ? _faker.Lorem.Sentence(3) : null) : null, includeTitle ? title ?? _faker.Lorem.Sentence(3) : null,
originalTitle, originalTitle,
description, description,
releaseInfo ?? (includeOptionalProperties ? _releaseInfoDtoFixture.Create( includeReleaseInfo ? (releaseInfo ?? _releaseInfoDtoFixture.Create(
originalReleaseDate: new DateOnly(releaseYear, 1, 1), originalReleaseDate: new DateOnly(releaseYear, 1, 1),
originalReleaseYear: releaseYear, originalReleaseYear: releaseYear,
releaseCountry: _faker.PickRandom<ReleaseCountry>()) : null), releaseCountry: _faker.PickRandom<ReleaseCountry>())) : null,
genres ?? (includeOptionalProperties ? [_genreDtoFixture.Create()] : null), includeGenres ? (genres ?? [_genreDtoFixture.Create()]) : null,
tags ?? (includeOptionalProperties ? [_tagDtoFixture.Create()] : null), includeTags ? (tags ?? [_tagDtoFixture.Create()]) : null,
language ?? (includeOptionalProperties ? _languageInfoDtoFixture.Create() : null), includeLanguage ? (language ?? _languageInfoDtoFixture.Create()) : null,
originalLanguage, originalLanguage,
publisher, publisher,
pageCount, pageCount,
format ?? (includeOptionalProperties ? _faker.PickRandom<BookFormat>() : null), includeFormat ? (format ?? _faker.PickRandom<BookFormat>()) : null,
edition, edition,
volumeNumber ?? (includeOptionalProperties ? _faker.Random.Int(1, 10) : null), includeVolumeNumber ? (volumeNumber ?? _faker.Random.Int(1, 10)) : null,
series, series,
asin, asin,
goodreadsId, goodreadsId,
@@ -17,7 +17,6 @@ namespace Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary.
public class BookRatingDtoFixture public class BookRatingDtoFixture
{ {
private readonly Fixture _fixture = new(); private readonly Fixture _fixture = new();
private readonly Random _random = new();
/// <summary> /// <summary>
/// Creates a <see cref="BookRatingDto"/>. /// Creates a <see cref="BookRatingDto"/>.
@@ -26,20 +25,22 @@ public class BookRatingDtoFixture
/// <param name="maxValue">Optional. The maximum possible rating value.</param> /// <param name="maxValue">Optional. The maximum possible rating value.</param>
/// <param name="source">Optional. The rating source.</param> /// <param name="source">Optional. The rating source.</param>
/// <param name="voteCount">Optional. The number of votes.</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> /// <returns>The created <see cref="BookRatingDto"/>.</returns>
public BookRatingDto Create( public BookRatingDto Create(
decimal? value = null, decimal? value = null,
decimal? maxValue = null, decimal? maxValue = null,
BookRatingSource? source = null, BookRatingSource? source = null,
int? voteCount = null, int? voteCount = null,
bool includeOptionalProperties = true) bool includeSource = true,
bool includeVoteCount = true)
{ {
return new BookRatingDto( return new BookRatingDto(
value ?? _random.Next(1, 5), value ?? Random.Shared.Next(1, 5),
maxValue ?? 5, maxValue ?? 5,
source ?? (includeOptionalProperties ? _fixture.Create<BookRatingSource>() : null), includeSource ? (source ?? _fixture.Create<BookRatingSource>()) : null,
voteCount ?? (includeOptionalProperties ? _random.Next(1, 1000) : 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="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="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="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="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> /// <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> /// <returns>The created request to add a track.</returns>
@@ -76,7 +85,16 @@ public class AddTrackRequestFixture
bool includePath = true, bool includePath = true,
bool includeMetadata = true, bool includeMetadata = true,
bool includeTrackNumber = 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 includeContributors = true,
bool includeRatings = true) bool includeRatings = true)
{ {
@@ -84,16 +102,16 @@ public class AddTrackRequestFixture
includePath ? path ?? Path.Combine(Path.GetTempPath(), "lumina-tracks", _faker.System.FileName()) : null, includePath ? path ?? Path.Combine(Path.GetTempPath(), "lumina-tracks", _faker.System.FileName()) : null,
includeMetadata ? metadata ?? _audioMetadataDtoFixture.Create() : null, includeMetadata ? metadata ?? _audioMetadataDtoFixture.Create() : null,
includeTrackNumber ? trackNumber ?? _faker.Random.Int(1, 30) : null, includeTrackNumber ? trackNumber ?? _faker.Random.Int(1, 30) : null,
includeOptionalProperties ? discNumber ?? _faker.Random.Int(1, 3) : null, includeDiscNumber ? discNumber ?? _faker.Random.Int(1, 3) : null,
includeOptionalProperties ? script ?? _faker.Random.AlphaNumeric(4) : null, includeScript ? script ?? _faker.Random.AlphaNumeric(4) : null,
includeOptionalProperties ? key ?? _faker.PickRandom<MusicKey>() : null, includeKey ? key ?? _faker.PickRandom<MusicKey>() : null,
includeOptionalProperties ? bpm ?? _faker.Random.Int(40, 220) : null, includeBpm ? bpm ?? _faker.Random.Int(40, 220) : null,
includeOptionalProperties ? work ?? _faker.Lorem.Sentence() : null, includeWork ? work ?? _faker.Lorem.Sentence() : null,
includeOptionalProperties ? musicBrainzRecordingId ?? _faker.Random.Guid() : null, includeMusicBrainzRecordingId ? musicBrainzRecordingId ?? _faker.Random.Guid() : null,
includeOptionalProperties ? musicBrainzTrackId ?? _faker.Random.Guid() : null, includeMusicBrainzTrackId ? musicBrainzTrackId ?? _faker.Random.Guid() : null,
includeOptionalProperties ? musicBrainzWorkId ?? _faker.Random.Guid() : null, includeMusicBrainzWorkId ? musicBrainzWorkId ?? _faker.Random.Guid() : null,
includeOptionalProperties ? moods ?? _moodDtoFixture.CreateMany(_faker.Random.Int(1, 3)) : null, includeMoods ? moods ?? _moodDtoFixture.CreateMany(_faker.Random.Int(1, 3)) : null,
includeOptionalProperties ? isrcs ?? _isrcDtoFixture.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, includeContributors ? contributors ?? _mediaContributorReferenceDtoFixture.CreateMany(_faker.Random.Int(1, 3)) : null,
includeRatings ? ratings ?? _audioRatingDtoFixture.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="isrcs">Optional. The ISRC codes of the track.</param>
/// <param name="contributors">Optional. The media contributors that performed on 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="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="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="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> /// <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<IsrcDto>? isrcs = null,
List<MediaContributorReferenceDto>? contributors = null, List<MediaContributorReferenceDto>? contributors = null,
List<AudioRatingDto>? ratings = 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 includeContributors = true,
bool includeRatings = true, bool includeRatings = true,
bool includePath = true, bool includePath = true,
@@ -83,16 +101,16 @@ public class UpdateTrackRequestFixture
includePath ? (path ?? _faker.System.FilePath()) : null, includePath ? (path ?? _faker.System.FilePath()) : null,
includeMetadata ? (metadata ?? _audioMetadataDtoFixture.Create()) : null, includeMetadata ? (metadata ?? _audioMetadataDtoFixture.Create()) : null,
includeTrackNumber ? (trackNumber ?? _faker.Random.Int(1, 20)) : null, includeTrackNumber ? (trackNumber ?? _faker.Random.Int(1, 20)) : null,
includeOptionalProperties ? (discNumber ?? _faker.Random.Int(1, 3)) : null, includeDiscNumber ? (discNumber ?? _faker.Random.Int(1, 3)) : null,
includeOptionalProperties ? (script ?? _faker.Random.String2(_faker.Random.Number(1, 50))) : null, includeScript ? (script ?? _faker.Random.String2(_faker.Random.Number(1, 50))) : null,
includeOptionalProperties ? (key ?? _faker.PickRandom<MusicKey>()) : null, includeKey ? (key ?? _faker.PickRandom<MusicKey>()) : null,
includeOptionalProperties ? (bpm ?? _faker.Random.Int(40, 240)) : null, includeBpm ? (bpm ?? _faker.Random.Int(40, 240)) : null,
includeOptionalProperties ? (work ?? _faker.Music.Genre()) : null, includeWork ? (work ?? _faker.Music.Genre()) : null,
includeOptionalProperties ? (musicBrainzRecordingId ?? _faker.Random.Guid()) : null, includeMusicBrainzRecordingId ? (musicBrainzRecordingId ?? _faker.Random.Guid()) : null,
includeOptionalProperties ? (musicBrainzTrackId ?? _faker.Random.Guid()) : null, includeMusicBrainzTrackId ? (musicBrainzTrackId ?? _faker.Random.Guid()) : null,
includeOptionalProperties ? (musicBrainzWorkId ?? _faker.Random.Guid()) : null, includeMusicBrainzWorkId ? (musicBrainzWorkId ?? _faker.Random.Guid()) : null,
includeOptionalProperties ? (moods ?? [.. _moodDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null, includeMoods ? (moods ?? [.. _moodDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null,
includeOptionalProperties ? (isrcs ?? [.. _isrcDtoFixture.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, includeContributors ? (contributors ?? [.. _mediaContributorReferenceDtoFixture.CreateMany(_faker.Random.Int(1, 3))]) : null,
includeRatings ? (ratings ?? [.. _audioRatingDtoFixture.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="isbns">Optional. The ISBNs of the book.</param>
/// <param name="contributors">Optional. The contributors 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="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> /// <returns>The created request to add a book.</returns>
public AddBookRequest Create( public AddBookRequest Create(
string? path = null, string? path = null,
@@ -70,7 +84,21 @@ public class AddBookRequestFixture
List<IsbnDto>? isbns = null, List<IsbnDto>? isbns = null,
List<MediaContributorReferenceDto>? contributors = null, List<MediaContributorReferenceDto>? contributors = null,
List<BookRatingDto>? ratings = 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>() return new Faker<AddBookRequest>()
.CustomInstantiator(f => new 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.Path, f => path ?? Path.Combine(Path.GetTempPath(), "lumina-books", f.System.FileName()))
.RuleFor(x => x.Metadata, metadata ?? _writtenContentMetadataDtoFixture.Create()) .RuleFor(x => x.Metadata, metadata ?? _writtenContentMetadataDtoFixture.Create())
.RuleFor(x => x.Format, f => format ?? (includeOptionalProperties ? f.PickRandom<BookFormat>() : null)) .RuleFor(x => x.Format, f => format ?? (includeFormat ? f.PickRandom<BookFormat>() : null))
.RuleFor(x => x.Edition, f => edition ?? (includeOptionalProperties ? f.Random.String2(f.Random.Number(1, 50)) : null)) .RuleFor(x => x.Edition, f => edition ?? (includeEdition ? 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.VolumeNumber, f => volumeNumber ?? (includeVolumeNumber ? (float?)f.Random.Number(1, 3) : null))
.RuleFor(x => x.Series, series) .RuleFor(x => x.Series, series)
.RuleFor(x => x.ASIN, f => asin ?? (includeOptionalProperties ? f.Random.String2(10) : null)) .RuleFor(x => x.ASIN, f => asin ?? (includeAsin ? f.Random.String2(10) : null))
.RuleFor(x => x.GoodreadsId, f => goodreadsId ?? (includeOptionalProperties ? f.Random.Number(100000, 500000).ToString() : null)) .RuleFor(x => x.GoodreadsId, f => goodreadsId ?? (includeGoodreadsId ? f.Random.Number(100000, 500000).ToString() : null))
.RuleFor(x => x.LCCN, f => lccn ?? (includeOptionalProperties ? CreateLccn(f) : null)) .RuleFor(x => x.LCCN, f => lccn ?? (includeLccn ? CreateLccn(f) : null))
.RuleFor(x => x.OCLCNumber, f => oclcNumber ?? (includeOptionalProperties ? CreateOclcNumber(f) : null)) .RuleFor(x => x.OCLCNumber, f => oclcNumber ?? (includeOclcNumber ? CreateOclcNumber(f) : null))
.RuleFor(x => x.OpenLibraryId, f => openLibraryId ?? (includeOptionalProperties ? CreateOpenLibraryId(f) : null)) .RuleFor(x => x.OpenLibraryId, f => openLibraryId ?? (includeOpenLibraryId ? CreateOpenLibraryId(f) : null))
.RuleFor(x => x.LibraryThingId, f => libraryThingId ?? (includeOptionalProperties ? f.Random.String2(f.Random.Number(1, 50)) : null)) .RuleFor(x => x.LibraryThingId, f => libraryThingId ?? (includeLibraryThingId ? f.Random.String2(f.Random.Number(1, 50)) : null))
.RuleFor(x => x.GoogleBooksId, f => googleBooksId ?? (includeOptionalProperties ? CreateGoogleBooksId(f) : null)) .RuleFor(x => x.GoogleBooksId, f => googleBooksId ?? (includeGoogleBooksId ? CreateGoogleBooksId(f) : null))
.RuleFor(x => x.BarnesAndNobleId, f => barnesAndNobleId ?? (includeOptionalProperties ? f.Random.String2(10, "0123456789") : null)) .RuleFor(x => x.BarnesAndNobleId, f => barnesAndNobleId ?? (includeBarnesAndNobleId ? f.Random.String2(10, "0123456789") : null))
.RuleFor(x => x.AppleBooksId, f => appleBooksId ?? (includeOptionalProperties ? $"id{f.Random.Number(1, 999999)}" : null)) .RuleFor(x => x.AppleBooksId, f => appleBooksId ?? (includeAppleBooksId ? $"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.ISBNs, f => isbns ?? (includeIsbns ? [.. _isbnDtoFixture.CreateMany(f.Random.Number(1, 3))] : null))
.RuleFor(p => p.Ratings, f => ratings ?? (includeOptionalProperties ? [.. _bookRatingDtoFixture.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 ?? (includeOptionalProperties ? [.. _mediaContributorReferenceDtoFixture.CreateMany(f.Random.Number(1, 3))] : null)); .RuleFor(x => x.Contributors, f => contributors ?? (includeContributors ? [.. _mediaContributorReferenceDtoFixture.CreateMany(f.Random.Number(1, 3))] : null));
} }
/// <summary> /// <summary>
@@ -47,7 +47,21 @@ public class UpdateBookRequestFixture
/// <param name="isbns">Optional. The ISBNs of the book.</param> /// <param name="isbns">Optional. The ISBNs of the book.</param>
/// <param name="contributors">Optional. The contributors 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="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> /// <returns>The created request to update a book.</returns>
public UpdateBookRequest Create( public UpdateBookRequest Create(
WrittenContentMetadataDto? metadata = null, WrittenContentMetadataDto? metadata = null,
@@ -67,7 +81,21 @@ public class UpdateBookRequestFixture
List<IsbnDto>? isbns = null, List<IsbnDto>? isbns = null,
List<MediaContributorReferenceDto>? contributors = null, List<MediaContributorReferenceDto>? contributors = null,
List<BookRatingDto>? ratings = 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>() return new Faker<UpdateBookRequest>()
.CustomInstantiator(f => new UpdateBookRequest( .CustomInstantiator(f => new UpdateBookRequest(
@@ -90,22 +118,22 @@ public class UpdateBookRequestFixture
default! default!
)) ))
.RuleFor(x => x.Metadata, metadata ?? _writtenContentMetadataDtoFixture.Create()) .RuleFor(x => x.Metadata, metadata ?? _writtenContentMetadataDtoFixture.Create())
.RuleFor(x => x.Format, f => format ?? (includeOptionalProperties ? f.PickRandom<BookFormat>() : null)) .RuleFor(x => x.Format, f => format ?? (includeFormat ? f.PickRandom<BookFormat>() : null))
.RuleFor(x => x.Edition, f => edition ?? (includeOptionalProperties ? f.Random.String2(f.Random.Number(1, 50)) : null)) .RuleFor(x => x.Edition, f => edition ?? (includeEdition ? 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.VolumeNumber, f => volumeNumber ?? (includeVolumeNumber ? (float?)f.Random.Number(1, 3) : null))
.RuleFor(x => x.Series, series) .RuleFor(x => x.Series, series)
.RuleFor(x => x.ASIN, f => asin ?? (includeOptionalProperties ? f.Random.String2(10) : null)) .RuleFor(x => x.ASIN, f => asin ?? (includeAsin ? f.Random.String2(10) : null))
.RuleFor(x => x.GoodreadsId, f => goodreadsId ?? (includeOptionalProperties ? f.Random.Number(100000, 500000).ToString() : null)) .RuleFor(x => x.GoodreadsId, f => goodreadsId ?? (includeGoodreadsId ? f.Random.Number(100000, 500000).ToString() : null))
.RuleFor(x => x.LCCN, f => lccn ?? (includeOptionalProperties ? CreateLccn(f) : null)) .RuleFor(x => x.LCCN, f => lccn ?? (includeLccn ? CreateLccn(f) : null))
.RuleFor(x => x.OCLCNumber, f => oclcNumber ?? (includeOptionalProperties ? CreateOclcNumber(f) : null)) .RuleFor(x => x.OCLCNumber, f => oclcNumber ?? (includeOclcNumber ? CreateOclcNumber(f) : null))
.RuleFor(x => x.OpenLibraryId, f => openLibraryId ?? (includeOptionalProperties ? CreateOpenLibraryId(f) : null)) .RuleFor(x => x.OpenLibraryId, f => openLibraryId ?? (includeOpenLibraryId ? CreateOpenLibraryId(f) : null))
.RuleFor(x => x.LibraryThingId, f => libraryThingId ?? (includeOptionalProperties ? f.Random.String2(f.Random.Number(1, 50)) : null)) .RuleFor(x => x.LibraryThingId, f => libraryThingId ?? (includeLibraryThingId ? f.Random.String2(f.Random.Number(1, 50)) : null))
.RuleFor(x => x.GoogleBooksId, f => googleBooksId ?? (includeOptionalProperties ? CreateGoogleBooksId(f) : null)) .RuleFor(x => x.GoogleBooksId, f => googleBooksId ?? (includeGoogleBooksId ? CreateGoogleBooksId(f) : null))
.RuleFor(x => x.BarnesAndNobleId, f => barnesAndNobleId ?? (includeOptionalProperties ? f.Random.String2(10, "0123456789") : null)) .RuleFor(x => x.BarnesAndNobleId, f => barnesAndNobleId ?? (includeBarnesAndNobleId ? f.Random.String2(10, "0123456789") : null))
.RuleFor(x => x.AppleBooksId, f => appleBooksId ?? (includeOptionalProperties ? $"id{f.Random.Number(1, 999999)}" : null)) .RuleFor(x => x.AppleBooksId, f => appleBooksId ?? (includeAppleBooksId ? $"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.ISBNs, f => isbns ?? (includeIsbns ? [.. _isbnDtoFixture.CreateMany(f.Random.Number(1, 3))] : null))
.RuleFor(p => p.Ratings, f => ratings ?? (includeOptionalProperties ? [.. _bookRatingDtoFixture.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 ?? (includeOptionalProperties ? [.. _mediaContributorReferenceDtoFixture.CreateMany(f.Random.Number(1, 3))] : null)); .RuleFor(x => x.Contributors, f => contributors ?? (includeContributors ? [.. _mediaContributorReferenceDtoFixture.CreateMany(f.Random.Number(1, 3))] : null));
} }
/// <summary> /// <summary>
@@ -28,12 +28,12 @@ public class ThemeResponseFixture
/// <param name="author">Optional. The author of the theme.</param> /// <param name="author">Optional. The author of the theme.</param>
/// <param name="version">Optional. The version 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="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="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="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="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="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> /// <returns>The created <see cref="ThemeResponse"/>.</returns>
public ThemeResponse Create( public ThemeResponse Create(
Guid? id = null, Guid? id = null,
@@ -43,12 +43,12 @@ public class ThemeResponseFixture
string? author = null, string? author = null,
string? version = null, string? version = null,
string? previewPath = null, string? previewPath = null,
bool includePreviewPath = false,
ThemeInstallSource? installSource = null, ThemeInstallSource? installSource = null,
bool? isCurrent = null, bool? isCurrent = null,
bool includeIsCurrent = false,
DateTime? installedAtUtc = null, DateTime? installedAtUtc = null,
bool? isDeleted = null) bool? isDeleted = null,
bool includePreviewPath = false,
bool includeIsCurrent = false)
{ {
return new ThemeResponse( return new ThemeResponse(
id ?? Guid.NewGuid(), id ?? Guid.NewGuid(),
@@ -23,7 +23,6 @@ namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedCo
public class LibraryFixture public class LibraryFixture
{ {
private readonly Faker _faker = new(); private readonly Faker _faker = new();
private readonly Random _random = new();
private readonly LibraryIdFixture _libraryIdFixture = new(); private readonly LibraryIdFixture _libraryIdFixture = new();
private readonly UserIdFixture _userIdFixture = new(); private readonly UserIdFixture _userIdFixture = new();
private readonly ScanIdFixture _scanIdFixture = new(); private readonly ScanIdFixture _scanIdFixture = new();
@@ -37,13 +36,13 @@ public class LibraryFixture
/// <param name="libraryType">Optional. The library type.</param> /// <param name="libraryType">Optional. The library type.</param>
/// <param name="contentLocations">Optional. The content locations of the library.</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="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="isEnabled">Whether the library is enabled.</param>
/// <param name="isLocked">Whether the library is locked.</param> /// <param name="isLocked">Whether the library is locked.</param>
/// <param name="canDownloadMetadataFromWeb">Whether metadata download from the web is enabled.</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="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="shouldSkipUnchangedDirectoriesDuringScan">Whether unchanged directories should be skipped during scan.</param>
/// <param name="scanIds">Optional. The scan Ids associated with the library.</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> /// <returns>The created <see cref="Library"/>.</returns>
public Library Create( public Library Create(
Guid? id = null, Guid? id = null,
@@ -52,13 +51,13 @@ public class LibraryFixture
LibraryType? libraryType = null, LibraryType? libraryType = null,
IEnumerable<string>? contentLocations = null, IEnumerable<string>? contentLocations = null,
string? coverImage = null, string? coverImage = null,
bool includeCoverImage = true,
bool isEnabled = true, bool isEnabled = true,
bool isLocked = false, bool isLocked = false,
bool canDownloadMetadataFromWeb = true, bool canDownloadMetadataFromWeb = true,
bool shouldSaveMetadataInMediaDirectories = false, bool shouldSaveMetadataInMediaDirectories = false,
bool shouldSkipUnchangedDirectoriesDuringScan = false, bool shouldSkipUnchangedDirectoriesDuringScan = false,
IEnumerable<Guid>? scanIds = null) IEnumerable<Guid>? scanIds = null,
bool includeCoverImage = true)
{ {
List<string> validPaths = List<string> validPaths =
[ [
@@ -77,7 +76,7 @@ public class LibraryFixture
resolvedUserId, resolvedUserId,
title ?? _faker.Random.String2(_faker.Random.Number(1, 50)), title ?? _faker.Random.String2(_faker.Random.Number(1, 50)),
libraryType ?? _faker.PickRandom<LibraryType>(), 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), Optional<string>.FromNullable(resolvedCoverImage),
isEnabled, isEnabled,
isLocked, isLocked,
@@ -91,7 +90,7 @@ public class LibraryFixture
resolvedUserId, resolvedUserId,
title ?? _faker.Random.String2(_faker.Random.Number(1, 50)), title ?? _faker.Random.String2(_faker.Random.Number(1, 50)),
libraryType ?? _faker.PickRandom<LibraryType>(), 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), Optional<string>.FromNullable(resolvedCoverImage),
isEnabled, isEnabled,
isLocked, isLocked,
@@ -28,8 +28,8 @@ public sealed class ThemePackFixture
/// <param name="templates">Optional template mappings written to the manifest.</param> /// <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="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="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="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> /// <returns>The created theme pack ZIP archive.</returns>
public byte[] Create( public byte[] Create(
string themeId = "test-theme", string themeId = "test-theme",
@@ -41,8 +41,8 @@ public sealed class ThemePackFixture
Dictionary<string, string>? templates = null, Dictionary<string, string>? templates = null,
string? preview = "assets/preview.png", string? preview = "assets/preview.png",
string? defaultTemplateContent = null, 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) Dictionary<string, string> manifestTemplates = templates ?? new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
{ {
@@ -21,18 +21,18 @@ public class ThemeNavEntryDtoFixture
/// </summary> /// </summary>
/// <param name="label">Optional label of the entry.</param> /// <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="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="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="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> /// <returns>The created <see cref="ThemeNavEntryDto"/>.</returns>
public ThemeNavEntryDto Create( public ThemeNavEntryDto Create(
string? label = null, string? label = null,
string? url = null, string? url = null,
bool includeUrl = false,
string? cssClass = null, string? cssClass = null,
bool includeCssClass = false, IReadOnlyList<ThemeNavEntryDto>? children = null,
IReadOnlyList<ThemeNavEntryDto>? children = null) bool includeUrl = false,
bool includeCssClass = false)
{ {
return new ThemeNavEntryDto( return new ThemeNavEntryDto(
Label: label ?? _faker.Lorem.Word(), Label: label ?? _faker.Lorem.Word(),
@@ -28,12 +28,12 @@ public class ThemeResponseDtoFixture
/// <param name="author">Optional author of the theme.</param> /// <param name="author">Optional author of the theme.</param>
/// <param name="version">Optional semantic version 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="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="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="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="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="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> /// <returns>A configured <see cref="ThemeResponseDto"/> instance.</returns>
public ThemeResponseDto Create( public ThemeResponseDto Create(
Guid? id = null, Guid? id = null,
@@ -43,12 +43,12 @@ public class ThemeResponseDtoFixture
string? author = null, string? author = null,
string? version = null, string? version = null,
string? previewPath = null, string? previewPath = null,
bool includePreviewPath = false,
ThemeInstallSource? installSource = null, ThemeInstallSource? installSource = null,
bool? isCurrent = null, bool? isCurrent = null,
bool includeIsCurrent = false,
DateTime? installedAtUtc = null, DateTime? installedAtUtc = null,
bool? isDeleted = null) bool? isDeleted = null,
bool includePreviewPath = false,
bool includeIsCurrent = false)
{ {
return new ThemeResponseDto( return new ThemeResponseDto(
Id: id ?? Guid.NewGuid(), Id: id ?? Guid.NewGuid(),
@@ -33,35 +33,67 @@ public class UpdateBookRequestFixture
/// <param name="id">Optional Id of the book to update.</param> /// <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="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="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> /// <returns>A configured <see cref="UpdateBookRequest"/> instance.</returns>
public UpdateBookRequest Create( public UpdateBookRequest Create(
Guid? id = null, Guid? id = null,
Guid? libraryId = null, Guid? libraryId = null,
WrittenContentMetadataDto? metadata = 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 return new UpdateBookRequest
{ {
BookId = id?.ToString() ?? Guid.NewGuid().ToString(), BookId = id?.ToString() ?? Guid.NewGuid().ToString(),
LibraryId = libraryId ?? Guid.NewGuid(), LibraryId = libraryId ?? Guid.NewGuid(),
Metadata = metadata ?? (includeOptionalProperties ? _writtenContentMetadataDtoFixture.Create() : null), Metadata = includeMetadata ? (metadata ?? _writtenContentMetadataDtoFixture.Create()) : null,
Format = includeOptionalProperties ? _faker.PickRandom<BookFormat>() : null, Format = includeFormat ? _faker.PickRandom<BookFormat>() : null,
Edition = includeOptionalProperties ? _faker.Random.String2(_faker.Random.Number(1, 50)) : null, Edition = includeEdition ? _faker.Random.String2(_faker.Random.Number(1, 50)) : null,
VolumeNumber = includeOptionalProperties ? _faker.Random.Number(1, 3) : null, VolumeNumber = includeVolumeNumber ? _faker.Random.Number(1, 3) : null,
Series = includeOptionalProperties ? _bookSeriesDtoFixture.Create() : null, Series = includeSeries ? _bookSeriesDtoFixture.Create() : null,
ASIN = includeOptionalProperties ? _faker.Random.String2(10) : null, ASIN = includeAsin ? _faker.Random.String2(10) : null,
GoodreadsId = includeOptionalProperties ? _faker.Random.Number(100000, 500000).ToString() : null, GoodreadsId = includeGoodreadsId ? _faker.Random.Number(100000, 500000).ToString() : null,
LCCN = includeOptionalProperties ? "n78890351" : null, LCCN = includeLccn ? "n78890351" : null,
OCLCNumber = includeOptionalProperties ? "ocm12345678" : null, OCLCNumber = includeOclcNumber ? "ocm12345678" : null,
OpenLibraryId = includeOptionalProperties ? "OL123456M" : null, OpenLibraryId = includeOpenLibraryId ? "OL123456M" : null,
LibraryThingId = includeOptionalProperties ? _faker.Random.String2(_faker.Random.Number(1, 50)) : null, LibraryThingId = includeLibraryThingId ? _faker.Random.String2(_faker.Random.Number(1, 50)) : null,
GoogleBooksId = includeOptionalProperties ? CreateGoogleBooksId() : null, GoogleBooksId = includeGoogleBooksId ? CreateGoogleBooksId() : null,
BarnesAndNobleId = includeOptionalProperties ? _faker.Random.String2(10, "0123456789") : null, BarnesAndNobleId = includeBarnesAndNobleId ? _faker.Random.String2(10, "0123456789") : null,
AppleBooksId = includeOptionalProperties ? $"id{_faker.Random.Number(1, 999999)}" : null, AppleBooksId = includeAppleBooksId ? $"id{_faker.Random.Number(1, 999999)}" : null,
ISBNs = includeOptionalProperties ? [.. _isbnDtoFixture.CreateMany(_faker.Random.Number(1, 3))] : null, ISBNs = includeIsbns ? [.. _isbnDtoFixture.CreateMany(_faker.Random.Number(1, 3))] : null,
Contributors = includeOptionalProperties ? [.. _mediaContributorDtoFixture.CreateMany(_faker.Random.Number(1, 3))] : null, Contributors = includeContributors ? [.. _mediaContributorDtoFixture.CreateMany(_faker.Random.Number(1, 3))] : null,
Ratings = includeOptionalProperties ? [.. _bookRatingDtoFixture.CreateMany(_faker.Random.Number(1, 3))] : null Ratings = includeRatings ? [.. _bookRatingDtoFixture.CreateMany(_faker.Random.Number(1, 3))] : null
}; };
} }
@@ -121,7 +121,14 @@ public class UpdateTrackEndpointTests : IClassFixture<AuthenticatedLuminaApiFact
isrcs: [], isrcs: [],
contributors: [], contributors: [],
ratings: [], ratings: [],
includeOptionalProperties: false); includeDiscNumber: false,
includeScript: false,
includeKey: false,
includeBpm: false,
includeWork: false,
includeMusicBrainzRecordingId: false,
includeMusicBrainzTrackId: false,
includeMusicBrainzWorkId: false);
// Act // Act
HttpResponseMessage response = await _client.PutAsJsonAsync($"/api/v1/libraries/{libraryId}/artists/{artistId}/albums/{albumId}/tracks/{trackId}", request); HttpResponseMessage response = await _client.PutAsJsonAsync($"/api/v1/libraries/{libraryId}/artists/{artistId}/albums/{albumId}/tracks/{trackId}", request);
@@ -157,7 +164,14 @@ public class UpdateTrackEndpointTests : IClassFixture<AuthenticatedLuminaApiFact
isrcs: [], isrcs: [],
contributors: [], contributors: [],
ratings: [], ratings: [],
includeOptionalProperties: false); includeDiscNumber: false,
includeScript: false,
includeKey: false,
includeBpm: false,
includeWork: false,
includeMusicBrainzRecordingId: false,
includeMusicBrainzTrackId: false,
includeMusicBrainzWorkId: false);
(HttpClient adminClient, _) = await CreateAdminClientAsync(); (HttpClient adminClient, _) = await CreateAdminClientAsync();
// Act // Act
@@ -1039,7 +1053,7 @@ public class UpdateTrackEndpointTests : IClassFixture<AuthenticatedLuminaApiFact
string content = await response.Content.ReadAsStringAsync(); string content = await response.Content.ReadAsStringAsync();
Dictionary<string, JsonElement>? problemDetails = JsonSerializer.Deserialize<Dictionary<string, JsonElement>>(content, _jsonOptions); Dictionary<string, JsonElement>? problemDetails = JsonSerializer.Deserialize<Dictionary<string, JsonElement>>(content, _jsonOptions);
Assert.NotNull(problemDetails); Assert.NotNull(problemDetails);
Assert.Equal(422, problemDetails!["status"].GetInt32()); Assert.Equal((int)HttpStatusCode.UnprocessableEntity, problemDetails!["status"].GetInt32());
Assert.Equal("General.Validation", problemDetails["title"].GetString()); Assert.Equal("General.Validation", problemDetails["title"].GetString());
Assert.Equal("OneOrMoreValidationErrorsOccurred", problemDetails["detail"].GetString()); Assert.Equal("OneOrMoreValidationErrorsOccurred", problemDetails["detail"].GetString());
@@ -702,7 +702,7 @@ public class AddBookEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory>
public async Task AddBook_WhenCalledWithEmptyFormat_ShouldAddBook() public async Task AddBook_WhenCalledWithEmptyFormat_ShouldAddBook()
{ {
// Arrange // Arrange
AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeOptionalProperties: false); AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false);
// Act & Assert // Act & Assert
await AssertCreated(bookRequest); await AssertCreated(bookRequest);
@@ -725,7 +725,7 @@ public class AddBookEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory>
public async Task AddBook_WhenCalledWithEmptyEdition_ShouldAddBook() public async Task AddBook_WhenCalledWithEmptyEdition_ShouldAddBook()
{ {
// Arrange // Arrange
AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeOptionalProperties: false); AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false);
// Act & Assert // Act & Assert
await AssertCreated(bookRequest); await AssertCreated(bookRequest);
@@ -748,7 +748,7 @@ public class AddBookEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory>
public async Task AddBook_WhenCalledWithEmptyVolumeNumber_ShouldAddBook() public async Task AddBook_WhenCalledWithEmptyVolumeNumber_ShouldAddBook()
{ {
// Arrange // Arrange
AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeOptionalProperties: false); AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false);
// Act & Assert // Act & Assert
await AssertCreated(bookRequest); await AssertCreated(bookRequest);
@@ -812,7 +812,7 @@ public class AddBookEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory>
public async Task AddBook_WhenCalledWithEmptyAsin_ShouldAddBook() public async Task AddBook_WhenCalledWithEmptyAsin_ShouldAddBook()
{ {
// Arrange // Arrange
AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeOptionalProperties: false); AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false);
// Act & Assert // Act & Assert
await AssertCreated(bookRequest); await AssertCreated(bookRequest);
@@ -835,7 +835,7 @@ public class AddBookEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory>
public async Task AddBook_WhenCalledWithEmptyGoodreadsId_ShouldAddBook() public async Task AddBook_WhenCalledWithEmptyGoodreadsId_ShouldAddBook()
{ {
// Arrange // Arrange
AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeOptionalProperties: false); AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false);
// Act & Assert // Act & Assert
await AssertCreated(bookRequest); await AssertCreated(bookRequest);
@@ -858,7 +858,7 @@ public class AddBookEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory>
public async Task AddBook_WhenCalledWithEmptyLccn_ShouldAddBook() public async Task AddBook_WhenCalledWithEmptyLccn_ShouldAddBook()
{ {
// Arrange // Arrange
AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeOptionalProperties: false); AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false);
// Act & Assert // Act & Assert
await AssertCreated(bookRequest); await AssertCreated(bookRequest);
@@ -881,7 +881,7 @@ public class AddBookEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory>
public async Task AddBook_WhenCalledWithEmptyOclcNumber_ShouldAddBook() public async Task AddBook_WhenCalledWithEmptyOclcNumber_ShouldAddBook()
{ {
// Arrange // Arrange
AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeOptionalProperties: false); AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false);
// Act & Assert // Act & Assert
await AssertCreated(bookRequest); await AssertCreated(bookRequest);
@@ -904,7 +904,7 @@ public class AddBookEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory>
public async Task AddBook_WhenCalledWithEmptyOpenLibraryId_ShouldAddBook() public async Task AddBook_WhenCalledWithEmptyOpenLibraryId_ShouldAddBook()
{ {
// Arrange // Arrange
AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeOptionalProperties: false); AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false);
// Act & Assert // Act & Assert
await AssertCreated(bookRequest); await AssertCreated(bookRequest);
@@ -927,7 +927,7 @@ public class AddBookEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory>
public async Task AddBook_WhenCalledWithEmptyLibraryThingId_ShouldAddBook() public async Task AddBook_WhenCalledWithEmptyLibraryThingId_ShouldAddBook()
{ {
// Arrange // Arrange
AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeOptionalProperties: false); AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false);
// Act & Assert // Act & Assert
await AssertCreated(bookRequest); await AssertCreated(bookRequest);
@@ -950,7 +950,7 @@ public class AddBookEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory>
public async Task AddBook_WhenCalledWithEmptyGoogleBooksId_ShouldAddBook() public async Task AddBook_WhenCalledWithEmptyGoogleBooksId_ShouldAddBook()
{ {
// Arrange // Arrange
AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeOptionalProperties: false); AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false);
// Act & Assert // Act & Assert
await AssertCreated(bookRequest); await AssertCreated(bookRequest);
@@ -986,7 +986,7 @@ public class AddBookEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory>
public async Task AddBook_WhenCalledWithEmptyBarnesAndNobleId_ShouldAddBook() public async Task AddBook_WhenCalledWithEmptyBarnesAndNobleId_ShouldAddBook()
{ {
// Arrange // Arrange
AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeOptionalProperties: false); AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false);
// Act & Assert // Act & Assert
await AssertCreated(bookRequest); await AssertCreated(bookRequest);
@@ -1022,7 +1022,7 @@ public class AddBookEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory>
public async Task AddBook_WhenCalledWithEmptyAppleBooksId_ShouldAddBook() public async Task AddBook_WhenCalledWithEmptyAppleBooksId_ShouldAddBook()
{ {
// Arrange // Arrange
AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeOptionalProperties: false); AddBookRequest bookRequest = _requestBookFixture.Create(isbns: [], contributors: [], ratings: [], includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false);
// Act & Assert // Act & Assert
await AssertCreated(bookRequest); await AssertCreated(bookRequest);
@@ -1045,7 +1045,7 @@ public class AddBookEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory>
public async Task AddBook_WhenCalledWithNullIsbns_ShouldReturnUnprocessableEntity() public async Task AddBook_WhenCalledWithNullIsbns_ShouldReturnUnprocessableEntity()
{ {
// Arrange // Arrange
AddBookRequest bookRequest = _requestBookFixture.Create(includeOptionalProperties: false); AddBookRequest bookRequest = _requestBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false);
// Act // Act
HttpResponseMessage response = await PostBookAsync(bookRequest); HttpResponseMessage response = await PostBookAsync(bookRequest);
@@ -1148,7 +1148,7 @@ public class AddBookEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory>
public async Task AddBook_WhenCalledWithNullRatings_ShouldReturnUnprocessableEntity() public async Task AddBook_WhenCalledWithNullRatings_ShouldReturnUnprocessableEntity()
{ {
// Arrange // Arrange
AddBookRequest bookRequest = _requestBookFixture.Create(includeOptionalProperties: false); AddBookRequest bookRequest = _requestBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false);
// Act // Act
HttpResponseMessage response = await PostBookAsync(bookRequest); HttpResponseMessage response = await PostBookAsync(bookRequest);
@@ -1197,7 +1197,7 @@ public class AddBookEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory>
public async Task AddBook_WhenCalledWithEmptyRatingVoteCount_ShouldAddBook() public async Task AddBook_WhenCalledWithEmptyRatingVoteCount_ShouldAddBook()
{ {
// Arrange // Arrange
AddBookRequest bookRequest = _requestBookFixture.Create(ratings: [_bookRatingDtoFixture.Create(source: BookRatingSource.Goodreads, includeOptionalProperties: false)]); AddBookRequest bookRequest = _requestBookFixture.Create(ratings: [_bookRatingDtoFixture.Create(source: BookRatingSource.Goodreads, includeVoteCount: false)]);
// Act & Assert // Act & Assert
await AssertCreated(bookRequest); await AssertCreated(bookRequest);
} }
@@ -1838,7 +1838,7 @@ public class AddBookEndpointTests : IClassFixture<AuthenticatedLuminaApiFactory>
private async Task AssertUnprocessableEntityWithValidationErrors(HttpResponseMessage response, params string[] expectedErrorCodes) private async Task AssertUnprocessableEntityWithValidationErrors(HttpResponseMessage response, params string[] expectedErrorCodes)
{ {
Assert.Equal(HttpStatusCode.UnprocessableContent, response.StatusCode); Assert.Equal(HttpStatusCode.UnprocessableEntity, response.StatusCode);
Assert.Equal("application/problem+json", response.Content.Headers.ContentType?.MediaType); Assert.Equal("application/problem+json", response.Content.Headers.ContentType?.MediaType);
string content = await response.Content.ReadAsStringAsync(); string content = await response.Content.ReadAsStringAsync();
@@ -92,7 +92,7 @@ public class UpdateBookEndpointTests : IClassFixture<AuthenticatedLuminaApiFacto
// Arrange // Arrange
Guid userId = GetCurrentUserId(); Guid userId = GetCurrentUserId();
(Guid libraryId, Guid bookId) = await SeedLibraryAndBookAsync(userId, "Original Title"); (Guid libraryId, Guid bookId) = await SeedLibraryAndBookAsync(userId, "Original Title");
UpdateBookRequest request = _requestBookFixture.Create(metadata: _writtenContentMetadataDtoFixture.Create(title: "Updated Title"), isbns: [], contributors: [], ratings: [], includeOptionalProperties: false); UpdateBookRequest request = _requestBookFixture.Create(metadata: _writtenContentMetadataDtoFixture.Create(title: "Updated Title"), isbns: [], contributors: [], ratings: [], includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false);
// Act // Act
HttpResponseMessage response = await _client.PutAsJsonAsync($"/api/v1/libraries/{libraryId}/books/{bookId}", request); HttpResponseMessage response = await _client.PutAsJsonAsync($"/api/v1/libraries/{libraryId}/books/{bookId}", request);
@@ -125,7 +125,7 @@ public class UpdateBookEndpointTests : IClassFixture<AuthenticatedLuminaApiFacto
_mediaContributorReferenceDtoFixture.Create(contributorId: contributorId, role: MediaContributorRole.Illustrator) _mediaContributorReferenceDtoFixture.Create(contributorId: contributorId, role: MediaContributorRole.Illustrator)
]; ];
await SeedContributorsAsync(duplicatedContributors); await SeedContributorsAsync(duplicatedContributors);
UpdateBookRequest request = _requestBookFixture.Create(contributors: duplicatedContributors, isbns: [], ratings: [], includeOptionalProperties: false); UpdateBookRequest request = _requestBookFixture.Create(contributors: duplicatedContributors, isbns: [], ratings: [], includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false);
// Act // Act
HttpResponseMessage response = await _client.PutAsJsonAsync($"/api/v1/libraries/{libraryId}/books/{bookId}", request); HttpResponseMessage response = await _client.PutAsJsonAsync($"/api/v1/libraries/{libraryId}/books/{bookId}", request);
@@ -134,11 +134,10 @@ public class UpdateBookEndpointTests : IClassFixture<AuthenticatedLuminaApiFacto
Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal(HttpStatusCode.OK, response.StatusCode);
using IServiceScope scope = _apiFactory.Services.CreateScope(); using IServiceScope scope = _apiFactory.Services.CreateScope();
LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService<LuminaDbContext>(); LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService<LuminaDbContext>();
List<BookContributorEntity> links = dbContext.Books List<BookContributorEntity> links = [.. dbContext.Books
.Include(book => book.Contributors) .Include(book => book.Contributors)
.Single(book => book.Id == bookId) .Single(book => book.Id == bookId)
.Contributors .Contributors];
.ToList();
Assert.Equal(2, links.Count); Assert.Equal(2, links.Count);
Assert.All(links, link => Assert.Equal(contributorId, link.MediaContributorId)); Assert.All(links, link => Assert.Equal(contributorId, link.MediaContributorId));
Assert.Contains(links, link => link.Role == MediaContributorRole.Author); Assert.Contains(links, link => link.Role == MediaContributorRole.Author);
@@ -1563,7 +1562,7 @@ public class UpdateBookEndpointTests : IClassFixture<AuthenticatedLuminaApiFacto
public async Task UpdateBook_WhenCalledWithNullIsbns_ShouldReturnUnprocessableEntity() public async Task UpdateBook_WhenCalledWithNullIsbns_ShouldReturnUnprocessableEntity()
{ {
// Arrange // Arrange
UpdateBookRequest bookRequest = _requestBookFixture.Create(includeOptionalProperties: false); UpdateBookRequest bookRequest = _requestBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false);
// Act // Act
HttpResponseMessage response = await PutBookAsync(bookRequest); HttpResponseMessage response = await PutBookAsync(bookRequest);
@@ -1706,7 +1705,7 @@ public class UpdateBookEndpointTests : IClassFixture<AuthenticatedLuminaApiFacto
public async Task UpdateBook_WhenCalledWithNullRatings_ShouldReturnUnprocessableEntity() public async Task UpdateBook_WhenCalledWithNullRatings_ShouldReturnUnprocessableEntity()
{ {
// Arrange // Arrange
UpdateBookRequest bookRequest = _requestBookFixture.Create(includeOptionalProperties: false); UpdateBookRequest bookRequest = _requestBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false);
// Act // Act
HttpResponseMessage response = await PutBookAsync(bookRequest); HttpResponseMessage response = await PutBookAsync(bookRequest);
@@ -1784,7 +1783,7 @@ public class UpdateBookEndpointTests : IClassFixture<AuthenticatedLuminaApiFacto
public async Task UpdateBook_WhenCalledWithNullVoteCount_ShouldUpdateBook() public async Task UpdateBook_WhenCalledWithNullVoteCount_ShouldUpdateBook()
{ {
// Arrange // Arrange
UpdateBookRequest bookRequest = _requestBookFixture.Create(ratings: [_bookRatingDtoFixture.Create(source: BookRatingSource.Goodreads, includeOptionalProperties: false)]); UpdateBookRequest bookRequest = _requestBookFixture.Create(ratings: [_bookRatingDtoFixture.Create(source: BookRatingSource.Goodreads, includeVoteCount: false)]);
// Act // Act
HttpResponseMessage response = await PutBookAsync(bookRequest); HttpResponseMessage response = await PutBookAsync(bookRequest);
@@ -1853,7 +1852,7 @@ public class UpdateBookEndpointTests : IClassFixture<AuthenticatedLuminaApiFacto
string content = await response.Content.ReadAsStringAsync(); string content = await response.Content.ReadAsStringAsync();
Dictionary<string, JsonElement>? problemDetails = JsonSerializer.Deserialize<Dictionary<string, JsonElement>>(content, _jsonOptions); Dictionary<string, JsonElement>? problemDetails = JsonSerializer.Deserialize<Dictionary<string, JsonElement>>(content, _jsonOptions);
Assert.NotNull(problemDetails); Assert.NotNull(problemDetails);
Assert.Equal(422, problemDetails!["status"].GetInt32()); Assert.Equal((int)HttpStatusCode.UnprocessableEntity, problemDetails!["status"].GetInt32());
Assert.Equal("General.Validation", problemDetails["title"].GetString()); Assert.Equal("General.Validation", problemDetails["title"].GetString());
Assert.Equal("OneOrMoreValidationErrorsOccurred", problemDetails["detail"].GetString()); Assert.Equal("OneOrMoreValidationErrorsOccurred", problemDetails["detail"].GetString());
@@ -1937,4 +1936,4 @@ public class UpdateBookEndpointTests : IClassFixture<AuthenticatedLuminaApiFacto
{ {
await _apiFactory.RemoveTestUserAsync(); await _apiFactory.RemoveTestUserAsync();
} }
} }
@@ -63,7 +63,16 @@ public class AddTrackRequestMappingTests
AddTrackRequest request = _addTrackRequestFixture.Create( AddTrackRequest request = _addTrackRequestFixture.Create(
path: "/music/queen/bohemian-rhapsody.flac", path: "/music/queen/bohemian-rhapsody.flac",
metadata: _audioMetadataDtoFixture.Create(title: "Love of My Life"), metadata: _audioMetadataDtoFixture.Create(title: "Love of My Life"),
includeOptionalProperties: false); includeDiscNumber: false,
includeScript: false,
includeKey: false,
includeBpm: false,
includeWork: false,
includeMusicBrainzRecordingId: false,
includeMusicBrainzTrackId: false,
includeMusicBrainzWorkId: false,
includeMoods: false,
includeIsrcs: false);
// Act // Act
AddTrackCommand result = request.ToCommand(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString()); AddTrackCommand result = request.ToCommand(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
@@ -84,7 +84,7 @@ public class UpdateTrackCommandMappingTests
Guid libraryId = Guid.NewGuid(); Guid libraryId = Guid.NewGuid();
(Artist artist, Guid albumId, Guid trackId) = CreateDomainArtist(libraryId); (Artist artist, Guid albumId, Guid trackId) = CreateDomainArtist(libraryId);
string updatedPath = "/music/queen/a-night-at-the-opera/03-you-re-my-best-friend.flac"; string updatedPath = "/music/queen/a-night-at-the-opera/03-you-re-my-best-friend.flac";
UpdateTrackCommand command = _updateTrackCommandFixture.Create(libraryId: libraryId.ToString(), artistId: artist.Id.Value.ToString(), albumId: albumId.ToString(), trackId: trackId.ToString(), path: updatedPath, includeOptionalProperties: false, contributors: [], ratings: []); UpdateTrackCommand command = _updateTrackCommandFixture.Create(libraryId: libraryId.ToString(), artistId: artist.Id.Value.ToString(), albumId: albumId.ToString(), trackId: trackId.ToString(), path: updatedPath, includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false, contributors: [], ratings: []);
// Act // Act
Result<Artist> result = command.ToDomainEntity(artist); Result<Artist> result = command.ToDomainEntity(artist);
@@ -63,7 +63,19 @@ public class UpdateTrackRequestMappingTests
Guid artistId = Guid.NewGuid(); Guid artistId = Guid.NewGuid();
Guid albumId = Guid.NewGuid(); Guid albumId = Guid.NewGuid();
Guid trackId = Guid.NewGuid(); Guid trackId = Guid.NewGuid();
UpdateTrackRequest request = _updateTrackRequestFixture.Create(includeOptionalProperties: false, contributors: [], ratings: []); UpdateTrackRequest request = _updateTrackRequestFixture.Create(
includeDiscNumber: false,
includeScript: false,
includeKey: false,
includeBpm: false,
includeWork: false,
includeMusicBrainzRecordingId: false,
includeMusicBrainzTrackId: false,
includeMusicBrainzWorkId: false,
includeMoods: false,
includeIsrcs: false,
contributors: [],
ratings: []);
// Act // Act
UpdateTrackCommand result = request.ToCommand(libraryId.ToString(), artistId.ToString(), albumId.ToString(), trackId.ToString()); UpdateTrackCommand result = request.ToCommand(libraryId.ToString(), artistId.ToString(), albumId.ToString(), trackId.ToString());
@@ -103,7 +115,14 @@ public class UpdateTrackRequestMappingTests
isrcs: [new("GBUM71029604")], isrcs: [new("GBUM71029604")],
contributors: [new(Guid.NewGuid(), MediaContributorRole.Vocals)], contributors: [new(Guid.NewGuid(), MediaContributorRole.Vocals)],
ratings: [new(4.5m, 5m, AudioRatingSource.MusicBrainz, 1000)], ratings: [new(4.5m, 5m, AudioRatingSource.MusicBrainz, 1000)],
includeOptionalProperties: false); includeDiscNumber: false,
includeScript: false,
includeKey: false,
includeBpm: false,
includeWork: false,
includeMusicBrainzRecordingId: false,
includeMusicBrainzTrackId: false,
includeMusicBrainzWorkId: false);
// Act // Act
UpdateTrackCommand result = request.ToCommand(libraryId.ToString(), artistId.ToString(), albumId.ToString(), trackId.ToString()); UpdateTrackCommand result = request.ToCommand(libraryId.ToString(), artistId.ToString(), albumId.ToString(), trackId.ToString());
@@ -62,7 +62,18 @@ public class AddBookCommandMappingTests
isbns: [], isbns: [],
contributors: [], contributors: [],
ratings: [], ratings: [],
includeOptionalProperties: false); includeFormat: false,
includeEdition: false,
includeVolumeNumber: false,
includeAsin: false,
includeGoodreadsId: false,
includeLccn: false,
includeOclcNumber: false,
includeOpenLibraryId: false,
includeLibraryThingId: false,
includeGoogleBooksId: false,
includeBarnesAndNobleId: false,
includeAppleBooksId: false);
// Act // Act
Result<Book> result = command.ToDomainEntity(libraryId); Result<Book> result = command.ToDomainEntity(libraryId);
@@ -92,7 +103,7 @@ public class AddBookCommandMappingTests
public void ToDomainEntity_WhenRatingCreationFails_ShouldReturnError() public void ToDomainEntity_WhenRatingCreationFails_ShouldReturnError()
{ {
// Arrange // Arrange
AddBookCommand command = _commandBookFixture.Create(ratings: [_bookRatingDtoFixture.Create(value: -1, maxValue: 5, includeOptionalProperties: false)]); AddBookCommand command = _commandBookFixture.Create(ratings: [_bookRatingDtoFixture.Create(value: -1, maxValue: 5, includeSource: false, includeVoteCount: false)]);
// Act // Act
Result<Book> result = command.ToDomainEntity(Guid.NewGuid()); Result<Book> result = command.ToDomainEntity(Guid.NewGuid());
@@ -64,7 +64,21 @@ public class AddBookRequestMappingTests
AddBookRequest request = _requestFixture.Create( AddBookRequest request = _requestFixture.Create(
path: "/books/test.epub", path: "/books/test.epub",
metadata: _writtenContentMetadataDtoFixture.Create(title: "Test Book"), metadata: _writtenContentMetadataDtoFixture.Create(title: "Test Book"),
includeOptionalProperties: false includeFormat: false,
includeEdition: false,
includeVolumeNumber: false,
includeAsin: false,
includeGoodreadsId: false,
includeLccn: false,
includeOclcNumber: false,
includeOpenLibraryId: false,
includeLibraryThingId: false,
includeGoogleBooksId: false,
includeBarnesAndNobleId: false,
includeAppleBooksId: false,
includeIsbns: false,
includeRatings: false,
includeContributors: false
); );
// Act // Act
@@ -105,7 +119,18 @@ public class AddBookRequestMappingTests
_mediaContributorReferenceDtoFixture.Create(role: MediaContributorRole.Author) _mediaContributorReferenceDtoFixture.Create(role: MediaContributorRole.Author)
], ],
ratings: [new(4.5m, 5m, BookRatingSource.Goodreads, 1000)], ratings: [new(4.5m, 5m, BookRatingSource.Goodreads, 1000)],
includeOptionalProperties: false includeFormat: false,
includeEdition: false,
includeVolumeNumber: false,
includeAsin: false,
includeGoodreadsId: false,
includeLccn: false,
includeOclcNumber: false,
includeOpenLibraryId: false,
includeLibraryThingId: false,
includeGoogleBooksId: false,
includeBarnesAndNobleId: false,
includeAppleBooksId: false
); );
// Act // Act
@@ -24,6 +24,7 @@ public class BookMetadataDtoMappingTests
private readonly BookFixture _bookFixture = new(); private readonly BookFixture _bookFixture = new();
private readonly BookMetadataDtoFixture _bookMetadataDtoFixture = new(); private readonly BookMetadataDtoFixture _bookMetadataDtoFixture = new();
private readonly GenreDtoFixture _genreDtoFixture = new(); private readonly GenreDtoFixture _genreDtoFixture = new();
private readonly ReleaseInfoDtoFixture _releaseInfoDtoFixture = new();
[Fact] [Fact]
public void ApplyMetadata_WhenCalledWithValidMetadata_ShouldApplyItToTheBook() public void ApplyMetadata_WhenCalledWithValidMetadata_ShouldApplyItToTheBook()
@@ -76,7 +77,7 @@ public class BookMetadataDtoMappingTests
{ {
// Arrange // Arrange
Book book = _bookFixture.Create(); Book book = _bookFixture.Create();
BookMetadataDto metadata = _bookMetadataDtoFixture.Create(title: title, includeOptionalProperties: false); BookMetadataDto metadata = _bookMetadataDtoFixture.Create(includeTitle: title is not null, title: title, includeReleaseInfo: false, includeGenres: false, includeTags: false, includeLanguage: false, includeFormat: false, includeVolumeNumber: false);
// Act // Act
Result<Success> result = book.ApplyMetadata(metadata); Result<Success> result = book.ApplyMetadata(metadata);
@@ -91,7 +92,7 @@ public class BookMetadataDtoMappingTests
{ {
// Arrange // Arrange
Book book = _bookFixture.Create(); Book book = _bookFixture.Create();
BookMetadataDto metadata = _bookMetadataDtoFixture.Create(title: "A valid title", includeOptionalProperties: false); BookMetadataDto metadata = _bookMetadataDtoFixture.Create(title: "A valid title", includeReleaseInfo: false, includeGenres: false, includeTags: false, includeLanguage: false, includeFormat: false, includeVolumeNumber: false);
// Act // Act
Result<Success> result = book.ApplyMetadata(metadata); Result<Success> result = book.ApplyMetadata(metadata);
@@ -108,7 +109,7 @@ public class BookMetadataDtoMappingTests
Book book = _bookFixture.Create(); Book book = _bookFixture.Create();
BookMetadataDto metadata = _bookMetadataDtoFixture.Create( BookMetadataDto metadata = _bookMetadataDtoFixture.Create(
title: "A valid title", title: "A valid title",
releaseInfo: new ReleaseInfoDto(new DateOnly(2000, 1, 1), 1999, null, null, null, null)); releaseInfo: _releaseInfoDtoFixture.Create(originalReleaseDate: new DateOnly(2000, 1, 1), originalReleaseYear: 1999));
// Act // Act
Result<Success> result = book.ApplyMetadata(metadata); Result<Success> result = book.ApplyMetadata(metadata);
@@ -173,8 +174,12 @@ public class BookMetadataDtoMappingTests
Book book = _bookFixture.Create(); Book book = _bookFixture.Create();
BookMetadataDto metadata = _bookMetadataDtoFixture.Create( BookMetadataDto metadata = _bookMetadataDtoFixture.Create(
title: "A valid title", title: "A valid title",
releaseInfo: new ReleaseInfoDto(new DateOnly(2000, 1, 1), 2000, null, null, null, null), releaseInfo: _releaseInfoDtoFixture.Create(originalReleaseDate: new DateOnly(2000, 1, 1), originalReleaseYear: 2000),
includeOptionalProperties: false); includeGenres: false,
includeTags: false,
includeLanguage: false,
includeFormat: false,
includeVolumeNumber: false);
// Act // Act
Result<Success> result = book.ApplyMetadata(metadata); Result<Success> result = book.ApplyMetadata(metadata);
@@ -72,7 +72,18 @@ public class UpdateBookCommandMappingTests
isbns: [], isbns: [],
contributors: [], contributors: [],
ratings: [], ratings: [],
includeOptionalProperties: false); includeFormat: false,
includeEdition: false,
includeVolumeNumber: false,
includeAsin: false,
includeGoodreadsId: false,
includeLccn: false,
includeOclcNumber: false,
includeOpenLibraryId: false,
includeLibraryThingId: false,
includeGoogleBooksId: false,
includeBarnesAndNobleId: false,
includeAppleBooksId: false);
BookEntity existingBook = _bookEntityFixture.Create(id: bookId, libraryId: libraryId, path: "/books/the-book.epub"); BookEntity existingBook = _bookEntityFixture.Create(id: bookId, libraryId: libraryId, path: "/books/the-book.epub");
// Act // Act
@@ -104,7 +115,7 @@ public class UpdateBookCommandMappingTests
public void ToDomainEntity_WhenRatingCreationFails_ShouldReturnError() public void ToDomainEntity_WhenRatingCreationFails_ShouldReturnError()
{ {
// Arrange // Arrange
UpdateBookCommand command = _commandBookFixture.Create(ratings: [_bookRatingDtoFixture.Create(value: -1, maxValue: 5, includeOptionalProperties: false)]); UpdateBookCommand command = _commandBookFixture.Create(ratings: [_bookRatingDtoFixture.Create(value: -1, maxValue: 5, includeSource: false, includeVoteCount: false)]);
BookEntity existingBook = _bookEntityFixture.Create(); BookEntity existingBook = _bookEntityFixture.Create();
// Act // Act
@@ -61,7 +61,7 @@ public class UpdateBookRequestMappingTests
// Arrange // Arrange
Guid libraryId = Guid.NewGuid(); Guid libraryId = Guid.NewGuid();
Guid bookId = Guid.NewGuid(); Guid bookId = Guid.NewGuid();
UpdateBookRequest request = _requestFixture.Create(includeOptionalProperties: false); UpdateBookRequest request = _requestFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false);
// Act // Act
UpdateBookCommand result = request.ToCommand(libraryId.ToString(), bookId.ToString()); UpdateBookCommand result = request.ToCommand(libraryId.ToString(), bookId.ToString());
@@ -102,7 +102,18 @@ public class UpdateBookRequestMappingTests
_mediaContributorReferenceDtoFixture.Create(role: MediaContributorRole.Author) _mediaContributorReferenceDtoFixture.Create(role: MediaContributorRole.Author)
], ],
ratings: [new(4.5m, 5m, BookRatingSource.Goodreads, 1000)], ratings: [new(4.5m, 5m, BookRatingSource.Goodreads, 1000)],
includeOptionalProperties: false includeFormat: false,
includeEdition: false,
includeVolumeNumber: false,
includeAsin: false,
includeGoodreadsId: false,
includeLccn: false,
includeOclcNumber: false,
includeOpenLibraryId: false,
includeLibraryThingId: false,
includeGoogleBooksId: false,
includeBarnesAndNobleId: false,
includeAppleBooksId: false
); );
// Act // Act
@@ -119,7 +130,7 @@ public class UpdateBookRequestMappingTests
public void ToCommand_WhenRouteValuesAreNotParseable_ShouldMapThemAsIs() public void ToCommand_WhenRouteValuesAreNotParseable_ShouldMapThemAsIs()
{ {
// Arrange // Arrange
UpdateBookRequest request = _requestFixture.Create(includeOptionalProperties: false); UpdateBookRequest request = _requestFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false);
// Act // Act
UpdateBookCommand result = request.ToCommand("not-a-library-guid", "not-a-guid"); UpdateBookCommand result = request.ToCommand("not-a-library-guid", "not-a-guid");
@@ -56,7 +56,7 @@ public class BookRatingDtoMappingTests
public void ToDomainEntity_WhenMappingMinimalBookRatingDto_ShouldMapRequiredPropertiesCorrectly() public void ToDomainEntity_WhenMappingMinimalBookRatingDto_ShouldMapRequiredPropertiesCorrectly()
{ {
// Arrange // Arrange
BookRatingDto dto = _bookRatingDtoFixture.Create(includeOptionalProperties: false); BookRatingDto dto = _bookRatingDtoFixture.Create(includeSource: false, includeVoteCount: false);
// Act // Act
Result<BookRating> result = dto.ToDomainEntity(); Result<BookRating> result = dto.ToDomainEntity();
@@ -90,7 +90,7 @@ public class BookRatingDtoMappingTests
List<BookRatingDto> dtos = List<BookRatingDto> dtos =
[ [
_bookRatingDtoFixture.Create(), _bookRatingDtoFixture.Create(),
_bookRatingDtoFixture.Create(includeOptionalProperties: false) _bookRatingDtoFixture.Create(includeSource: false, includeVoteCount: false)
]; ];
// Act // Act
@@ -125,7 +125,7 @@ public class BookRatingDtoMappingTests
[ [
_bookRatingDtoFixture.Create(), _bookRatingDtoFixture.Create(),
_bookRatingDtoFixture.Create(value: 10, maxValue: 5), _bookRatingDtoFixture.Create(value: 10, maxValue: 5),
_bookRatingDtoFixture.Create(includeOptionalProperties: false) _bookRatingDtoFixture.Create(includeSource: false, includeVoteCount: false)
]; ];
// Act // Act
@@ -419,7 +419,7 @@ public class AddTrackCommandValidatorTests
public void Validate_WhenOriginalReleaseYearIsLessThan1_ShouldHaveValidationError() public void Validate_WhenOriginalReleaseYearIsLessThan1_ShouldHaveValidationError()
{ {
// Arrange // Arrange
AddTrackCommand command = _addTrackCommandFixture.Create(metadata: _audioMetadataDtoFixture.Create(releaseInfo: new ReleaseInfoDto(null, 0, null, null, null, null))); AddTrackCommand command = _addTrackCommandFixture.Create(metadata: _audioMetadataDtoFixture.Create(releaseInfo: _releaseInfoDtoFixture.Create(originalReleaseYear: 0)));
// Act // Act
List<Error> result = _validator.TestValidate(command); List<Error> result = _validator.TestValidate(command);
@@ -432,7 +432,7 @@ public class AddTrackCommandValidatorTests
public void Validate_WhenOriginalReleaseYearIsGreaterThan9999_ShouldHaveValidationError() public void Validate_WhenOriginalReleaseYearIsGreaterThan9999_ShouldHaveValidationError()
{ {
// Arrange // Arrange
AddTrackCommand command = _addTrackCommandFixture.Create(metadata: _audioMetadataDtoFixture.Create(releaseInfo: new ReleaseInfoDto(null, 10000, null, null, null, null))); AddTrackCommand command = _addTrackCommandFixture.Create(metadata: _audioMetadataDtoFixture.Create(releaseInfo: _releaseInfoDtoFixture.Create(originalReleaseYear: 10000)));
// Act // Act
List<Error> result = _validator.TestValidate(command); List<Error> result = _validator.TestValidate(command);
@@ -458,7 +458,7 @@ public class AddTrackCommandValidatorTests
public void Validate_WhenReReleaseYearIsLessThan1_ShouldHaveValidationError() public void Validate_WhenReReleaseYearIsLessThan1_ShouldHaveValidationError()
{ {
// Arrange // Arrange
AddTrackCommand command = _addTrackCommandFixture.Create(metadata: _audioMetadataDtoFixture.Create(releaseInfo: new ReleaseInfoDto(null, null, null, 0, null, null))); AddTrackCommand command = _addTrackCommandFixture.Create(metadata: _audioMetadataDtoFixture.Create(releaseInfo: _releaseInfoDtoFixture.Create(reReleaseYear: 0)));
// Act // Act
List<Error> result = _validator.TestValidate(command); List<Error> result = _validator.TestValidate(command);
@@ -471,7 +471,7 @@ public class AddTrackCommandValidatorTests
public void Validate_WhenReReleaseYearIsGreaterThan9999_ShouldHaveValidationError() public void Validate_WhenReReleaseYearIsGreaterThan9999_ShouldHaveValidationError()
{ {
// Arrange // Arrange
AddTrackCommand command = _addTrackCommandFixture.Create(metadata: _audioMetadataDtoFixture.Create(releaseInfo: new ReleaseInfoDto(null, null, null, 10000, null, null))); AddTrackCommand command = _addTrackCommandFixture.Create(metadata: _audioMetadataDtoFixture.Create(releaseInfo: _releaseInfoDtoFixture.Create(reReleaseYear: 10000)));
// Act // Act
List<Error> result = _validator.TestValidate(command); List<Error> result = _validator.TestValidate(command);
@@ -943,7 +943,7 @@ public class AddTrackCommandValidatorTests
public void Validate_WhenMusicBrainzRecordingIdIsNull_ShouldNotHaveValidationError() public void Validate_WhenMusicBrainzRecordingIdIsNull_ShouldNotHaveValidationError()
{ {
// Arrange // Arrange
AddTrackCommand command = _addTrackCommandFixture.Create(includeOptionalProperties: false); AddTrackCommand command = _addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false);
// Act // Act
List<Error> result = _validator.TestValidate(command); List<Error> result = _validator.TestValidate(command);
@@ -1054,7 +1054,7 @@ public class AddTrackCommandValidatorTests
public void Validate_WhenDiscNumberIsNull_ShouldNotHaveValidationError() public void Validate_WhenDiscNumberIsNull_ShouldNotHaveValidationError()
{ {
// Arrange // Arrange
AddTrackCommand command = _addTrackCommandFixture.Create(includeOptionalProperties: false); AddTrackCommand command = _addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false);
// Act // Act
List<Error> result = _validator.TestValidate(command); List<Error> result = _validator.TestValidate(command);
@@ -1093,7 +1093,7 @@ public class AddTrackCommandValidatorTests
public void Validate_WhenScriptIsNull_ShouldNotHaveValidationError() public void Validate_WhenScriptIsNull_ShouldNotHaveValidationError()
{ {
// Arrange // Arrange
AddTrackCommand command = _addTrackCommandFixture.Create(includeOptionalProperties: false); AddTrackCommand command = _addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false);
// Act // Act
List<Error> result = _validator.TestValidate(command); List<Error> result = _validator.TestValidate(command);
@@ -1132,7 +1132,7 @@ public class AddTrackCommandValidatorTests
public void Validate_WhenKeyIsNull_ShouldNotHaveValidationError() public void Validate_WhenKeyIsNull_ShouldNotHaveValidationError()
{ {
// Arrange // Arrange
AddTrackCommand command = _addTrackCommandFixture.Create(includeOptionalProperties: false); AddTrackCommand command = _addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false);
// Act // Act
List<Error> result = _validator.TestValidate(command); List<Error> result = _validator.TestValidate(command);
@@ -1173,7 +1173,7 @@ public class AddTrackCommandValidatorTests
public void Validate_WhenBpmIsNull_ShouldNotHaveValidationError() public void Validate_WhenBpmIsNull_ShouldNotHaveValidationError()
{ {
// Arrange // Arrange
AddTrackCommand command = _addTrackCommandFixture.Create(includeOptionalProperties: false); AddTrackCommand command = _addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false);
// Act // Act
List<Error> result = _validator.TestValidate(command); List<Error> result = _validator.TestValidate(command);
@@ -1212,7 +1212,7 @@ public class AddTrackCommandValidatorTests
public void Validate_WhenWorkIsNull_ShouldNotHaveValidationError() public void Validate_WhenWorkIsNull_ShouldNotHaveValidationError()
{ {
// Arrange // Arrange
AddTrackCommand command = _addTrackCommandFixture.Create(includeOptionalProperties: false); AddTrackCommand command = _addTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false);
// Act // Act
List<Error> result = _validator.TestValidate(command); List<Error> result = _validator.TestValidate(command);
@@ -1175,7 +1175,7 @@ public class UpdateTrackCommandValidatorTests
public void Validate_WhenMusicBrainzRecordingIdIsNull_ShouldNotHaveValidationError() public void Validate_WhenMusicBrainzRecordingIdIsNull_ShouldNotHaveValidationError()
{ {
// Arrange // Arrange
UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeOptionalProperties: false); UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false);
// Act // Act
List<Error> result = _validator.TestValidate(command); List<Error> result = _validator.TestValidate(command);
@@ -1214,7 +1214,7 @@ public class UpdateTrackCommandValidatorTests
public void Validate_WhenMusicBrainzTrackIdIsNull_ShouldNotHaveValidationError() public void Validate_WhenMusicBrainzTrackIdIsNull_ShouldNotHaveValidationError()
{ {
// Arrange // Arrange
UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeOptionalProperties: false); UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false);
// Act // Act
List<Error> result = _validator.TestValidate(command); List<Error> result = _validator.TestValidate(command);
@@ -1253,7 +1253,7 @@ public class UpdateTrackCommandValidatorTests
public void Validate_WhenMusicBrainzWorkIdIsNull_ShouldNotHaveValidationError() public void Validate_WhenMusicBrainzWorkIdIsNull_ShouldNotHaveValidationError()
{ {
// Arrange // Arrange
UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeOptionalProperties: false); UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false);
// Act // Act
List<Error> result = _validator.TestValidate(command); List<Error> result = _validator.TestValidate(command);
@@ -1357,7 +1357,7 @@ public class UpdateTrackCommandValidatorTests
public void Validate_WhenDiscNumberIsNull_ShouldNotHaveValidationError() public void Validate_WhenDiscNumberIsNull_ShouldNotHaveValidationError()
{ {
// Arrange // Arrange
UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeOptionalProperties: false); UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false);
// Act // Act
List<Error> result = _validator.TestValidate(command); List<Error> result = _validator.TestValidate(command);
@@ -1396,7 +1396,7 @@ public class UpdateTrackCommandValidatorTests
public void Validate_WhenScriptIsNull_ShouldNotHaveValidationError() public void Validate_WhenScriptIsNull_ShouldNotHaveValidationError()
{ {
// Arrange // Arrange
UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeOptionalProperties: false); UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false);
// Act // Act
List<Error> result = _validator.TestValidate(command); List<Error> result = _validator.TestValidate(command);
@@ -1435,7 +1435,7 @@ public class UpdateTrackCommandValidatorTests
public void Validate_WhenKeyIsNull_ShouldNotHaveValidationError() public void Validate_WhenKeyIsNull_ShouldNotHaveValidationError()
{ {
// Arrange // Arrange
UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeOptionalProperties: false); UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false);
// Act // Act
List<Error> result = _validator.TestValidate(command); List<Error> result = _validator.TestValidate(command);
@@ -1487,7 +1487,7 @@ public class UpdateTrackCommandValidatorTests
public void Validate_WhenBpmIsNull_ShouldNotHaveValidationError() public void Validate_WhenBpmIsNull_ShouldNotHaveValidationError()
{ {
// Arrange // Arrange
UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeOptionalProperties: false); UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false);
// Act // Act
List<Error> result = _validator.TestValidate(command); List<Error> result = _validator.TestValidate(command);
@@ -1526,7 +1526,7 @@ public class UpdateTrackCommandValidatorTests
public void Validate_WhenWorkIsNull_ShouldNotHaveValidationError() public void Validate_WhenWorkIsNull_ShouldNotHaveValidationError()
{ {
// Arrange // Arrange
UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeOptionalProperties: false); UpdateTrackCommand command = _updateTrackCommandFixture.Create(includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMusicBrainzWorkId: false, includeMoods: false, includeIsrcs: false);
// Act // Act
List<Error> result = _validator.TestValidate(command); List<Error> result = _validator.TestValidate(command);
@@ -226,7 +226,7 @@ public class AddBookCommandHandlerTests
public async Task HandleAsync_WhenCalledWithInvalidRating_ShouldReturnFailureResult() public async Task HandleAsync_WhenCalledWithInvalidRating_ShouldReturnFailureResult()
{ {
// Arrange // Arrange
AddBookCommand bookCommand = _commandBookFixture.Create(ratings: [_bookRatingDtoFixture.Create(value: -1, maxValue: 5, includeOptionalProperties: false)]); AddBookCommand bookCommand = _commandBookFixture.Create(ratings: [_bookRatingDtoFixture.Create(value: -1, maxValue: 5, includeSource: false, includeVoteCount: false)]);
// Act // Act
Result<BookResponse> result = await _sut.HandleAsync(bookCommand, CancellationToken.None); Result<BookResponse> result = await _sut.HandleAsync(bookCommand, CancellationToken.None);
@@ -210,7 +210,7 @@ public class AddBookCommandValidatorTests
public void Validate_WhenOriginalReleaseYearIsLessThan1_ShouldHaveValidationError() public void Validate_WhenOriginalReleaseYearIsLessThan1_ShouldHaveValidationError()
{ {
// Arrange // Arrange
AddBookCommand bookCommand = _commandBookFixture.Create(metadata: _writtenContentMetadataDtoFixture.Create(releaseInfo: new ReleaseInfoDto(null, 0, null, null, null, null))); AddBookCommand bookCommand = _commandBookFixture.Create(metadata: _writtenContentMetadataDtoFixture.Create(releaseInfo: _releaseInfoDtoFixture.Create(originalReleaseYear: 0)));
// Act // Act
List<Error> result = _validator.TestValidate(bookCommand); List<Error> result = _validator.TestValidate(bookCommand);
@@ -223,7 +223,7 @@ public class AddBookCommandValidatorTests
public void Validate_WhenOriginalReleaseYearIsGreaterThan9999_ShouldHaveValidationError() public void Validate_WhenOriginalReleaseYearIsGreaterThan9999_ShouldHaveValidationError()
{ {
// Arrange // Arrange
AddBookCommand bookCommand = _commandBookFixture.Create(metadata: _writtenContentMetadataDtoFixture.Create(releaseInfo: new ReleaseInfoDto(null, 10000, null, null, null, null))); AddBookCommand bookCommand = _commandBookFixture.Create(metadata: _writtenContentMetadataDtoFixture.Create(releaseInfo: _releaseInfoDtoFixture.Create(originalReleaseYear: 10000)));
// Act // Act
List<Error> result = _validator.TestValidate(bookCommand); List<Error> result = _validator.TestValidate(bookCommand);
@@ -249,7 +249,7 @@ public class AddBookCommandValidatorTests
public void Validate_WhenReReleaseYearIsLessThan1_ShouldHaveValidationError() public void Validate_WhenReReleaseYearIsLessThan1_ShouldHaveValidationError()
{ {
// Arrange // Arrange
AddBookCommand bookCommand = _commandBookFixture.Create(metadata: _writtenContentMetadataDtoFixture.Create(releaseInfo: new ReleaseInfoDto(null, null, null, 0, null, null))); AddBookCommand bookCommand = _commandBookFixture.Create(metadata: _writtenContentMetadataDtoFixture.Create(releaseInfo: _releaseInfoDtoFixture.Create(reReleaseYear: 0)));
// Act // Act
List<Error> result = _validator.TestValidate(bookCommand); List<Error> result = _validator.TestValidate(bookCommand);
@@ -262,7 +262,7 @@ public class AddBookCommandValidatorTests
public void Validate_WhenReReleaseYearIsGreaterThan9999_ShouldHaveValidationError() public void Validate_WhenReReleaseYearIsGreaterThan9999_ShouldHaveValidationError()
{ {
// Arrange // Arrange
AddBookCommand bookCommand = _commandBookFixture.Create(metadata: _writtenContentMetadataDtoFixture.Create(releaseInfo: new ReleaseInfoDto(null, null, null, 10000, null, null))); AddBookCommand bookCommand = _commandBookFixture.Create(metadata: _writtenContentMetadataDtoFixture.Create(releaseInfo: _releaseInfoDtoFixture.Create(reReleaseYear: 10000)));
// Act // Act
List<Error> result = _validator.TestValidate(bookCommand); List<Error> result = _validator.TestValidate(bookCommand);
@@ -756,7 +756,7 @@ public class AddBookCommandValidatorTests
public void Validate_WhenFormatIsNull_ShouldNotHaveValidationError() public void Validate_WhenFormatIsNull_ShouldNotHaveValidationError()
{ {
// Arrange // Arrange
AddBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); AddBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false);
// Act // Act
List<Error> result = _validator.TestValidate(bookCommand); List<Error> result = _validator.TestValidate(bookCommand);
@@ -795,7 +795,7 @@ public class AddBookCommandValidatorTests
public void Validate_WhenEditionIsNull_ShouldNotHaveValidationError() public void Validate_WhenEditionIsNull_ShouldNotHaveValidationError()
{ {
// Arrange // Arrange
AddBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); AddBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false);
// Act // Act
List<Error> result = _validator.TestValidate(bookCommand); List<Error> result = _validator.TestValidate(bookCommand);
@@ -834,7 +834,7 @@ public class AddBookCommandValidatorTests
public void Validate_WhenVolumeNumberIsNull_ShouldNotHaveValidationError() public void Validate_WhenVolumeNumberIsNull_ShouldNotHaveValidationError()
{ {
// Arrange // Arrange
AddBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); AddBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false);
// Act // Act
List<Error> result = _validator.TestValidate(bookCommand); List<Error> result = _validator.TestValidate(bookCommand);
@@ -954,7 +954,7 @@ public class AddBookCommandValidatorTests
public void Validate_WhenAsinIsNull_ShouldNotHaveValidationError() public void Validate_WhenAsinIsNull_ShouldNotHaveValidationError()
{ {
// Arrange // Arrange
AddBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); AddBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false);
// Act // Act
List<Error> result = _validator.TestValidate(bookCommand); List<Error> result = _validator.TestValidate(bookCommand);
@@ -980,7 +980,7 @@ public class AddBookCommandValidatorTests
public void Validate_WhenGoodreadsIdIsNull_ShouldNotHaveValidationError() public void Validate_WhenGoodreadsIdIsNull_ShouldNotHaveValidationError()
{ {
// Arrange // Arrange
AddBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); AddBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false);
// Act // Act
List<Error> result = _validator.TestValidate(bookCommand); List<Error> result = _validator.TestValidate(bookCommand);
@@ -1045,7 +1045,7 @@ public class AddBookCommandValidatorTests
public void Validate_WhenLccnIsNull_ShouldNotHaveValidationError() public void Validate_WhenLccnIsNull_ShouldNotHaveValidationError()
{ {
// Arrange // Arrange
AddBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); AddBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false);
// Act // Act
List<Error> result = _validator.TestValidate(bookCommand); List<Error> result = _validator.TestValidate(bookCommand);
@@ -1110,7 +1110,7 @@ public class AddBookCommandValidatorTests
public void Validate_WhenCalledWithEmptyOclcNumber_ShouldNotHaveValidationError() public void Validate_WhenCalledWithEmptyOclcNumber_ShouldNotHaveValidationError()
{ {
// Arrange // Arrange
AddBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); AddBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false);
// Act // Act
List<Error> result = _validator.TestValidate(bookCommand); List<Error> result = _validator.TestValidate(bookCommand);
@@ -1201,7 +1201,7 @@ public class AddBookCommandValidatorTests
public void Validate_WhenOpenLibraryIdIsNull_ShouldNotHaveValidationError() public void Validate_WhenOpenLibraryIdIsNull_ShouldNotHaveValidationError()
{ {
// Arrange // Arrange
AddBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); AddBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false);
// Act // Act
List<Error> result = _validator.TestValidate(bookCommand); List<Error> result = _validator.TestValidate(bookCommand);
@@ -1266,7 +1266,7 @@ public class AddBookCommandValidatorTests
public void Validate_WhenCalledWithEmptyLibraryThingId_ShouldNotHaveValidationError() public void Validate_WhenCalledWithEmptyLibraryThingId_ShouldNotHaveValidationError()
{ {
// Arrange // Arrange
AddBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); AddBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false);
// Act // Act
List<Error> result = _validator.TestValidate(bookCommand); List<Error> result = _validator.TestValidate(bookCommand);
@@ -1305,7 +1305,7 @@ public class AddBookCommandValidatorTests
public void Validate_WhenCalledWithEmptyGoogleBooksId_ShouldNotHaveValidationError() public void Validate_WhenCalledWithEmptyGoogleBooksId_ShouldNotHaveValidationError()
{ {
// Arrange // Arrange
AddBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); AddBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false);
// Act // Act
List<Error> result = _validator.TestValidate(bookCommand); List<Error> result = _validator.TestValidate(bookCommand);
@@ -1357,7 +1357,7 @@ public class AddBookCommandValidatorTests
public void Validate_WhenCalledWithEmptyBarnesAndNobleId_ShouldNotHaveValidationError() public void Validate_WhenCalledWithEmptyBarnesAndNobleId_ShouldNotHaveValidationError()
{ {
// Arrange // Arrange
AddBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); AddBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false);
// Act // Act
List<Error> result = _validator.TestValidate(bookCommand); List<Error> result = _validator.TestValidate(bookCommand);
@@ -1409,7 +1409,7 @@ public class AddBookCommandValidatorTests
public void Validate_WhenCalledWithEmptyAppleBooksId_ShouldNotHaveValidationError() public void Validate_WhenCalledWithEmptyAppleBooksId_ShouldNotHaveValidationError()
{ {
// Arrange // Arrange
AddBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); AddBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false);
// Act // Act
List<Error> result = _validator.TestValidate(bookCommand); List<Error> result = _validator.TestValidate(bookCommand);
@@ -1448,7 +1448,7 @@ public class AddBookCommandValidatorTests
public void Validate_WhenCalledWithNullIsbns_ShouldHaveValidationError() public void Validate_WhenCalledWithNullIsbns_ShouldHaveValidationError()
{ {
// Arrange // Arrange
AddBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); AddBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false);
// Act // Act
List<Error> result = _validator.TestValidate(bookCommand); List<Error> result = _validator.TestValidate(bookCommand);
@@ -1591,7 +1591,7 @@ public class AddBookCommandValidatorTests
public void Validate_WhenCalledWithNullRatings_ShouldHaveValidationError() public void Validate_WhenCalledWithNullRatings_ShouldHaveValidationError()
{ {
// Arrange // Arrange
AddBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); AddBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false);
// Act // Act
List<Error> result = _validator.TestValidate(bookCommand); List<Error> result = _validator.TestValidate(bookCommand);
@@ -1669,7 +1669,7 @@ public class AddBookCommandValidatorTests
public void Validate_WhenCalledWithNullVoteCount_ShouldNotHaveValidationError() public void Validate_WhenCalledWithNullVoteCount_ShouldNotHaveValidationError()
{ {
// Arrange // Arrange
AddBookCommand bookCommand = _commandBookFixture.Create(ratings: [_bookRatingDtoFixture.Create(includeOptionalProperties: false)]); AddBookCommand bookCommand = _commandBookFixture.Create(ratings: [_bookRatingDtoFixture.Create(includeSource: false, includeVoteCount: false)]);
// Act // Act
List<Error> result = _validator.TestValidate(bookCommand); List<Error> result = _validator.TestValidate(bookCommand);
@@ -343,7 +343,7 @@ public class UpdateBookCommandHandlerTests
public async Task HandleAsync_WhenCalledWithInvalidRating_ShouldReturnFailureResult() public async Task HandleAsync_WhenCalledWithInvalidRating_ShouldReturnFailureResult()
{ {
// Arrange // Arrange
UpdateBookCommand command = _commandBookFixture.Create(ratings: [_bookRatingDtoFixture.Create(value: -1, maxValue: 5, includeOptionalProperties: false)]); UpdateBookCommand command = _commandBookFixture.Create(ratings: [_bookRatingDtoFixture.Create(value: -1, maxValue: 5, includeSource: false, includeVoteCount: false)]);
BookEntity existingBook = _bookEntityFixture.Create(id: Guid.Parse(command.BookId!), libraryId: Guid.Parse(command.LibraryId!)); BookEntity existingBook = _bookEntityFixture.Create(id: Guid.Parse(command.BookId!), libraryId: Guid.Parse(command.LibraryId!));
_mockBookRepository.GetByIdAsync(Arg.Any<Guid>(), Arg.Any<bool>(), Arg.Any<bool>(), Arg.Any<CancellationToken>()) _mockBookRepository.GetByIdAsync(Arg.Any<Guid>(), Arg.Any<bool>(), Arg.Any<bool>(), Arg.Any<CancellationToken>())
.Returns(Result.From<BookEntity?>(existingBook)); .Returns(Result.From<BookEntity?>(existingBook));
@@ -197,7 +197,7 @@ public class UpdateBookCommandValidatorTests
public void Validate_WhenOriginalReleaseYearIsLessThan1_ShouldHaveValidationError() public void Validate_WhenOriginalReleaseYearIsLessThan1_ShouldHaveValidationError()
{ {
// Arrange // Arrange
UpdateBookCommand bookCommand = _commandBookFixture.Create(metadata: _writtenContentMetadataDtoFixture.Create(releaseInfo: new ReleaseInfoDto(null, 0, null, null, null, null))); UpdateBookCommand bookCommand = _commandBookFixture.Create(metadata: _writtenContentMetadataDtoFixture.Create(releaseInfo: _releaseInfoDtoFixture.Create(originalReleaseYear: 0)));
// Act // Act
List<Error> result = _validator.TestValidate(bookCommand); List<Error> result = _validator.TestValidate(bookCommand);
@@ -210,7 +210,7 @@ public class UpdateBookCommandValidatorTests
public void Validate_WhenOriginalReleaseYearIsGreaterThan9999_ShouldHaveValidationError() public void Validate_WhenOriginalReleaseYearIsGreaterThan9999_ShouldHaveValidationError()
{ {
// Arrange // Arrange
UpdateBookCommand bookCommand = _commandBookFixture.Create(metadata: _writtenContentMetadataDtoFixture.Create(releaseInfo: new ReleaseInfoDto(null, 10000, null, null, null, null))); UpdateBookCommand bookCommand = _commandBookFixture.Create(metadata: _writtenContentMetadataDtoFixture.Create(releaseInfo: _releaseInfoDtoFixture.Create(originalReleaseYear: 10000)));
// Act // Act
List<Error> result = _validator.TestValidate(bookCommand); List<Error> result = _validator.TestValidate(bookCommand);
@@ -236,7 +236,7 @@ public class UpdateBookCommandValidatorTests
public void Validate_WhenReReleaseYearIsLessThan1_ShouldHaveValidationError() public void Validate_WhenReReleaseYearIsLessThan1_ShouldHaveValidationError()
{ {
// Arrange // Arrange
UpdateBookCommand bookCommand = _commandBookFixture.Create(metadata: _writtenContentMetadataDtoFixture.Create(releaseInfo: new ReleaseInfoDto(null, null, null, 0, null, null))); UpdateBookCommand bookCommand = _commandBookFixture.Create(metadata: _writtenContentMetadataDtoFixture.Create(releaseInfo: _releaseInfoDtoFixture.Create(reReleaseYear: 0)));
// Act // Act
List<Error> result = _validator.TestValidate(bookCommand); List<Error> result = _validator.TestValidate(bookCommand);
@@ -249,7 +249,7 @@ public class UpdateBookCommandValidatorTests
public void Validate_WhenReReleaseYearIsGreaterThan9999_ShouldHaveValidationError() public void Validate_WhenReReleaseYearIsGreaterThan9999_ShouldHaveValidationError()
{ {
// Arrange // Arrange
UpdateBookCommand bookCommand = _commandBookFixture.Create(metadata: _writtenContentMetadataDtoFixture.Create(releaseInfo: new ReleaseInfoDto(null, null, null, 10000, null, null))); UpdateBookCommand bookCommand = _commandBookFixture.Create(metadata: _writtenContentMetadataDtoFixture.Create(releaseInfo: _releaseInfoDtoFixture.Create(reReleaseYear: 10000)));
// Act // Act
List<Error> result = _validator.TestValidate(bookCommand); List<Error> result = _validator.TestValidate(bookCommand);
@@ -743,7 +743,7 @@ public class UpdateBookCommandValidatorTests
public void Validate_WhenFormatIsNull_ShouldNotHaveValidationError() public void Validate_WhenFormatIsNull_ShouldNotHaveValidationError()
{ {
// Arrange // Arrange
UpdateBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); UpdateBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false);
// Act // Act
List<Error> result = _validator.TestValidate(bookCommand); List<Error> result = _validator.TestValidate(bookCommand);
@@ -782,7 +782,7 @@ public class UpdateBookCommandValidatorTests
public void Validate_WhenEditionIsNull_ShouldNotHaveValidationError() public void Validate_WhenEditionIsNull_ShouldNotHaveValidationError()
{ {
// Arrange // Arrange
UpdateBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); UpdateBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false);
// Act // Act
List<Error> result = _validator.TestValidate(bookCommand); List<Error> result = _validator.TestValidate(bookCommand);
@@ -821,7 +821,7 @@ public class UpdateBookCommandValidatorTests
public void Validate_WhenVolumeNumberIsNull_ShouldNotHaveValidationError() public void Validate_WhenVolumeNumberIsNull_ShouldNotHaveValidationError()
{ {
// Arrange // Arrange
UpdateBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); UpdateBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false);
// Act // Act
List<Error> result = _validator.TestValidate(bookCommand); List<Error> result = _validator.TestValidate(bookCommand);
@@ -941,7 +941,7 @@ public class UpdateBookCommandValidatorTests
public void Validate_WhenAsinIsNull_ShouldNotHaveValidationError() public void Validate_WhenAsinIsNull_ShouldNotHaveValidationError()
{ {
// Arrange // Arrange
UpdateBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); UpdateBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false);
// Act // Act
List<Error> result = _validator.TestValidate(bookCommand); List<Error> result = _validator.TestValidate(bookCommand);
@@ -967,7 +967,7 @@ public class UpdateBookCommandValidatorTests
public void Validate_WhenGoodreadsIdIsNull_ShouldNotHaveValidationError() public void Validate_WhenGoodreadsIdIsNull_ShouldNotHaveValidationError()
{ {
// Arrange // Arrange
UpdateBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); UpdateBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false);
// Act // Act
List<Error> result = _validator.TestValidate(bookCommand); List<Error> result = _validator.TestValidate(bookCommand);
@@ -1032,7 +1032,7 @@ public class UpdateBookCommandValidatorTests
public void Validate_WhenLccnIsNull_ShouldNotHaveValidationError() public void Validate_WhenLccnIsNull_ShouldNotHaveValidationError()
{ {
// Arrange // Arrange
UpdateBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); UpdateBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false);
// Act // Act
List<Error> result = _validator.TestValidate(bookCommand); List<Error> result = _validator.TestValidate(bookCommand);
@@ -1097,7 +1097,7 @@ public class UpdateBookCommandValidatorTests
public void Validate_WhenCalledWithEmptyOclcNumber_ShouldNotHaveValidationError() public void Validate_WhenCalledWithEmptyOclcNumber_ShouldNotHaveValidationError()
{ {
// Arrange // Arrange
UpdateBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); UpdateBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false);
// Act // Act
List<Error> result = _validator.TestValidate(bookCommand); List<Error> result = _validator.TestValidate(bookCommand);
@@ -1188,7 +1188,7 @@ public class UpdateBookCommandValidatorTests
public void Validate_WhenOpenLibraryIdIsNull_ShouldNotHaveValidationError() public void Validate_WhenOpenLibraryIdIsNull_ShouldNotHaveValidationError()
{ {
// Arrange // Arrange
UpdateBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); UpdateBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false);
// Act // Act
List<Error> result = _validator.TestValidate(bookCommand); List<Error> result = _validator.TestValidate(bookCommand);
@@ -1253,7 +1253,7 @@ public class UpdateBookCommandValidatorTests
public void Validate_WhenCalledWithEmptyLibraryThingId_ShouldNotHaveValidationError() public void Validate_WhenCalledWithEmptyLibraryThingId_ShouldNotHaveValidationError()
{ {
// Arrange // Arrange
UpdateBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); UpdateBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false);
// Act // Act
List<Error> result = _validator.TestValidate(bookCommand); List<Error> result = _validator.TestValidate(bookCommand);
@@ -1292,7 +1292,7 @@ public class UpdateBookCommandValidatorTests
public void Validate_WhenCalledWithEmptyGoogleBooksId_ShouldNotHaveValidationError() public void Validate_WhenCalledWithEmptyGoogleBooksId_ShouldNotHaveValidationError()
{ {
// Arrange // Arrange
UpdateBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); UpdateBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false);
// Act // Act
List<Error> result = _validator.TestValidate(bookCommand); List<Error> result = _validator.TestValidate(bookCommand);
@@ -1344,7 +1344,7 @@ public class UpdateBookCommandValidatorTests
public void Validate_WhenCalledWithEmptyBarnesAndNobleId_ShouldNotHaveValidationError() public void Validate_WhenCalledWithEmptyBarnesAndNobleId_ShouldNotHaveValidationError()
{ {
// Arrange // Arrange
UpdateBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); UpdateBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false);
// Act // Act
List<Error> result = _validator.TestValidate(bookCommand); List<Error> result = _validator.TestValidate(bookCommand);
@@ -1396,7 +1396,7 @@ public class UpdateBookCommandValidatorTests
public void Validate_WhenCalledWithEmptyAppleBooksId_ShouldNotHaveValidationError() public void Validate_WhenCalledWithEmptyAppleBooksId_ShouldNotHaveValidationError()
{ {
// Arrange // Arrange
UpdateBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); UpdateBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false);
// Act // Act
List<Error> result = _validator.TestValidate(bookCommand); List<Error> result = _validator.TestValidate(bookCommand);
@@ -1435,7 +1435,7 @@ public class UpdateBookCommandValidatorTests
public void Validate_WhenCalledWithNullIsbns_ShouldHaveValidationError() public void Validate_WhenCalledWithNullIsbns_ShouldHaveValidationError()
{ {
// Arrange // Arrange
UpdateBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); UpdateBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false);
// Act // Act
List<Error> result = _validator.TestValidate(bookCommand); List<Error> result = _validator.TestValidate(bookCommand);
@@ -1578,7 +1578,7 @@ public class UpdateBookCommandValidatorTests
public void Validate_WhenCalledWithNullRatings_ShouldHaveValidationError() public void Validate_WhenCalledWithNullRatings_ShouldHaveValidationError()
{ {
// Arrange // Arrange
UpdateBookCommand bookCommand = _commandBookFixture.Create(includeOptionalProperties: false); UpdateBookCommand bookCommand = _commandBookFixture.Create(includeFormat: false, includeEdition: false, includeVolumeNumber: false, includeAsin: false, includeGoodreadsId: false, includeLccn: false, includeOclcNumber: false, includeOpenLibraryId: false, includeLibraryThingId: false, includeGoogleBooksId: false, includeBarnesAndNobleId: false, includeAppleBooksId: false, includeIsbns: false, includeRatings: false, includeContributors: false);
// Act // Act
List<Error> result = _validator.TestValidate(bookCommand); List<Error> result = _validator.TestValidate(bookCommand);
@@ -1656,7 +1656,7 @@ public class UpdateBookCommandValidatorTests
public void Validate_WhenCalledWithNullVoteCount_ShouldNotHaveValidationError() public void Validate_WhenCalledWithNullVoteCount_ShouldNotHaveValidationError()
{ {
// Arrange // Arrange
UpdateBookCommand bookCommand = _commandBookFixture.Create(ratings: [_bookRatingDtoFixture.Create(includeOptionalProperties: false)]); UpdateBookCommand bookCommand = _commandBookFixture.Create(ratings: [_bookRatingDtoFixture.Create(includeSource: false, includeVoteCount: false)]);
// Act // Act
List<Error> result = _validator.TestValidate(bookCommand); List<Error> result = _validator.TestValidate(bookCommand);
@@ -20,7 +20,7 @@ public class BookRatingDtoTests
public void Create_WhenOmittingOptionalProperties_ShouldReturnNullSourceAndVoteCount() public void Create_WhenOmittingOptionalProperties_ShouldReturnNullSourceAndVoteCount()
{ {
// Act // Act
BookRatingDto sut = _bookRatingDtoFixture.Create(includeOptionalProperties: false); BookRatingDto sut = _bookRatingDtoFixture.Create(includeSource: false, includeVoteCount: false);
// Assert // Assert
Assert.Null(sut.Source); Assert.Null(sut.Source);
@@ -32,7 +32,11 @@ public class MetadataAggregatorTests
public void Merge_WhenBothMetadataHaveScalarValues_ShouldKeepTheFirstValues() public void Merge_WhenBothMetadataHaveScalarValues_ShouldKeepTheFirstValues()
{ {
// Arrange // Arrange
BookMetadataDto first = _bookMetadataDtoFixture.Create(includeOptionalProperties: false, BookMetadataDto first = _bookMetadataDtoFixture.Create(
includeReleaseInfo: false,
includeGenres: false,
includeTags: false,
includeLanguage: false,
title: "First Title", title: "First Title",
originalTitle: "First Original Title", originalTitle: "First Original Title",
description: "First Description", description: "First Description",
@@ -51,7 +55,11 @@ public class MetadataAggregatorTests
barnesAndNobleId: "FIRST-BN", barnesAndNobleId: "FIRST-BN",
appleBooksId: "FIRST-APPLE", appleBooksId: "FIRST-APPLE",
coverImagePath: "First Cover"); coverImagePath: "First Cover");
BookMetadataDto second = _bookMetadataDtoFixture.Create(includeOptionalProperties: false, BookMetadataDto second = _bookMetadataDtoFixture.Create(
includeReleaseInfo: false,
includeGenres: false,
includeTags: false,
includeLanguage: false,
title: "Second Title", title: "Second Title",
originalTitle: "Second Original Title", originalTitle: "Second Original Title",
description: "Second Description", description: "Second Description",
@@ -99,8 +107,29 @@ public class MetadataAggregatorTests
public void Merge_WhenFirstHasNullScalars_ShouldFallBackToTheSecondValues() public void Merge_WhenFirstHasNullScalars_ShouldFallBackToTheSecondValues()
{ {
// Arrange // Arrange
BookMetadataDto first = _bookMetadataDtoFixture.Create(includeOptionalProperties: false, title: null, description: null, publisher: null, pageCount: null); BookMetadataDto first = _bookMetadataDtoFixture.Create(
BookMetadataDto second = _bookMetadataDtoFixture.Create(includeOptionalProperties: false, title: "Second Title", description: "Second Description", publisher: "Second Publisher", pageCount: 200); includeTitle: false,
includeReleaseInfo: false,
includeGenres: false,
includeTags: false,
includeLanguage: false,
includeFormat: false,
includeVolumeNumber: false,
title: null,
description: null,
publisher: null,
pageCount: null);
BookMetadataDto second = _bookMetadataDtoFixture.Create(
includeReleaseInfo: false,
includeGenres: false,
includeTags: false,
includeLanguage: false,
includeFormat: false,
includeVolumeNumber: false,
title: "Second Title",
description: "Second Description",
publisher: "Second Publisher",
pageCount: 200);
// Act // Act
BookMetadataDto result = MetadataAggregator.Merge(first, second); BookMetadataDto result = MetadataAggregator.Merge(first, second);
@@ -116,8 +145,26 @@ public class MetadataAggregatorTests
public void Merge_WhenBothHaveNullScalars_ShouldReturnNullScalars() public void Merge_WhenBothHaveNullScalars_ShouldReturnNullScalars()
{ {
// Arrange // Arrange
BookMetadataDto first = _bookMetadataDtoFixture.Create(includeOptionalProperties: false, title: null, coverImagePath: null); BookMetadataDto first = _bookMetadataDtoFixture.Create(
BookMetadataDto second = _bookMetadataDtoFixture.Create(includeOptionalProperties: false, title: null, coverImagePath: null); includeTitle: false,
includeReleaseInfo: false,
includeGenres: false,
includeTags: false,
includeLanguage: false,
includeFormat: false,
includeVolumeNumber: false,
title: null,
coverImagePath: null);
BookMetadataDto second = _bookMetadataDtoFixture.Create(
includeTitle: false,
includeReleaseInfo: false,
includeGenres: false,
includeTags: false,
includeLanguage: false,
includeFormat: false,
includeVolumeNumber: false,
title: null,
coverImagePath: null);
// Act // Act
BookMetadataDto result = MetadataAggregator.Merge(first, second); BookMetadataDto result = MetadataAggregator.Merge(first, second);
@@ -137,10 +184,24 @@ public class MetadataAggregatorTests
public void Merge_WhenBothHaveReleaseInfo_ShouldCoalesceEachField() public void Merge_WhenBothHaveReleaseInfo_ShouldCoalesceEachField()
{ {
// Arrange // Arrange
BookMetadataDto first = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false); BookMetadataDto first = _bookMetadataDtoFixture.Create(
BookMetadataDto second = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false); includeGenres: false,
first = first with { ReleaseInfo = _releaseInfoDtoFixture.Create(originalReleaseDate: new DateOnly(2001, 1, 1), originalReleaseYear: 2001, releaseCountry: ReleaseCountry.US) }; includeTags: false,
second = second with { ReleaseInfo = _releaseInfoDtoFixture.Create(reReleaseDate: new DateOnly(2010, 5, 5), reReleaseYear: 2010, releaseCountry: ReleaseCountry.GB, releaseVersion: "2.0") }; includeLanguage: false,
includeFormat: false,
includeVolumeNumber: false,
title: "Title",
coverImagePath: "First Cover",
releaseInfo: _releaseInfoDtoFixture.Create(originalReleaseDate: new DateOnly(2001, 1, 1), originalReleaseYear: 2001, releaseCountry: ReleaseCountry.US));
BookMetadataDto second = _bookMetadataDtoFixture.Create(
includeGenres: false,
includeTags: false,
includeLanguage: false,
includeFormat: false,
includeVolumeNumber: false,
title: "Title",
coverImagePath: "First Cover",
releaseInfo: _releaseInfoDtoFixture.Create(reReleaseDate: new DateOnly(2010, 5, 5), reReleaseYear: 2010, releaseCountry: ReleaseCountry.GB, releaseVersion: "2.0"));
// Act // Act
BookMetadataDto result = MetadataAggregator.Merge(first, second); BookMetadataDto result = MetadataAggregator.Merge(first, second);
@@ -158,8 +219,24 @@ public class MetadataAggregatorTests
public void Merge_WhenFirstReleaseInfoIsNull_ShouldUseTheSecondReleaseInfo() public void Merge_WhenFirstReleaseInfoIsNull_ShouldUseTheSecondReleaseInfo()
{ {
// Arrange // Arrange
BookMetadataDto first = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { ReleaseInfo = null }; BookMetadataDto first = _bookMetadataDtoFixture.Create(
BookMetadataDto second = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { ReleaseInfo = _releaseInfoDtoFixture.Create(originalReleaseDate: new DateOnly(2001, 1, 1), originalReleaseYear: 2001) }; includeReleaseInfo: false,
includeGenres: false,
includeTags: false,
includeLanguage: false,
includeFormat: false,
includeVolumeNumber: false,
title: "Title",
coverImagePath: "First Cover");
BookMetadataDto second = _bookMetadataDtoFixture.Create(
includeGenres: false,
includeTags: false,
includeLanguage: false,
includeFormat: false,
includeVolumeNumber: false,
title: "Title",
coverImagePath: "First Cover",
releaseInfo: _releaseInfoDtoFixture.Create(originalReleaseDate: new DateOnly(2001, 1, 1), originalReleaseYear: 2001));
// Act // Act
BookMetadataDto result = MetadataAggregator.Merge(first, second); BookMetadataDto result = MetadataAggregator.Merge(first, second);
@@ -172,8 +249,24 @@ public class MetadataAggregatorTests
public void Merge_WhenBothReleaseInfosAreNull_ShouldReturnNullReleaseInfo() public void Merge_WhenBothReleaseInfosAreNull_ShouldReturnNullReleaseInfo()
{ {
// Arrange // Arrange
BookMetadataDto first = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { ReleaseInfo = null }; BookMetadataDto first = _bookMetadataDtoFixture.Create(
BookMetadataDto second = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { ReleaseInfo = null }; includeReleaseInfo: false,
includeGenres: false,
includeTags: false,
includeLanguage: false,
includeFormat: false,
includeVolumeNumber: false,
title: "Title",
coverImagePath: "First Cover");
BookMetadataDto second = _bookMetadataDtoFixture.Create(
includeReleaseInfo: false,
includeGenres: false,
includeTags: false,
includeLanguage: false,
includeFormat: false,
includeVolumeNumber: false,
title: "Title",
coverImagePath: "First Cover");
// Act // Act
BookMetadataDto result = MetadataAggregator.Merge(first, second); BookMetadataDto result = MetadataAggregator.Merge(first, second);
@@ -186,8 +279,24 @@ public class MetadataAggregatorTests
public void Merge_WhenBothHaveGenres_ShouldUnionAndDeDuplicateByName() public void Merge_WhenBothHaveGenres_ShouldUnionAndDeDuplicateByName()
{ {
// Arrange // Arrange
BookMetadataDto first = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Genres = [_genreDtoFixture.Create(name: "Science fiction"), _genreDtoFixture.Create(name: "Space opera")] }; BookMetadataDto first = _bookMetadataDtoFixture.Create(
BookMetadataDto second = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Genres = [_genreDtoFixture.Create(name: "Science fiction"), _genreDtoFixture.Create(name: "Fantasy")] }; includeReleaseInfo: false,
includeTags: false,
includeLanguage: false,
includeFormat: false,
includeVolumeNumber: false,
title: "Title",
coverImagePath: "First Cover",
genres: [_genreDtoFixture.Create(name: "Science fiction"), _genreDtoFixture.Create(name: "Space opera")]);
BookMetadataDto second = _bookMetadataDtoFixture.Create(
includeReleaseInfo: false,
includeTags: false,
includeLanguage: false,
includeFormat: false,
includeVolumeNumber: false,
title: "Title",
coverImagePath: "First Cover",
genres: [_genreDtoFixture.Create(name: "Science fiction"), _genreDtoFixture.Create(name: "Fantasy")]);
// Act // Act
BookMetadataDto result = MetadataAggregator.Merge(first, second); BookMetadataDto result = MetadataAggregator.Merge(first, second);
@@ -203,8 +312,24 @@ public class MetadataAggregatorTests
public void Merge_WhenBothHaveTags_ShouldUnionAndDeDuplicateByName() public void Merge_WhenBothHaveTags_ShouldUnionAndDeDuplicateByName()
{ {
// Arrange // Arrange
BookMetadataDto first = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Tags = [_tagDtoFixture.Create(name: "Tag A"), _tagDtoFixture.Create(name: "Tag B")] }; BookMetadataDto first = _bookMetadataDtoFixture.Create(
BookMetadataDto second = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Tags = [_tagDtoFixture.Create(name: "Tag A"), _tagDtoFixture.Create(name: "Tag C")] }; includeReleaseInfo: false,
includeGenres: false,
includeLanguage: false,
includeFormat: false,
includeVolumeNumber: false,
title: "Title",
coverImagePath: "First Cover",
tags: [_tagDtoFixture.Create(name: "Tag A"), _tagDtoFixture.Create(name: "Tag B")]);
BookMetadataDto second = _bookMetadataDtoFixture.Create(
includeReleaseInfo: false,
includeGenres: false,
includeLanguage: false,
includeFormat: false,
includeVolumeNumber: false,
title: "Title",
coverImagePath: "First Cover",
tags: [_tagDtoFixture.Create(name: "Tag A"), _tagDtoFixture.Create(name: "Tag C")]);
// Act // Act
BookMetadataDto result = MetadataAggregator.Merge(first, second); BookMetadataDto result = MetadataAggregator.Merge(first, second);
@@ -220,8 +345,26 @@ public class MetadataAggregatorTests
public void Merge_WhenBothHaveIsbns_ShouldUnionAndDeDuplicateByValue() public void Merge_WhenBothHaveIsbns_ShouldUnionAndDeDuplicateByValue()
{ {
// Arrange // Arrange
BookMetadataDto first = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Isbns = [_isbnDtoFixture.Create(value: "9780306406157", format: IsbnFormat.Isbn13)] }; BookMetadataDto first = _bookMetadataDtoFixture.Create(
BookMetadataDto second = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Isbns = [_isbnDtoFixture.Create(value: "9780306406157", format: IsbnFormat.Isbn13), _isbnDtoFixture.Create(value: "0306406152", format: IsbnFormat.Isbn10)] }; includeReleaseInfo: false,
includeGenres: false,
includeTags: false,
includeLanguage: false,
includeFormat: false,
includeVolumeNumber: false,
title: "Title",
coverImagePath: "First Cover",
isbns: [_isbnDtoFixture.Create(value: "9780306406157", format: IsbnFormat.Isbn13)]);
BookMetadataDto second = _bookMetadataDtoFixture.Create(
includeReleaseInfo: false,
includeGenres: false,
includeTags: false,
includeLanguage: false,
includeFormat: false,
includeVolumeNumber: false,
title: "Title",
coverImagePath: "First Cover",
isbns: [_isbnDtoFixture.Create(value: "9780306406157", format: IsbnFormat.Isbn13), _isbnDtoFixture.Create(value: "0306406152", format: IsbnFormat.Isbn10)]);
// Act // Act
BookMetadataDto result = MetadataAggregator.Merge(first, second); BookMetadataDto result = MetadataAggregator.Merge(first, second);
@@ -236,8 +379,26 @@ public class MetadataAggregatorTests
public void Merge_WhenBothHaveContributors_ShouldUnionAndDeDuplicateByDisplayNameAndRole() public void Merge_WhenBothHaveContributors_ShouldUnionAndDeDuplicateByDisplayNameAndRole()
{ {
// Arrange // Arrange
BookMetadataDto first = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Contributors = [_mediaContributorDtoFixture.Create("Author A", MediaContributorRole.Author)] }; BookMetadataDto first = _bookMetadataDtoFixture.Create(
BookMetadataDto second = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Contributors = [_mediaContributorDtoFixture.Create("Author A", MediaContributorRole.Author), _mediaContributorDtoFixture.Create("Translator B", MediaContributorRole.Translator)] }; includeReleaseInfo: false,
includeGenres: false,
includeTags: false,
includeLanguage: false,
includeFormat: false,
includeVolumeNumber: false,
title: "Title",
coverImagePath: "First Cover",
contributors: [_mediaContributorDtoFixture.Create("Author A", MediaContributorRole.Author)]);
BookMetadataDto second = _bookMetadataDtoFixture.Create(
includeReleaseInfo: false,
includeGenres: false,
includeTags: false,
includeLanguage: false,
includeFormat: false,
includeVolumeNumber: false,
title: "Title",
coverImagePath: "First Cover",
contributors: [_mediaContributorDtoFixture.Create("Author A", MediaContributorRole.Author), _mediaContributorDtoFixture.Create("Translator B", MediaContributorRole.Translator)]);
// Act // Act
BookMetadataDto result = MetadataAggregator.Merge(first, second); BookMetadataDto result = MetadataAggregator.Merge(first, second);
@@ -252,8 +413,26 @@ public class MetadataAggregatorTests
public void Merge_WhenBothHaveRatings_ShouldUnionAndDeDuplicateBySource() public void Merge_WhenBothHaveRatings_ShouldUnionAndDeDuplicateBySource()
{ {
// Arrange // Arrange
BookMetadataDto first = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Ratings = [_bookRatingDtoFixture.Create(value: 8m, maxValue: 10m, source: BookRatingSource.Calibre, voteCount: null)] }; BookMetadataDto first = _bookMetadataDtoFixture.Create(
BookMetadataDto second = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Ratings = [_bookRatingDtoFixture.Create(value: 8m, maxValue: 10m, source: BookRatingSource.Calibre, voteCount: null), _bookRatingDtoFixture.Create(value: 4.2m, maxValue: 5m, source: BookRatingSource.OpenLibrary, voteCount: 100)] }; includeReleaseInfo: false,
includeGenres: false,
includeTags: false,
includeLanguage: false,
includeFormat: false,
includeVolumeNumber: false,
title: "Title",
coverImagePath: "First Cover",
ratings: [_bookRatingDtoFixture.Create(value: 8m, maxValue: 10m, source: BookRatingSource.Calibre, voteCount: null)]);
BookMetadataDto second = _bookMetadataDtoFixture.Create(
includeReleaseInfo: false,
includeGenres: false,
includeTags: false,
includeLanguage: false,
includeFormat: false,
includeVolumeNumber: false,
title: "Title",
coverImagePath: "First Cover",
ratings: [_bookRatingDtoFixture.Create(value: 8m, maxValue: 10m, source: BookRatingSource.Calibre, voteCount: null), _bookRatingDtoFixture.Create(value: 4.2m, maxValue: 5m, source: BookRatingSource.OpenLibrary, voteCount: 100)]);
// Act // Act
BookMetadataDto result = MetadataAggregator.Merge(first, second); BookMetadataDto result = MetadataAggregator.Merge(first, second);
@@ -268,8 +447,27 @@ public class MetadataAggregatorTests
public void Merge_WhenOnlyFirstHasCollections_ShouldReturnTheFirstCollections() public void Merge_WhenOnlyFirstHasCollections_ShouldReturnTheFirstCollections()
{ {
// Arrange // Arrange
BookMetadataDto first = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Tags = [_tagDtoFixture.Create(name: "Tag A")], Genres = [_genreDtoFixture.Create(name: "Genre A")], Isbns = [_isbnDtoFixture.Create(value: "9780306406157", format: IsbnFormat.Isbn13)], Contributors = [_mediaContributorDtoFixture.Create("Author A", MediaContributorRole.Author)], Ratings = [_bookRatingDtoFixture.Create(value: 8m, maxValue: 10m, source: BookRatingSource.Calibre, voteCount: null)] }; BookMetadataDto first = _bookMetadataDtoFixture.Create(
BookMetadataDto second = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Tags = null, Genres = null, Isbns = null, Contributors = null, Ratings = null }; includeReleaseInfo: false,
includeLanguage: false,
includeFormat: false,
includeVolumeNumber: false,
title: "Title",
coverImagePath: "First Cover",
tags: [_tagDtoFixture.Create(name: "Tag A")],
genres: [_genreDtoFixture.Create(name: "Genre A")],
isbns: [_isbnDtoFixture.Create(value: "9780306406157", format: IsbnFormat.Isbn13)],
contributors: [_mediaContributorDtoFixture.Create("Author A", MediaContributorRole.Author)],
ratings: [_bookRatingDtoFixture.Create(value: 8m, maxValue: 10m, source: BookRatingSource.Calibre, voteCount: null)]);
BookMetadataDto second = _bookMetadataDtoFixture.Create(
includeReleaseInfo: false,
includeGenres: false,
includeTags: false,
includeLanguage: false,
includeFormat: false,
includeVolumeNumber: false,
title: "Title",
coverImagePath: "First Cover");
// Act // Act
BookMetadataDto result = MetadataAggregator.Merge(first, second); BookMetadataDto result = MetadataAggregator.Merge(first, second);
@@ -286,8 +484,27 @@ public class MetadataAggregatorTests
public void Merge_WhenOnlySecondHasCollections_ShouldReturnTheSecondCollections() public void Merge_WhenOnlySecondHasCollections_ShouldReturnTheSecondCollections()
{ {
// Arrange // Arrange
BookMetadataDto first = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Tags = null, Genres = null, Isbns = null, Contributors = null, Ratings = null }; BookMetadataDto first = _bookMetadataDtoFixture.Create(
BookMetadataDto second = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Tags = [_tagDtoFixture.Create(name: "Tag B")], Genres = [_genreDtoFixture.Create(name: "Genre B")], Isbns = [_isbnDtoFixture.Create(value: "0306406152", format: IsbnFormat.Isbn10)], Contributors = [_mediaContributorDtoFixture.Create("Author B", MediaContributorRole.Author)], Ratings = [_bookRatingDtoFixture.Create(value: 4.2m, maxValue: 5m, source: BookRatingSource.OpenLibrary, voteCount: 100)] }; includeReleaseInfo: false,
includeGenres: false,
includeTags: false,
includeLanguage: false,
includeFormat: false,
includeVolumeNumber: false,
title: "Title",
coverImagePath: "First Cover");
BookMetadataDto second = _bookMetadataDtoFixture.Create(
includeReleaseInfo: false,
includeLanguage: false,
includeFormat: false,
includeVolumeNumber: false,
title: "Title",
coverImagePath: "First Cover",
tags: [_tagDtoFixture.Create(name: "Tag B")],
genres: [_genreDtoFixture.Create(name: "Genre B")],
isbns: [_isbnDtoFixture.Create(value: "0306406152", format: IsbnFormat.Isbn10)],
contributors: [_mediaContributorDtoFixture.Create("Author B", MediaContributorRole.Author)],
ratings: [_bookRatingDtoFixture.Create(value: 4.2m, maxValue: 5m, source: BookRatingSource.OpenLibrary, voteCount: 100)]);
// Act // Act
BookMetadataDto result = MetadataAggregator.Merge(first, second); BookMetadataDto result = MetadataAggregator.Merge(first, second);
@@ -304,8 +521,24 @@ public class MetadataAggregatorTests
public void Merge_WhenBothHaveNullCollections_ShouldReturnNullCollections() public void Merge_WhenBothHaveNullCollections_ShouldReturnNullCollections()
{ {
// Arrange // Arrange
BookMetadataDto first = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Tags = null, Genres = null, Isbns = null, Contributors = null, Ratings = null }; BookMetadataDto first = _bookMetadataDtoFixture.Create(
BookMetadataDto second = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Tags = null, Genres = null, Isbns = null, Contributors = null, Ratings = null }; includeReleaseInfo: false,
includeGenres: false,
includeTags: false,
includeLanguage: false,
includeFormat: false,
includeVolumeNumber: false,
title: "Title",
coverImagePath: "First Cover");
BookMetadataDto second = _bookMetadataDtoFixture.Create(
includeReleaseInfo: false,
includeGenres: false,
includeTags: false,
includeLanguage: false,
includeFormat: false,
includeVolumeNumber: false,
title: "Title",
coverImagePath: "First Cover");
// Act // Act
BookMetadataDto result = MetadataAggregator.Merge(first, second); BookMetadataDto result = MetadataAggregator.Merge(first, second);
@@ -322,8 +555,24 @@ public class MetadataAggregatorTests
public void Merge_WhenBothHaveLanguages_ShouldKeepTheFirstLanguage() public void Merge_WhenBothHaveLanguages_ShouldKeepTheFirstLanguage()
{ {
// Arrange // Arrange
BookMetadataDto first = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Language = _languageInfoDtoFixture.Create(languageCode: "en", languageName: "English", nativeName: "English") }; BookMetadataDto first = _bookMetadataDtoFixture.Create(
BookMetadataDto second = _bookMetadataDtoFixture.Create(title: "Title", coverImagePath: "First Cover", includeOptionalProperties: false) with { Language = _languageInfoDtoFixture.Create(languageCode: "de", languageName: "German", nativeName: "Deutsch") }; includeReleaseInfo: false,
includeGenres: false,
includeTags: false,
includeFormat: false,
includeVolumeNumber: false,
title: "Title",
coverImagePath: "First Cover",
language: _languageInfoDtoFixture.Create(languageCode: "en", languageName: "English", nativeName: "English"));
BookMetadataDto second = _bookMetadataDtoFixture.Create(
includeReleaseInfo: false,
includeGenres: false,
includeTags: false,
includeFormat: false,
includeVolumeNumber: false,
title: "Title",
coverImagePath: "First Cover",
language: _languageInfoDtoFixture.Create(languageCode: "de", languageName: "German", nativeName: "Deutsch"));
// Act // Act
BookMetadataDto result = MetadataAggregator.Merge(first, second); BookMetadataDto result = MetadataAggregator.Merge(first, second);
@@ -30,7 +30,7 @@ public class IMetadataProviderGenericTests
// Arrange // Arrange
BookMetadataLookupDto lookup = _bookMetadataLookupDtoFixture.Create(); BookMetadataLookupDto lookup = _bookMetadataLookupDtoFixture.Create();
CancellationToken cancellationToken = CancellationToken.None; CancellationToken cancellationToken = CancellationToken.None;
BookMetadataDto expectedMetadata = _bookMetadataDtoFixture.Create(title: "Search Result", includeOptionalProperties: false); BookMetadataDto expectedMetadata = _bookMetadataDtoFixture.Create(title: "Search Result", includeReleaseInfo: false, includeGenres: false, includeTags: false, includeLanguage: false, includeFormat: false, includeVolumeNumber: false);
TestBookMetadataProvider provider = new(expectedMetadata); TestBookMetadataProvider provider = new(expectedMetadata);
IMetadataProvider baseProvider = provider; IMetadataProvider baseProvider = provider;
@@ -50,7 +50,7 @@ public class IMetadataProviderGenericTests
// Arrange // Arrange
BookMetadataLookupDto lookup = _bookMetadataLookupDtoFixture.Create(); BookMetadataLookupDto lookup = _bookMetadataLookupDtoFixture.Create();
CancellationToken cancellationToken = CancellationToken.None; CancellationToken cancellationToken = CancellationToken.None;
BookMetadataDto expectedMetadata = _bookMetadataDtoFixture.Create(title: "Exact Result", includeOptionalProperties: false); BookMetadataDto expectedMetadata = _bookMetadataDtoFixture.Create(title: "Exact Result", includeReleaseInfo: false, includeGenres: false, includeTags: false, includeLanguage: false, includeFormat: false, includeVolumeNumber: false);
TestBookMetadataProvider provider = new(expectedMetadata); TestBookMetadataProvider provider = new(expectedMetadata);
IMetadataProvider baseProvider = provider; IMetadataProvider baseProvider = provider;
@@ -68,7 +68,7 @@ public class IMetadataProviderGenericTests
{ {
// Arrange // Arrange
MetadataLookupDto otherLookup = _otherMetadataLookupDtoFixture.Create(); MetadataLookupDto otherLookup = _otherMetadataLookupDtoFixture.Create();
TestBookMetadataProvider provider = new(_bookMetadataDtoFixture.Create(title: "Search Result", includeOptionalProperties: false)); TestBookMetadataProvider provider = new(_bookMetadataDtoFixture.Create(title: "Search Result", includeReleaseInfo: false, includeGenres: false, includeTags: false, includeLanguage: false, includeFormat: false, includeVolumeNumber: false));
IMetadataProvider baseProvider = provider; IMetadataProvider baseProvider = provider;
// Act // Act
@@ -87,7 +87,7 @@ public class IMetadataProviderGenericTests
{ {
// Arrange // Arrange
MetadataLookupDto otherLookup = _otherMetadataLookupDtoFixture.Create(); MetadataLookupDto otherLookup = _otherMetadataLookupDtoFixture.Create();
TestBookMetadataProvider provider = new(_bookMetadataDtoFixture.Create(title: "Exact Result", includeOptionalProperties: false)); TestBookMetadataProvider provider = new(_bookMetadataDtoFixture.Create(title: "Exact Result", includeReleaseInfo: false, includeGenres: false, includeTags: false, includeLanguage: false, includeFormat: false, includeVolumeNumber: false));
IMetadataProvider baseProvider = provider; IMetadataProvider baseProvider = provider;
// Act // Act