mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 19:21:10 +00:00
Hardens test assertions and adds missing test coverage.
This commit is contained in:
1 parent
6b86fd5805
commit
1189bbaf36
489 files changed
+39982
-512
No files matched your search
+86
@@ -0,0 +1,86 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.AudioLibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Common.ValueObjects.Metadata;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.AudioLibraryBoundedContext.AudioLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="AudioMetadata"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AudioMetadataFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly GenreFixture _genreFixture = new();
|
||||
private readonly TagFixture _tagFixture = new();
|
||||
private readonly ReleaseInfoFixture _releaseInfoFixture = new();
|
||||
private readonly LanguageInfoFixture _languageInfoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="AudioMetadata"/>.
|
||||
/// </summary>
|
||||
/// <param name="title">Optional. The title of the audio.</param>
|
||||
/// <param name="originalTitle">Optional. The original title of the audio.</param>
|
||||
/// <param name="durationInSeconds">Optional. The duration of the audio, in seconds.</param>
|
||||
/// <param name="sampleRate">Optional. The sample rate of the audio, in Hz.</param>
|
||||
/// <param name="channels">Optional. The number of audio channels.</param>
|
||||
/// <param name="releaseInfo">Optional. The release information of the audio.</param>
|
||||
/// <param name="description">Optional. The description of the audio.</param>
|
||||
/// <param name="genres">Optional. The genres of the audio.</param>
|
||||
/// <param name="tags">Optional. The tags associated with the audio.</param>
|
||||
/// <param name="language">Optional. The language of the audio.</param>
|
||||
/// <param name="originalLanguage">Optional. The original language of the audio.</param>
|
||||
/// <param name="bitDepth">Optional. The bit depth of the audio.</param>
|
||||
/// <param name="audioCodec">Optional. The audio codec used.</param>
|
||||
/// <param name="bitrate">Optional. The bitrate of the audio, in kbps.</param>
|
||||
/// <returns>The created <see cref="AudioMetadata"/>.</returns>
|
||||
public AudioMetadata Create(
|
||||
string? title = null,
|
||||
Optional<string>? originalTitle = null,
|
||||
int? durationInSeconds = null,
|
||||
int? sampleRate = null,
|
||||
int? channels = null,
|
||||
ReleaseInfo? releaseInfo = null,
|
||||
Optional<string>? description = null,
|
||||
List<Genre>? genres = null,
|
||||
List<Tag>? tags = null,
|
||||
Optional<LanguageInfo>? language = null,
|
||||
Optional<LanguageInfo>? originalLanguage = null,
|
||||
Optional<int>? bitDepth = null,
|
||||
Optional<string>? audioCodec = null,
|
||||
Optional<int>? bitrate = null)
|
||||
{
|
||||
return AudioMetadata.Create(
|
||||
title ?? _faker.Music.Genre(),
|
||||
originalTitle ?? Optional<string>.None(),
|
||||
durationInSeconds ?? _faker.Random.Int(60, 7200),
|
||||
sampleRate ?? _faker.Random.Int(44100, 192000),
|
||||
channels ?? _faker.Random.Int(1, 8),
|
||||
releaseInfo ?? _releaseInfoFixture.Create(),
|
||||
description ?? Optional<string>.Some(_faker.Lorem.Sentence()),
|
||||
genres ?? [_genreFixture.Create(), _genreFixture.Create()],
|
||||
tags ?? [_tagFixture.Create(), _tagFixture.Create()],
|
||||
language ?? Optional<LanguageInfo>.Some(_languageInfoFixture.Create()),
|
||||
originalLanguage ?? Optional<LanguageInfo>.None(),
|
||||
bitDepth ?? Optional<int>.Some(_faker.Random.Int(8, 32)),
|
||||
audioCodec ?? Optional<string>.Some("PCM"),
|
||||
bitrate ?? Optional<int>.Some(_faker.Random.Int(128, 320))).Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="AudioMetadata"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="AudioMetadata"/> instances.</returns>
|
||||
public List<AudioMetadata> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+5
-2
@@ -32,6 +32,7 @@ public class LibraryFixture
|
||||
/// <param name="libraryType">Optional. The library type.</param>
|
||||
/// <param name="contentLocations">Optional. The content locations of the library.</param>
|
||||
/// <param name="coverImage">Optional. The cover image of the library.</param>
|
||||
/// <param name="includeCoverImage">Whether to include a cover image or not.</param>
|
||||
/// <param name="isEnabled">Whether the library is enabled.</param>
|
||||
/// <param name="isLocked">Whether the library is locked.</param>
|
||||
/// <param name="downloadMetadataFromWeb">Whether metadata download from the web is enabled.</param>
|
||||
@@ -46,6 +47,7 @@ public class LibraryFixture
|
||||
LibraryType? libraryType = null,
|
||||
IEnumerable<string>? contentLocations = null,
|
||||
string? coverImage = null,
|
||||
bool includeCoverImage = true,
|
||||
bool isEnabled = true,
|
||||
bool isLocked = false,
|
||||
bool downloadMetadataFromWeb = true,
|
||||
@@ -62,6 +64,7 @@ public class LibraryFixture
|
||||
];
|
||||
|
||||
List<ScanId> resolvedScanIds = scanIds is null ? [ScanId.CreateUnique(), ScanId.CreateUnique()] : [.. scanIds.Select(scanId => ScanId.Create(scanId))];
|
||||
string? resolvedCoverImage = includeCoverImage ? (coverImage ?? _faker.System.FilePath()) : null;
|
||||
|
||||
Result<Library> library = id is null ?
|
||||
Library.Create(
|
||||
@@ -69,7 +72,7 @@ public class LibraryFixture
|
||||
title ?? _faker.Random.String2(_faker.Random.Number(1, 50)),
|
||||
libraryType ?? _faker.PickRandom<LibraryType>(),
|
||||
contentLocations ?? validPaths.Take(_random.Next(1, validPaths.Count)),
|
||||
coverImage ?? _faker.System.FilePath(),
|
||||
resolvedCoverImage,
|
||||
isEnabled,
|
||||
isLocked,
|
||||
downloadMetadataFromWeb,
|
||||
@@ -83,7 +86,7 @@ public class LibraryFixture
|
||||
title ?? _faker.Random.String2(_faker.Random.Number(1, 50)),
|
||||
libraryType ?? _faker.PickRandom<LibraryType>(),
|
||||
contentLocations ?? validPaths.Take(_random.Next(1, validPaths.Count)),
|
||||
coverImage ?? _faker.System.FilePath(),
|
||||
resolvedCoverImage,
|
||||
isEnabled,
|
||||
isLocked,
|
||||
downloadMetadataFromWeb,
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryId"/> value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryIdFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryId"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The raw value of the library Id.</param>
|
||||
/// <returns>The created <see cref="LibraryId"/>.</returns>
|
||||
public LibraryId Create(Guid? value = null)
|
||||
{
|
||||
return LibraryId.Create(value ?? Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="LibraryId"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="LibraryId"/> instances.</returns>
|
||||
public List<LibraryId> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryScan"/> domain aggregate.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryScanFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryScan"/> domain aggregate.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The scan Id.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the media library that is scanned.</param>
|
||||
/// <param name="userId">Optional. The Id of the user that initiated the scan.</param>
|
||||
/// <param name="status">Optional. The status of the media library scan.</param>
|
||||
/// <param name="pastScans">Optional. The list of past scans of the scanned media library.</param>
|
||||
/// <returns>The created <see cref="LibraryScan"/>.</returns>
|
||||
public LibraryScan Create(
|
||||
Guid? id = null,
|
||||
Guid? libraryId = null,
|
||||
Guid? userId = null,
|
||||
LibraryScanJobStatus? status = null,
|
||||
List<LibraryScan>? pastScans = null)
|
||||
{
|
||||
Result<LibraryScan> scan = LibraryScan.Create(
|
||||
ScanId.Create(id ?? Guid.NewGuid()),
|
||||
LibraryId.Create(libraryId ?? Guid.NewGuid()),
|
||||
UserId.Create(userId ?? Guid.NewGuid()),
|
||||
status ?? LibraryScanJobStatus.Pending,
|
||||
pastScans ?? []);
|
||||
|
||||
return scan.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="LibraryScan"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="LibraryScan"/> instances.</returns>
|
||||
public List<LibraryScan> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MediaLibraryScanCompositeId"/> value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaLibraryScanCompositeIdFixture
|
||||
{
|
||||
private readonly ScanIdFixture _scanIdFixture = new();
|
||||
private readonly UserIdFixture _userIdFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MediaLibraryScanCompositeId"/>.
|
||||
/// </summary>
|
||||
/// <param name="scanId">Optional. The scan Id of the composite scan identifier.</param>
|
||||
/// <param name="userId">Optional. The user Id of the composite scan identifier.</param>
|
||||
/// <returns>The created <see cref="MediaLibraryScanCompositeId"/>.</returns>
|
||||
public MediaLibraryScanCompositeId Create(ScanId? scanId = null, UserId? userId = null)
|
||||
{
|
||||
return MediaLibraryScanCompositeId.Create(
|
||||
scanId ?? _scanIdFixture.Create(),
|
||||
userId ?? _userIdFixture.Create());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="MediaLibraryScanCompositeId"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MediaLibraryScanCompositeId"/> instances.</returns>
|
||||
public List<MediaLibraryScanCompositeId> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MediaLibraryScanJobProgress"/> value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaLibraryScanJobProgressFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MediaLibraryScanJobProgress"/>.
|
||||
/// </summary>
|
||||
/// <param name="completedItems">Optional. The number of completed items of the scan job.</param>
|
||||
/// <param name="totalItems">Optional. The total number of items of the scan job.</param>
|
||||
/// <param name="currentOperation">Optional. The current operation being performed by the scan job.</param>
|
||||
/// <returns>The created <see cref="MediaLibraryScanJobProgress"/>.</returns>
|
||||
public MediaLibraryScanJobProgress Create(
|
||||
int? completedItems = null,
|
||||
int? totalItems = null,
|
||||
string? currentOperation = null)
|
||||
{
|
||||
Result<MediaLibraryScanJobProgress> progress = MediaLibraryScanJobProgress.Create(
|
||||
completedItems ?? _faker.Random.Number(0, 100),
|
||||
totalItems ?? _faker.Random.Number(100, 200),
|
||||
currentOperation ?? _faker.Random.Words());
|
||||
|
||||
return progress.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="MediaLibraryScanJobProgress"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MediaLibraryScanJobProgress"/> instances.</returns>
|
||||
public List<MediaLibraryScanJobProgress> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MediaLibraryScanProgress"/> value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaLibraryScanProgressFixture
|
||||
{
|
||||
private readonly ScanIdFixture _scanIdFixture = new();
|
||||
private readonly UserIdFixture _userIdFixture = new();
|
||||
private readonly LibraryIdFixture _libraryIdFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MediaLibraryScanProgress"/>.
|
||||
/// </summary>
|
||||
/// <param name="scanId">Optional. The scan Id of the media library scan.</param>
|
||||
/// <param name="userId">Optional. The user Id of the user initiating the media library scan.</param>
|
||||
/// <param name="libraryId">Optional. The library Id of the scanned media library.</param>
|
||||
/// <param name="completedJobs">Optional. The number of completed jobs of the media library scan.</param>
|
||||
/// <param name="totalJobs">Optional. The total number of jobs of the media library scan.</param>
|
||||
/// <param name="status">Optional. The status of the media library scan.</param>
|
||||
/// <param name="currentJobProgress">Optional. The current job progress of the media library scan. When <see langword="null"/>, no current job progress is set.</param>
|
||||
/// <returns>The created <see cref="MediaLibraryScanProgress"/>.</returns>
|
||||
public MediaLibraryScanProgress Create(
|
||||
ScanId? scanId = null,
|
||||
UserId? userId = null,
|
||||
LibraryId? libraryId = null,
|
||||
int? completedJobs = null,
|
||||
int? totalJobs = null,
|
||||
LibraryScanJobStatus? status = null,
|
||||
Optional<MediaLibraryScanJobProgress>? currentJobProgress = null)
|
||||
{
|
||||
Result<MediaLibraryScanProgress> progress = MediaLibraryScanProgress.Create(
|
||||
scanId ?? _scanIdFixture.Create(),
|
||||
userId ?? _userIdFixture.Create(),
|
||||
libraryId ?? _libraryIdFixture.Create(),
|
||||
completedJobs ?? 1,
|
||||
totalJobs ?? 2,
|
||||
status ?? LibraryScanJobStatus.Pending,
|
||||
currentJobProgress ?? Optional<MediaLibraryScanJobProgress>.None());
|
||||
|
||||
return progress.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="MediaLibraryScanProgress"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MediaLibraryScanProgress"/> instances.</returns>
|
||||
public List<MediaLibraryScanProgress> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ScanId"/> value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ScanIdFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ScanId"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The raw value of the scan Id.</param>
|
||||
/// <returns>The created <see cref="ScanId"/>.</returns>
|
||||
public ScanId Create(Guid? value = null)
|
||||
{
|
||||
return ScanId.Create(value ?? Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ScanId"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ScanId"/> instances.</returns>
|
||||
public List<ScanId> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaContributorBoundedContext.MediaContributorAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaContributorBoundedContext.MediaContributorAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MediaContributorId"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaContributorIdFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MediaContributorId"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The value used to create the <see cref="MediaContributorId"/>. If not provided, a random value is generated.</param>
|
||||
/// <returns>The created <see cref="MediaContributorId"/>.</returns>
|
||||
public MediaContributorId Create(Guid? value = null)
|
||||
{
|
||||
return value is null ? MediaContributorId.CreateUnique() : MediaContributorId.Create(value.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="MediaContributorId"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MediaContributorId"/> instances.</returns>
|
||||
public List<MediaContributorId> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaContributorBoundedContext.MediaContributorAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaContributorBoundedContext.MediaContributorAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MediaContributorName"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaContributorNameFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MediaContributorName"/>.
|
||||
/// </summary>
|
||||
/// <param name="displayName">Optional. The name by which the contributor is popularly known. If not provided, a random name is generated.</param>
|
||||
/// <param name="legalName">Optional. The legal name of the contributor. If not provided, a random legal name is generated.</param>
|
||||
/// <returns>The created <see cref="MediaContributorName"/>.</returns>
|
||||
public MediaContributorName Create(string? displayName = null, Optional<string>? legalName = null)
|
||||
{
|
||||
Result<MediaContributorName> nameResult = MediaContributorName.Create(
|
||||
displayName ?? _faker.Person.FullName,
|
||||
legalName ?? Optional<string>.Some(_faker.Person.FullName));
|
||||
|
||||
if (nameResult.IsFailure)
|
||||
throw new InvalidOperationException("Failed to create MediaContributorName: " + string.Join(", ", nameResult.Errors));
|
||||
return nameResult.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="MediaContributorName"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MediaContributorName"/> instances.</returns>
|
||||
public List<MediaContributorName> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaContributorBoundedContext.MediaContributorAggregate.ValueObjects;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.MediaContributorBoundedContext.MediaContributorAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MediaContributorRole"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaContributorRoleFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MediaContributorRole"/>.
|
||||
/// </summary>
|
||||
/// <param name="name">Optional. The name of the role. If not provided, a random name is generated.</param>
|
||||
/// <param name="category">Optional. The category of the role. If not provided, a random category is generated.</param>
|
||||
/// <returns>The created <see cref="MediaContributorRole"/>.</returns>
|
||||
public MediaContributorRole Create(string? name = null, string? category = null)
|
||||
{
|
||||
return MediaContributorRole.Create(
|
||||
name ?? _faker.Lorem.Word(),
|
||||
category ?? _faker.Commerce.Department());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="MediaContributorRole"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MediaContributorRole"/> instances.</returns>
|
||||
public List<MediaContributorRole> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="User"/> domain aggregate.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UserFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="User"/> domain aggregate.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The user Id.</param>
|
||||
/// <param name="username">Optional. The username of the user.</param>
|
||||
/// <returns>The created <see cref="User"/>.</returns>
|
||||
public User Create(Guid? id = null, string? username = null)
|
||||
{
|
||||
UserId userId = id is null ? UserId.CreateUnique() : UserId.Create(id.Value);
|
||||
Result<User> user = User.Create(userId, username ?? _faker.Internet.UserName());
|
||||
return user.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="User"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="User"/> instances.</returns>
|
||||
public List<User> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="UserId"/> value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UserIdFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="UserId"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The raw value of the user Id.</param>
|
||||
/// <returns>The created <see cref="UserId"/>.</returns>
|
||||
public UserId Create(Guid? value = null)
|
||||
{
|
||||
return UserId.Create(value ?? Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="UserId"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="UserId"/> instances.</returns>
|
||||
public List<UserId> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserSettingsAggregate;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.UserManagementBoundedContext.UserSettingsAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="UserSettings"/> domain aggregate.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UserSettingsFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="UserSettings"/> domain aggregate.
|
||||
/// </summary>
|
||||
/// <param name="userId">Optional. The Id of the user that owns the settings.</param>
|
||||
/// <param name="isPaginationEnabled">Whether pagination is enabled for the user.</param>
|
||||
/// <param name="itemsPerPage">The number of library items displayed per page when pagination is enabled.</param>
|
||||
/// <param name="ignoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker.</param>
|
||||
/// <returns>The created <see cref="UserSettings"/>.</returns>
|
||||
public UserSettings Create(
|
||||
Guid? userId = null,
|
||||
bool isPaginationEnabled = true,
|
||||
int itemsPerPage = 48,
|
||||
bool ignoreThePrefixForAlphaPicker = false)
|
||||
{
|
||||
Result<UserSettings> settings = UserSettings.Create(
|
||||
userId is null ? UserId.CreateUnique() : UserId.Create(userId.Value),
|
||||
isPaginationEnabled,
|
||||
itemsPerPage,
|
||||
ignoreThePrefixForAlphaPicker);
|
||||
return settings.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="UserSettings"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="UserSettings"/> instances.</returns>
|
||||
public List<UserSettings> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using Lumina.Domain.Core.BoundedContexts.MediaContributorBoundedContext.MediaContributorAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.VideoLibraryBoundedContext.MovieLibraryAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.VideoLibraryBoundedContext.MovieLibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.MediaContributorBoundedContext.MediaContributorAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.VideoLibraryBoundedContext.MovieLibraryAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.VideoLibraryBoundedContext.MovieLibraryAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="Movie"/> domain aggregate.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MovieFixture
|
||||
{
|
||||
private readonly VideoMetadataFixture _videoMetadataFixture = new();
|
||||
private readonly MovieIdFixture _movieIdFixture = new();
|
||||
private readonly MediaContributorIdFixture _mediaContributorIdFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="Movie"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The unique identifier of the movie.</param>
|
||||
/// <param name="metadata">Optional. The metadata of the movie.</param>
|
||||
/// <param name="contributors">Optional. The list of media contributors of the movie.</param>
|
||||
/// <param name="ratings">Optional. The list of ratings for the movie.</param>
|
||||
/// <returns>The created <see cref="Movie"/>.</returns>
|
||||
public Movie Create(
|
||||
MovieId? id = null,
|
||||
VideoMetadata? metadata = null,
|
||||
List<MediaContributorId>? contributors = null,
|
||||
List<Rating>? ratings = null)
|
||||
{
|
||||
return Movie.Create(
|
||||
id ?? _movieIdFixture.Create(),
|
||||
metadata ?? _videoMetadataFixture.Create(),
|
||||
contributors ?? [_mediaContributorIdFixture.Create()],
|
||||
ratings ?? []).Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="Movie"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="Movie"/> instances.</returns>
|
||||
public List<Movie> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.VideoLibraryBoundedContext.MovieLibraryAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.VideoLibraryBoundedContext.MovieLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MovieId"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MovieIdFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MovieId"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The value used to create the <see cref="MovieId"/>. If not provided, a random value is generated.</param>
|
||||
/// <returns>The created <see cref="MovieId"/>.</returns>
|
||||
public MovieId Create(Guid? value = null)
|
||||
{
|
||||
return value is null ? MovieId.CreateUnique() : MovieId.Create(value.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="MovieId"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MovieId"/> instances.</returns>
|
||||
public List<MovieId> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using Lumina.Domain.Core.BoundedContexts.VideoLibraryBoundedContext.MovieLibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Common.ValueObjects.Metadata;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.VideoLibraryBoundedContext.MovieLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="VideoMetadata"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class VideoMetadataFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly GenreFixture _genreFixture = new();
|
||||
private readonly TagFixture _tagFixture = new();
|
||||
private readonly ReleaseInfoFixture _releaseInfoFixture = new();
|
||||
private readonly LanguageInfoFixture _languageInfoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="VideoMetadata"/>.
|
||||
/// </summary>
|
||||
/// <param name="title">Optional. The title of the video.</param>
|
||||
/// <param name="originalTitle">Optional. The original title of the video.</param>
|
||||
/// <param name="durationInSeconds">Optional. The duration of the video in seconds.</param>
|
||||
/// <param name="resolution">Optional. The resolution of the video.</param>
|
||||
/// <param name="description">Optional. The description of the video.</param>
|
||||
/// <param name="releaseInfo">Optional. The release information of the video.</param>
|
||||
/// <param name="language">Optional. The language of the video.</param>
|
||||
/// <param name="originalLanguage">Optional. The original language of the video.</param>
|
||||
/// <param name="frameRate">Optional. The frame rate of the video.</param>
|
||||
/// <param name="videoCodec">Optional. The video codec used.</param>
|
||||
/// <param name="audioCodec">Optional. The audio codec used.</param>
|
||||
/// <param name="genres">Optional. The genres of the video.</param>
|
||||
/// <param name="tags">Optional. The tags associated with the video.</param>
|
||||
/// <returns>The created <see cref="VideoMetadata"/>.</returns>
|
||||
public VideoMetadata Create(
|
||||
string? title = null,
|
||||
Optional<string>? originalTitle = null,
|
||||
int? durationInSeconds = null,
|
||||
string? resolution = null,
|
||||
Optional<string>? description = null,
|
||||
ReleaseInfo? releaseInfo = null,
|
||||
Optional<LanguageInfo>? language = null,
|
||||
Optional<LanguageInfo>? originalLanguage = null,
|
||||
Optional<float>? frameRate = null,
|
||||
Optional<string>? videoCodec = null,
|
||||
Optional<string>? audioCodec = null,
|
||||
List<Genre>? genres = null,
|
||||
List<Tag>? tags = null)
|
||||
{
|
||||
return VideoMetadata.Create(
|
||||
title ?? _faker.Commerce.ProductName(),
|
||||
originalTitle ?? Optional<string>.None(),
|
||||
durationInSeconds ?? _faker.Random.Int(60, 18000),
|
||||
resolution ?? "1920x1080",
|
||||
description ?? Optional<string>.Some(_faker.Lorem.Sentence()),
|
||||
releaseInfo ?? _releaseInfoFixture.Create(),
|
||||
language ?? Optional<LanguageInfo>.Some(_languageInfoFixture.Create()),
|
||||
originalLanguage ?? Optional<LanguageInfo>.None(),
|
||||
frameRate ?? Optional<float>.Some(24),
|
||||
videoCodec ?? Optional<string>.Some("H.264"),
|
||||
audioCodec ?? Optional<string>.Some("AAC"),
|
||||
genres ?? [_genreFixture.Create(), _genreFixture.Create()],
|
||||
tags ?? [_tagFixture.Create(), _tagFixture.Create()]).Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="VideoMetadata"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="VideoMetadata"/> instances.</returns>
|
||||
public List<VideoMetadata> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.VideoLibraryBoundedContext.TvShowLibraryAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.VideoLibraryBoundedContext.TvShowLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="EpisodeId"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class EpisodeIdFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="EpisodeId"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The value used to create the <see cref="EpisodeId"/>. If not provided, a random value is generated.</param>
|
||||
/// <returns>The created <see cref="EpisodeId"/>.</returns>
|
||||
public EpisodeId Create(Guid? value = null)
|
||||
{
|
||||
return value is null ? EpisodeId.CreateUnique() : EpisodeId.Create(value.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="EpisodeId"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="EpisodeId"/> instances.</returns>
|
||||
public List<EpisodeId> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.VideoLibraryBoundedContext.TvShowLibraryAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.VideoLibraryBoundedContext.TvShowLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="SeasonId"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class SeasonIdFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="SeasonId"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The value used to create the <see cref="SeasonId"/>. If not provided, a random value is generated.</param>
|
||||
/// <returns>The created <see cref="SeasonId"/>.</returns>
|
||||
public SeasonId Create(Guid? value = null)
|
||||
{
|
||||
return value is null ? SeasonId.CreateUnique() : SeasonId.Create(value.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="SeasonId"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="SeasonId"/> instances.</returns>
|
||||
public List<SeasonId> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.VideoLibraryBoundedContext.TvShowLibraryAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.VideoLibraryBoundedContext.TvShowLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="TvShowId"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class TvShowIdFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="TvShowId"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The value used to create the <see cref="TvShowId"/>. If not provided, a random value is generated.</param>
|
||||
/// <returns>The created <see cref="TvShowId"/>.</returns>
|
||||
public TvShowId Create(Guid? value = null)
|
||||
{
|
||||
return value is null ? TvShowId.CreateUnique() : TvShowId.Create(value.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="TvShowId"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="TvShowId"/> instances.</returns>
|
||||
public List<TvShowId> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Entities;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="BookSeries"/> domain aggregate.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class BookSeriesFixture
|
||||
{
|
||||
private readonly BookSeriesIdFixture _bookSeriesIdFixture = new();
|
||||
private readonly WrittenContentMetadataFixture _writtenContentMetadataFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="BookSeries"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The unique identifier of the book series.</param>
|
||||
/// <param name="isComplete">Whether the book series is complete.</param>
|
||||
/// <returns>The created <see cref="BookSeries"/>.</returns>
|
||||
public BookSeries Create(
|
||||
Guid? id = null,
|
||||
bool isComplete = false)
|
||||
{
|
||||
return BookSeries.Create(
|
||||
id is null ? BookSeriesId.CreateUnique() : _bookSeriesIdFixture.Create(id.Value),
|
||||
_writtenContentMetadataFixture.Create(),
|
||||
isComplete,
|
||||
[]).Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="BookSeries"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="BookSeries"/> instances.</returns>
|
||||
public List<BookSeries> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="BookId"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class BookIdFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="BookId"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The value used to create the <see cref="BookId"/>. If not provided, a random value is generated.</param>
|
||||
/// <returns>The created <see cref="BookId"/>.</returns>
|
||||
public BookId Create(Guid? value = null)
|
||||
{
|
||||
return value is null ? BookId.CreateUnique() : BookId.Create(value.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="BookId"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="BookId"/> instances.</returns>
|
||||
public List<BookId> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="BookLibraryId"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class BookLibraryIdFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="BookLibraryId"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The value used to create the <see cref="BookLibraryId"/>. If not provided, a random value is generated.</param>
|
||||
/// <returns>The created <see cref="BookLibraryId"/>.</returns>
|
||||
public BookLibraryId Create(Guid? value = null)
|
||||
{
|
||||
return value is null ? BookLibraryId.CreateUnique().Value : BookLibraryId.Create(value.Value).Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="BookLibraryId"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="BookLibraryId"/> instances.</returns>
|
||||
public List<BookLibraryId> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="BookSeriesId"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class BookSeriesIdFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="BookSeriesId"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The value used to create the <see cref="BookSeriesId"/>. If not provided, a random value is generated.</param>
|
||||
/// <returns>The created <see cref="BookSeriesId"/>.</returns>
|
||||
public BookSeriesId Create(Guid? value = null)
|
||||
{
|
||||
return value is null ? BookSeriesId.CreateUnique() : BookSeriesId.Create(value.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="BookSeriesId"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="BookSeriesId"/> instances.</returns>
|
||||
public List<BookSeriesId> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+15
-4
@@ -1,4 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
|
||||
using System;
|
||||
@@ -19,13 +20,23 @@ public class IsbnFixture
|
||||
/// <summary>
|
||||
/// Creates a valid <see cref="Isbn"/> with a random or explicitly requested format.
|
||||
/// </summary>
|
||||
/// <param name="value">Optional. The ISBN value to use. If not provided, a random valid value is generated for the requested format.</param>
|
||||
/// <param name="format">Optional. The requested <see cref="IsbnFormat"/>. If not provided, a random format is selected.</param>
|
||||
/// <returns>The created <see cref="Isbn"/>.</returns>
|
||||
public Isbn Create(IsbnFormat? format = null)
|
||||
public Isbn Create(string? value = null, IsbnFormat? format = null)
|
||||
{
|
||||
IsbnFormat targetFormat = format ?? (_random.Next(2) == 0 ? IsbnFormat.Isbn10 : IsbnFormat.Isbn13);
|
||||
string isbn = targetFormat == IsbnFormat.Isbn10 ? GenerateValidIsbn10() : GenerateValidIsbn13();
|
||||
return Isbn.Create(isbn, targetFormat).Value;
|
||||
if (value is not null)
|
||||
{
|
||||
IsbnFormat targetFormat = format ?? IsbnFormat.Isbn10;
|
||||
Result<Isbn> result = Isbn.Create(value, targetFormat);
|
||||
if (result.IsFailure)
|
||||
throw new InvalidOperationException("Failed to create Isbn: " + string.Join(", ", result.Errors));
|
||||
return result.Value;
|
||||
}
|
||||
|
||||
IsbnFormat requestedFormat = format ?? (_random.Next(2) == 0 ? IsbnFormat.Isbn10 : IsbnFormat.Isbn13);
|
||||
string isbn = requestedFormat == IsbnFormat.Isbn10 ? GenerateValidIsbn10() : GenerateValidIsbn13();
|
||||
return Isbn.Create(isbn, requestedFormat).Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.ValueObjects.Metadata;
|
||||
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Common.ValueObjects.Metadata;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="WrittenContentMetadata"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class WrittenContentMetadataFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly GenreFixture _genreFixture = new();
|
||||
private readonly TagFixture _tagFixture = new();
|
||||
private readonly ReleaseInfoFixture _releaseInfoFixture = new();
|
||||
private readonly LanguageInfoFixture _languageInfoFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="WrittenContentMetadata"/>.
|
||||
/// </summary>
|
||||
/// <param name="title">Optional. The title of the written content.</param>
|
||||
/// <param name="originalTitle">Optional. The original title of the written content.</param>
|
||||
/// <param name="description">Optional. The description of the written content.</param>
|
||||
/// <param name="releaseInfo">Optional. The release information of the written content.</param>
|
||||
/// <param name="genres">Optional. The genres of the written content.</param>
|
||||
/// <param name="tags">Optional. The tags associated with the written content.</param>
|
||||
/// <param name="language">Optional. The language of the written content.</param>
|
||||
/// <param name="originalLanguage">Optional. The original language of the written content.</param>
|
||||
/// <param name="publisher">Optional. The publisher of the written content.</param>
|
||||
/// <param name="pageCount">Optional. The number of pages in the written content.</param>
|
||||
/// <returns>The created <see cref="WrittenContentMetadata"/>.</returns>
|
||||
public WrittenContentMetadata Create(
|
||||
string? title = null,
|
||||
Optional<string>? originalTitle = null,
|
||||
Optional<string>? description = null,
|
||||
ReleaseInfo? releaseInfo = null,
|
||||
List<Genre>? genres = null,
|
||||
List<Tag>? tags = null,
|
||||
Optional<LanguageInfo>? language = null,
|
||||
Optional<LanguageInfo>? originalLanguage = null,
|
||||
Optional<string>? publisher = null,
|
||||
Optional<int>? pageCount = null)
|
||||
{
|
||||
return WrittenContentMetadata.Create(
|
||||
title ?? _faker.Commerce.ProductName(),
|
||||
originalTitle ?? Optional<string>.None(),
|
||||
description ?? Optional<string>.Some(_faker.Lorem.Sentence()),
|
||||
releaseInfo ?? _releaseInfoFixture.Create(),
|
||||
genres ?? [_genreFixture.Create(), _genreFixture.Create()],
|
||||
tags ?? [_tagFixture.Create(), _tagFixture.Create()],
|
||||
language ?? Optional<LanguageInfo>.Some(_languageInfoFixture.Create()),
|
||||
originalLanguage ?? Optional<LanguageInfo>.None(),
|
||||
publisher ?? Optional<string>.Some(_faker.Company.CompanyName()),
|
||||
pageCount ?? Optional<int>.Some(_faker.Random.Int(1, 1000))).Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="WrittenContentMetadata"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="WrittenContentMetadata"/> instances.</returns>
|
||||
public List<WrittenContentMetadata> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user