mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 17:11:10 +00:00
Renames project paths from Lumina to Nemera
This commit is contained in:
1 parent
ce6fddb4c9
commit
0f659a4877
6450 files changed
No files matched your search
+33
@@ -0,0 +1,33 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.Events;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryDeletedDomainEvent"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryDeletedDomainEventFixture
|
||||
{
|
||||
private readonly LibraryFixture _libraryFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryDeletedDomainEvent"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the domain event.</param>
|
||||
/// <param name="library">Optional. The library that was deleted.</param>
|
||||
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
|
||||
/// <returns>The created <see cref="LibraryDeletedDomainEvent"/>.</returns>
|
||||
public LibraryDeletedDomainEvent Create(Guid? id = null, Library? library = null, DateTime? occurredOnUtc = null)
|
||||
{
|
||||
return new LibraryDeletedDomainEvent(
|
||||
id ?? Guid.NewGuid(),
|
||||
library ?? _libraryFixture.Create(),
|
||||
occurredOnUtc ?? DateTime.UtcNow);
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.Events;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibrarySavedDomainEvent"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibrarySavedDomainEventFixture
|
||||
{
|
||||
private readonly LibraryFixture _libraryFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibrarySavedDomainEvent"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the domain event.</param>
|
||||
/// <param name="library">Optional. The library that was created or updated.</param>
|
||||
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
|
||||
/// <returns>The created <see cref="LibrarySavedDomainEvent"/>.</returns>
|
||||
public LibrarySavedDomainEvent Create(Guid? id = null, Library? library = null, DateTime? occurredOnUtc = null)
|
||||
{
|
||||
return new LibrarySavedDomainEvent(
|
||||
id ?? Guid.NewGuid(),
|
||||
library ?? _libraryFixture.Create(),
|
||||
occurredOnUtc ?? DateTime.UtcNow);
|
||||
}
|
||||
}
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="Library"/> domain aggregate.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly LibraryIdFixture _libraryIdFixture = new();
|
||||
private readonly UserIdFixture _userIdFixture = new();
|
||||
private readonly ScanIdFixture _scanIdFixture = new();
|
||||
private readonly LibraryConsumptionSettingsFixture _libraryConsumptionSettingsFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="Library"/> domain aggregate.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The library Id.</param>
|
||||
/// <param name="userId">Optional. The Id of the user that owns the library.</param>
|
||||
/// <param name="title">Optional. The library title.</param>
|
||||
/// <param name="libraryType">Optional. The library type.</param>
|
||||
/// <param name="contentLocations">Optional. The content locations of the library.</param>
|
||||
/// <param name="coverImage">Optional. The cover image of the library.</param>
|
||||
/// <param name="isEnabled">Whether the library is enabled.</param>
|
||||
/// <param name="isLocked">Whether the library is locked.</param>
|
||||
/// <param name="canDownloadMetadataFromWeb">Whether metadata download from the web is enabled.</param>
|
||||
/// <param name="shouldSaveMetadataInMediaDirectories">Whether metadata should be saved in the media directories.</param>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Whether unchanged directories should be skipped during scan.</param>
|
||||
/// <param name="shouldSkipHiddenFilesAndDirectoriesDuringScan">Whether hidden files and directories should be skipped during scan.</param>
|
||||
/// <param name="isContentOnSsd">Whether the content of the library is stored on a solid state drive.</param>
|
||||
/// <param name="consumptionSettings">Optional. The consumption settings of the library.</param>
|
||||
/// <param name="scanIds">Optional. The scan Ids associated with the library.</param>
|
||||
/// <param name="pathTemplate">Optional. The path template of the library.</param>
|
||||
/// <param name="includeCoverImage">Whether the cover image should be included, or left unset, meaning the library has no cover.</param>
|
||||
/// <returns>The created <see cref="Library"/>.</returns>
|
||||
public Library Create(
|
||||
Guid? id = null,
|
||||
Guid? userId = null,
|
||||
string? title = null,
|
||||
LibraryType? libraryType = null,
|
||||
IEnumerable<string>? contentLocations = null,
|
||||
string? coverImage = null,
|
||||
bool isEnabled = true,
|
||||
bool isLocked = false,
|
||||
bool canDownloadMetadataFromWeb = true,
|
||||
bool shouldSaveMetadataInMediaDirectories = false,
|
||||
bool shouldSkipUnchangedDirectoriesDuringScan = false,
|
||||
bool shouldSkipHiddenFilesAndDirectoriesDuringScan = false,
|
||||
bool isContentOnSsd = false,
|
||||
LibraryConsumptionSettings? consumptionSettings = null,
|
||||
IEnumerable<Guid>? scanIds = null,
|
||||
LibraryPathTemplate? pathTemplate = null,
|
||||
bool includeCoverImage = true)
|
||||
{
|
||||
List<string> validPaths =
|
||||
[
|
||||
"C:/Media",
|
||||
"D:/Books",
|
||||
"E:/Digital Library",
|
||||
"F:/Content"
|
||||
];
|
||||
|
||||
UserId resolvedUserId = userId is null ? _userIdFixture.Create() : _userIdFixture.Create(userId.Value);
|
||||
LibraryType resolvedLibraryType = libraryType ?? _faker.PickRandom<LibraryType>();
|
||||
LibraryConsumptionSettings resolvedConsumptionSettings = consumptionSettings ?? _libraryConsumptionSettingsFixture.Create(resolvedLibraryType);
|
||||
List<ScanId> resolvedScanIds = scanIds is null ? [.. _scanIdFixture.CreateMany(2)] : [.. scanIds.Select(scanId => _scanIdFixture.Create(scanId))];
|
||||
string? resolvedCoverImage = includeCoverImage ? (coverImage ?? _faker.System.FilePath()) : null;
|
||||
|
||||
Result<Library> library = id is null ?
|
||||
Library.Create(
|
||||
resolvedUserId,
|
||||
title ?? _faker.Random.String2(_faker.Random.Number(1, 50)),
|
||||
resolvedLibraryType,
|
||||
contentLocations ?? validPaths.Take(Random.Shared.Next(1, validPaths.Count)),
|
||||
Optional<string>.FromNullable(resolvedCoverImage),
|
||||
isEnabled,
|
||||
isLocked,
|
||||
canDownloadMetadataFromWeb,
|
||||
shouldSaveMetadataInMediaDirectories,
|
||||
shouldSkipUnchangedDirectoriesDuringScan,
|
||||
shouldSkipHiddenFilesAndDirectoriesDuringScan,
|
||||
isContentOnSsd,
|
||||
resolvedConsumptionSettings,
|
||||
pathTemplate ?? LibraryPathTemplate.Empty(),
|
||||
resolvedScanIds
|
||||
) :
|
||||
Library.Create(
|
||||
_libraryIdFixture.Create(id.Value),
|
||||
resolvedUserId,
|
||||
title ?? _faker.Random.String2(_faker.Random.Number(1, 50)),
|
||||
resolvedLibraryType,
|
||||
contentLocations ?? validPaths.Take(Random.Shared.Next(1, validPaths.Count)),
|
||||
Optional<string>.FromNullable(resolvedCoverImage),
|
||||
isEnabled,
|
||||
isLocked,
|
||||
canDownloadMetadataFromWeb,
|
||||
shouldSaveMetadataInMediaDirectories,
|
||||
shouldSkipUnchangedDirectoriesDuringScan,
|
||||
shouldSkipHiddenFilesAndDirectoriesDuringScan,
|
||||
isContentOnSsd,
|
||||
resolvedConsumptionSettings,
|
||||
pathTemplate ?? LibraryPathTemplate.Empty(),
|
||||
resolvedScanIds
|
||||
);
|
||||
|
||||
return library.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="Library"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="Library"/> instances.</returns>
|
||||
public List<Library> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryConsumptionSettings"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryConsumptionSettingsFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a valid <see cref="LibraryConsumptionSettings"/>.
|
||||
/// </summary>
|
||||
/// <param name="shouldTrackConsumptionProgress">Optional. Whether the consumption progress is tracked. A random value is used when absent.</param>
|
||||
/// <param name="completionThresholdPercentage">Optional. The completion threshold percentage. A random value is used when absent and the threshold is included.</param>
|
||||
/// <param name="includeCompletionThreshold">Whether the completion threshold should be included. When <see langword="false"/>, no threshold is set.</param>
|
||||
/// <returns>The created consumption settings.</returns>
|
||||
public LibraryConsumptionSettings Create(
|
||||
bool? shouldTrackConsumptionProgress = null,
|
||||
int? completionThresholdPercentage = null,
|
||||
bool includeCompletionThreshold = true)
|
||||
{
|
||||
bool resolvedShouldTrackConsumptionProgress = shouldTrackConsumptionProgress ?? _faker.Random.Bool();
|
||||
Optional<int> resolvedCompletionThresholdPercentage = includeCompletionThreshold
|
||||
? Optional<int>.FromNullable(completionThresholdPercentage ?? _faker.Random.Int(0, 100))
|
||||
: Optional<int>.None();
|
||||
return LibraryConsumptionSettings.Create(resolvedShouldTrackConsumptionProgress, resolvedCompletionThresholdPercentage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the default <see cref="LibraryConsumptionSettings"/> for <paramref name="libraryType"/>.
|
||||
/// </summary>
|
||||
/// <param name="libraryType">The type of the media library for which to create the default consumption settings.</param>
|
||||
/// <returns>The default consumption settings of the media library type.</returns>
|
||||
public LibraryConsumptionSettings Create(LibraryType libraryType)
|
||||
{
|
||||
return LibraryConsumptionSettings.CreateDefault(libraryType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="LibraryConsumptionSettings"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="LibraryConsumptionSettings"/> instances.</returns>
|
||||
public List<LibraryConsumptionSettings> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+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())];
|
||||
}
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryPathPart"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryPathPartFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryPathPart"/>.
|
||||
/// </summary>
|
||||
/// <param name="kind">Optional. The kind of the path part.</param>
|
||||
/// <param name="representation">Optional. The literal text or the value mask of the path part. When omitted, a representation valid for the resolved kind is generated.</param>
|
||||
/// <param name="isOptional">Whether the path part can be absent from the path.</param>
|
||||
/// <returns>The created <see cref="LibraryPathPart"/>.</returns>
|
||||
public LibraryPathPart Create(
|
||||
LibraryPathPartKind? kind = null,
|
||||
string? representation = null,
|
||||
bool isOptional = false)
|
||||
{
|
||||
LibraryPathPartKind resolvedKind = kind ?? _faker.PickRandom<LibraryPathPartKind>();
|
||||
string resolvedRepresentation = representation ?? CreateValidRepresentation(resolvedKind);
|
||||
Result<LibraryPathPart> partResult = LibraryPathPart.Create(resolvedKind, resolvedRepresentation, isOptional);
|
||||
if (partResult.IsFailure)
|
||||
throw new InvalidOperationException("Failed to create LibraryPathPart: " + string.Join(", ", partResult.Errors));
|
||||
return partResult.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="LibraryPathPart"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="LibraryPathPart"/> instances.</returns>
|
||||
public List<LibraryPathPart> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a representation that is valid for the provided <paramref name="kind"/>.
|
||||
/// </summary>
|
||||
/// <param name="kind">The kind of the path part a representation is created for.</param>
|
||||
/// <returns>The created representation.</returns>
|
||||
private string CreateValidRepresentation(LibraryPathPartKind kind)
|
||||
{
|
||||
// A separator renders the platform path separator, so it never carries a representation.
|
||||
if (kind == LibraryPathPartKind.Separator)
|
||||
return string.Empty;
|
||||
// A literal is arbitrary on-disk text between value parts, so it carries no value placeholder.
|
||||
if (kind == LibraryPathPartKind.Literal)
|
||||
return _faker.Lorem.Word();
|
||||
// A typed part must carry exactly one value placeholder, so that the position of the captured value is unambiguous.
|
||||
return "{0}";
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryPathTemplate"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryPathTemplateFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly LibraryPathPartFixture _libraryPathPartFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryPathTemplate"/>.
|
||||
/// </summary>
|
||||
/// <param name="parts">Optional. The ordered parts that make up the path template.</param>
|
||||
/// <param name="includeParts">Whether the template should carry parts. When <see langword="false"/>, an empty template is created.</param>
|
||||
/// <returns>The created <see cref="LibraryPathTemplate"/>.</returns>
|
||||
public LibraryPathTemplate Create(
|
||||
IEnumerable<LibraryPathPart>? parts = null,
|
||||
bool includeParts = true)
|
||||
{
|
||||
if (!includeParts)
|
||||
return LibraryPathTemplate.Empty();
|
||||
return LibraryPathTemplate.Create(parts ?? _libraryPathPartFixture.CreateMany(_faker.Random.Int(1, 4)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="LibraryPathTemplate"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="LibraryPathTemplate"/> instances.</returns>
|
||||
public List<LibraryPathTemplate> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryMediaItemDeletedDomainEvent"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryMediaItemDeletedDomainEventFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly LibraryIdFixture _libraryIdFixture = new();
|
||||
private readonly MediaLibraryScanCompositeIdFixture _mediaLibraryScanCompositeIdFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryMediaItemDeletedDomainEvent"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the domain event.</param>
|
||||
/// <param name="libraryId">Optional. The unique identifier of the library to which the deleted media library item belonged.</param>
|
||||
/// <param name="mediaLibraryScanCompositeId">Optional. The composite identifier of the media library scan during which the item deletion was detected.</param>
|
||||
/// <param name="path">Optional. The path of the media library item that was deleted.</param>
|
||||
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
|
||||
/// <returns>The created <see cref="LibraryMediaItemDeletedDomainEvent"/>.</returns>
|
||||
public LibraryMediaItemDeletedDomainEvent Create(
|
||||
Guid? id = null,
|
||||
LibraryId? libraryId = null,
|
||||
MediaLibraryScanCompositeId? mediaLibraryScanCompositeId = null,
|
||||
string? path = null,
|
||||
DateTime? occurredOnUtc = null)
|
||||
{
|
||||
return new LibraryMediaItemDeletedDomainEvent(
|
||||
id ?? Guid.NewGuid(),
|
||||
libraryId ?? _libraryIdFixture.Create(),
|
||||
mediaLibraryScanCompositeId ?? _mediaLibraryScanCompositeIdFixture.Create(),
|
||||
path ?? _faker.System.FilePath(),
|
||||
occurredOnUtc ?? DateTime.UtcNow);
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryScanCancelledDomainEvent"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryScanCancelledDomainEventFixture
|
||||
{
|
||||
private readonly ScanIdFixture _scanIdFixture = new();
|
||||
private readonly LibraryIdFixture _libraryIdFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryScanCancelledDomainEvent"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the domain event.</param>
|
||||
/// <param name="scanId">Optional. The unique identifier of the cancelled media library scan.</param>
|
||||
/// <param name="libraryId">Optional. The unique identifier of the library whose scan was cancelled.</param>
|
||||
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
|
||||
/// <returns>The created <see cref="LibraryScanCancelledDomainEvent"/>.</returns>
|
||||
public LibraryScanCancelledDomainEvent Create(
|
||||
Guid? id = null,
|
||||
ScanId? scanId = null,
|
||||
LibraryId? libraryId = null,
|
||||
DateTime? occurredOnUtc = null)
|
||||
{
|
||||
return new LibraryScanCancelledDomainEvent(
|
||||
id ?? Guid.NewGuid(),
|
||||
scanId ?? _scanIdFixture.Create(),
|
||||
libraryId ?? _libraryIdFixture.Create(),
|
||||
occurredOnUtc ?? DateTime.UtcNow);
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryScanFailedDomainEvent"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryScanFailedDomainEventFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly LibraryIdFixture _libraryIdFixture = new();
|
||||
private readonly MediaLibraryScanCompositeIdFixture _mediaLibraryScanCompositeIdFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryScanFailedDomainEvent"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the domain event.</param>
|
||||
/// <param name="libraryId">Optional. The unique identifier of the library whose scan has failed.</param>
|
||||
/// <param name="mediaLibraryScanCompositeId">Optional. The composite identifier of the media library scan that has failed.</param>
|
||||
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
|
||||
/// <param name="errorMessage">Optional. The descriptive message of the failure.</param>
|
||||
/// <param name="includeErrorMessage">Whether the error message should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="LibraryScanFailedDomainEvent"/>.</returns>
|
||||
public LibraryScanFailedDomainEvent Create(
|
||||
Guid? id = null,
|
||||
LibraryId? libraryId = null,
|
||||
MediaLibraryScanCompositeId? mediaLibraryScanCompositeId = null,
|
||||
DateTime? occurredOnUtc = null,
|
||||
string? errorMessage = null,
|
||||
bool includeErrorMessage = true)
|
||||
{
|
||||
return new LibraryScanFailedDomainEvent(
|
||||
id ?? Guid.NewGuid(),
|
||||
libraryId ?? _libraryIdFixture.Create(),
|
||||
mediaLibraryScanCompositeId ?? _mediaLibraryScanCompositeIdFixture.Create(),
|
||||
occurredOnUtc ?? DateTime.UtcNow,
|
||||
Optional<string>.FromNullable(includeErrorMessage ? (errorMessage ?? _faker.Random.Words()) : null));
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryScanFinishedDomainEvent"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryScanFinishedDomainEventFixture
|
||||
{
|
||||
private readonly MediaLibraryScanCompositeIdFixture _mediaLibraryScanCompositeIdFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryScanFinishedDomainEvent"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the domain event.</param>
|
||||
/// <param name="mediaLibraryScanCompositeId">Optional. The composite identifier of the media library scan that was finished.</param>
|
||||
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
|
||||
/// <returns>The created <see cref="LibraryScanFinishedDomainEvent"/>.</returns>
|
||||
public LibraryScanFinishedDomainEvent Create(
|
||||
Guid? id = null,
|
||||
MediaLibraryScanCompositeId? mediaLibraryScanCompositeId = null,
|
||||
DateTime? occurredOnUtc = null)
|
||||
{
|
||||
return new LibraryScanFinishedDomainEvent(
|
||||
id ?? Guid.NewGuid(),
|
||||
mediaLibraryScanCompositeId ?? _mediaLibraryScanCompositeIdFixture.Create(),
|
||||
occurredOnUtc ?? DateTime.UtcNow);
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryScanJobProgressChangedDomainEvent"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryScanJobProgressChangedDomainEventFixture
|
||||
{
|
||||
private readonly LibraryIdFixture _libraryIdFixture = new();
|
||||
private readonly MediaLibraryScanCompositeIdFixture _mediaLibraryScanCompositeIdFixture = new();
|
||||
private readonly MediaLibraryScanJobProgressFixture _mediaLibraryScanJobProgressFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryScanJobProgressChangedDomainEvent"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the domain event.</param>
|
||||
/// <param name="libraryId">Optional. The unique identifier of the library being scanned.</param>
|
||||
/// <param name="mediaLibraryScanCompositeId">Optional. The composite identifier of the media library scan whose job progress changed.</param>
|
||||
/// <param name="progress">Optional. The new media library scan job progress.</param>
|
||||
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
|
||||
/// <returns>The created <see cref="LibraryScanJobProgressChangedDomainEvent"/>.</returns>
|
||||
public LibraryScanJobProgressChangedDomainEvent Create(
|
||||
Guid? id = null,
|
||||
LibraryId? libraryId = null,
|
||||
MediaLibraryScanCompositeId? mediaLibraryScanCompositeId = null,
|
||||
MediaLibraryScanJobProgress? progress = null,
|
||||
DateTime? occurredOnUtc = null)
|
||||
{
|
||||
return new LibraryScanJobProgressChangedDomainEvent(
|
||||
id ?? Guid.NewGuid(),
|
||||
libraryId ?? _libraryIdFixture.Create(),
|
||||
mediaLibraryScanCompositeId ?? _mediaLibraryScanCompositeIdFixture.Create(),
|
||||
progress ?? _mediaLibraryScanJobProgressFixture.Create(),
|
||||
occurredOnUtc ?? DateTime.UtcNow);
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryScanProgressChangedDomainEvent"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryScanProgressChangedDomainEventFixture
|
||||
{
|
||||
private readonly LibraryIdFixture _libraryIdFixture = new();
|
||||
private readonly MediaLibraryScanCompositeIdFixture _mediaLibraryScanCompositeIdFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryScanProgressChangedDomainEvent"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the domain event.</param>
|
||||
/// <param name="libraryId">Optional. The unique identifier of the library being scanned.</param>
|
||||
/// <param name="mediaLibraryScanCompositeId">Optional. The composite identifier of the media library scan whose progress changed.</param>
|
||||
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
|
||||
/// <returns>The created <see cref="LibraryScanProgressChangedDomainEvent"/>.</returns>
|
||||
public LibraryScanProgressChangedDomainEvent Create(
|
||||
Guid? id = null,
|
||||
LibraryId? libraryId = null,
|
||||
MediaLibraryScanCompositeId? mediaLibraryScanCompositeId = null,
|
||||
DateTime? occurredOnUtc = null)
|
||||
{
|
||||
return new LibraryScanProgressChangedDomainEvent(
|
||||
id ?? Guid.NewGuid(),
|
||||
libraryId ?? _libraryIdFixture.Create(),
|
||||
mediaLibraryScanCompositeId ?? _mediaLibraryScanCompositeIdFixture.Create(),
|
||||
occurredOnUtc ?? DateTime.UtcNow);
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryScanQueuedDomainEvent"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryScanQueuedDomainEventFixture
|
||||
{
|
||||
private readonly ScanIdFixture _scanIdFixture = new();
|
||||
private readonly UserIdFixture _userIdFixture = new();
|
||||
private readonly LibraryIdFixture _libraryIdFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryScanQueuedDomainEvent"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the domain event.</param>
|
||||
/// <param name="scanId">Optional. The unique identifier of the queued media library scan.</param>
|
||||
/// <param name="userId">Optional. The unique identifier of the user that initiated the queued media library scan.</param>
|
||||
/// <param name="libraryId">Optional. The unique identifier of the library whose scan was queued.</param>
|
||||
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
|
||||
/// <returns>The created <see cref="LibraryScanQueuedDomainEvent"/>.</returns>
|
||||
public LibraryScanQueuedDomainEvent Create(
|
||||
Guid? id = null,
|
||||
ScanId? scanId = null,
|
||||
UserId? userId = null,
|
||||
LibraryId? libraryId = null,
|
||||
DateTime? occurredOnUtc = null)
|
||||
{
|
||||
return new LibraryScanQueuedDomainEvent(
|
||||
id ?? Guid.NewGuid(),
|
||||
scanId ?? _scanIdFixture.Create(),
|
||||
userId ?? _userIdFixture.Create(),
|
||||
libraryId ?? _libraryIdFixture.Create(),
|
||||
occurredOnUtc ?? DateTime.UtcNow);
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryScanStartedDomainEvent"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryScanStartedDomainEventFixture
|
||||
{
|
||||
private readonly LibraryScanFixture _libraryScanFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryScanStartedDomainEvent"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the domain event.</param>
|
||||
/// <param name="libraryScan">Optional. The library scan that was started.</param>
|
||||
/// <param name="occurredOnUtc">Optional. The date and time when the domain event occurred.</param>
|
||||
/// <returns>The created <see cref="LibraryScanStartedDomainEvent"/>.</returns>
|
||||
public LibraryScanStartedDomainEvent Create(Guid? id = null, LibraryScan? libraryScan = null, DateTime? occurredOnUtc = null)
|
||||
{
|
||||
return new LibraryScanStartedDomainEvent(
|
||||
id ?? Guid.NewGuid(),
|
||||
libraryScan ?? _libraryScanFixture.Create(),
|
||||
occurredOnUtc ?? DateTime.UtcNow);
|
||||
}
|
||||
}
|
||||
+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())];
|
||||
}
|
||||
}
|
||||
+134
@@ -0,0 +1,134 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Jobs;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Jobs;
|
||||
|
||||
/// <summary>
|
||||
/// Controllable test double for the <see cref="IMediaLibraryScanDiscoveryJob"/> interface.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public sealed class FakeMediaLibraryScanDiscoveryJob : IMediaLibraryScanDiscoveryJob
|
||||
{
|
||||
private readonly TaskCompletionSource _executionStarted = new(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
private readonly TaskCompletionSource _executionCompleted = new(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the media library scan that this job is part of.
|
||||
/// </summary>
|
||||
public required ScanId ScanId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Id of the user that initiated the media library scan that this job is part of.
|
||||
/// </summary>
|
||||
public required UserId UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the unique identifier of the media library upon which the scan is performed.
|
||||
/// </summary>
|
||||
public required LibraryId LibraryId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of child media scan jobs that will be triggered when this job's payload completes execution.
|
||||
/// </summary>
|
||||
public List<IMediaLibraryScanJob> Children { get; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of parent media scan jobs that will trigger this job when their payload will complete execution.
|
||||
/// </summary>
|
||||
public List<IMediaLibraryScanJob> Parents { get; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the status of the current media library scan job.
|
||||
/// </summary>
|
||||
public LibraryScanJobStatus Status { get; private set; } = LibraryScanJobStatus.Pending;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of times this job was executed.
|
||||
/// </summary>
|
||||
public int ExecutionCount { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this job is currently executing.
|
||||
/// </summary>
|
||||
public bool IsExecuting { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Id this job was last executed with.
|
||||
/// </summary>
|
||||
public Guid? LastExecutionId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the cancellation token this job was last executed with.
|
||||
/// </summary>
|
||||
public CancellationToken LastCancellationToken { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the optional callback invoked while the job executes, allowing a test to block or throw.
|
||||
/// </summary>
|
||||
public Func<CancellationToken, Task>? OnExecute { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a task that completes as soon as the job starts executing.
|
||||
/// </summary>
|
||||
public Task ExecutionStarted => _executionStarted.Task;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a task that completes as soon as the job finishes executing successfully.
|
||||
/// </summary>
|
||||
public Task ExecutionCompleted => _executionCompleted.Task;
|
||||
|
||||
/// <summary>
|
||||
/// Adds a media library scan job to the list of child media library scan jobs that will be triggered when this job's payload completes execution.
|
||||
/// </summary>
|
||||
/// <param name="job">The child media library scan job to be added.</param>
|
||||
public void AddChild(IMediaLibraryScanJob job)
|
||||
{
|
||||
if (!Children.Contains(job) && !Parents.Contains(job))
|
||||
Children.Add(job);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a media library scan job to the list of parent media library scan jobs that will trigger this job when their payload will complete execution.
|
||||
/// </summary>
|
||||
/// <param name="job">The child media library scan job to be added.</param>
|
||||
public void AddParent(IMediaLibraryScanJob job)
|
||||
{
|
||||
if (!Parents.Contains(job) && !Children.Contains(job))
|
||||
Parents.Add(job);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes the payload of the media library scan job.
|
||||
/// </summary>
|
||||
/// <typeparam name="TInput">The type of the input parameter representing the data to be processed by this payload.</typeparam>
|
||||
/// <param name="id">The id of the media library scan job.</param>
|
||||
/// <param name="input">The input data to be processed by this payload.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
public async Task ExecuteAsync<TInput>(Guid id, TInput input, CancellationToken cancellationToken)
|
||||
{
|
||||
ExecutionCount++;
|
||||
LastExecutionId = id;
|
||||
LastCancellationToken = cancellationToken;
|
||||
IsExecuting = true;
|
||||
Status = LibraryScanJobStatus.Running;
|
||||
_executionStarted.TrySetResult();
|
||||
|
||||
if (OnExecute is not null)
|
||||
await OnExecute(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
Status = LibraryScanJobStatus.Completed;
|
||||
IsExecuting = false;
|
||||
_executionCompleted.TrySetResult();
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Jobs;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.Fixtures.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Jobs;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="IMediaLibraryScanDiscoveryJob"/> interface.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaLibraryScanDiscoveryJobFixture
|
||||
{
|
||||
private readonly ScanIdFixture _scanIdFixture = new();
|
||||
private readonly UserIdFixture _userIdFixture = new();
|
||||
private readonly LibraryIdFixture _libraryIdFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a controllable <see cref="FakeMediaLibraryScanDiscoveryJob"/>.
|
||||
/// </summary>
|
||||
/// <param name="scanId">Optional. The Id of the media library scan that the job is part of.</param>
|
||||
/// <param name="userId">Optional. The Id of the user that initiated the media library scan.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the media library that is scanned.</param>
|
||||
/// <param name="children">Optional. The child jobs of the created job.</param>
|
||||
/// <param name="onExecute">Optional. The callback invoked while the job executes.</param>
|
||||
/// <returns>The created <see cref="FakeMediaLibraryScanDiscoveryJob"/>.</returns>
|
||||
public FakeMediaLibraryScanDiscoveryJob Create(
|
||||
ScanId? scanId = null,
|
||||
UserId? userId = null,
|
||||
LibraryId? libraryId = null,
|
||||
List<IMediaLibraryScanJob>? children = null,
|
||||
Func<CancellationToken, Task>? onExecute = null)
|
||||
{
|
||||
FakeMediaLibraryScanDiscoveryJob job = new()
|
||||
{
|
||||
ScanId = scanId ?? _scanIdFixture.Create(),
|
||||
UserId = userId ?? _userIdFixture.Create(),
|
||||
LibraryId = libraryId ?? _libraryIdFixture.Create(),
|
||||
OnExecute = onExecute
|
||||
};
|
||||
|
||||
foreach (IMediaLibraryScanJob child in children ?? [])
|
||||
job.AddChild(child);
|
||||
|
||||
return job;
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryPathPartDefinition"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryPathPartDefinitionFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryPathPartDefinition"/>.
|
||||
/// </summary>
|
||||
/// <param name="kind">Optional. The kind of the described part.</param>
|
||||
/// <param name="valueType">Optional. The value type captured by the described part.</param>
|
||||
/// <param name="defaultRepresentation">Optional. The default representation of the described part.</param>
|
||||
/// <param name="isOptionalByDefault">Whether the described part is optional by default.</param>
|
||||
/// <returns>The created <see cref="LibraryPathPartDefinition"/>.</returns>
|
||||
public LibraryPathPartDefinition Create(
|
||||
LibraryPathPartKind? kind = null,
|
||||
LibraryPathValueType? valueType = null,
|
||||
string? defaultRepresentation = null,
|
||||
bool isOptionalByDefault = false)
|
||||
{
|
||||
return new LibraryPathPartDefinition(
|
||||
kind ?? _faker.PickRandom<LibraryPathPartKind>(),
|
||||
valueType ?? _faker.PickRandom<LibraryPathValueType>(),
|
||||
defaultRepresentation ?? "{0}",
|
||||
isOptionalByDefault);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="LibraryPathPartDefinition"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="LibraryPathPartDefinition"/> instances.</returns>
|
||||
public List<LibraryPathPartDefinition> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+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())];
|
||||
}
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ParsedLibraryPath"/> domain value object.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ParsedLibraryPathFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ParsedLibraryPath"/>.
|
||||
/// </summary>
|
||||
/// <param name="values">Optional. The captured values, keyed by their part kind.</param>
|
||||
/// <param name="includeValues">Whether the parsed path should carry captured values. When <see langword="false"/>, an empty set of values is created.</param>
|
||||
/// <returns>The created <see cref="ParsedLibraryPath"/>.</returns>
|
||||
public ParsedLibraryPath Create(
|
||||
IReadOnlyDictionary<LibraryPathPartKind, string>? values = null,
|
||||
bool includeValues = true)
|
||||
{
|
||||
if (!includeValues)
|
||||
return ParsedLibraryPath.Create(new Dictionary<LibraryPathPartKind, string>());
|
||||
return ParsedLibraryPath.Create(values ?? CreateRandomValues());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="ParsedLibraryPath"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ParsedLibraryPath"/> instances.</returns>
|
||||
public List<ParsedLibraryPath> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a bounded set of random captured values.
|
||||
/// </summary>
|
||||
/// <returns>The captured values, keyed by their part kind.</returns>
|
||||
private Dictionary<LibraryPathPartKind, string> CreateRandomValues()
|
||||
{
|
||||
LibraryPathPartKind[] candidateKinds =
|
||||
[
|
||||
LibraryPathPartKind.Artist,
|
||||
LibraryPathPartKind.ReleaseName,
|
||||
LibraryPathPartKind.TrackName,
|
||||
LibraryPathPartKind.Title,
|
||||
LibraryPathPartKind.Author
|
||||
];
|
||||
|
||||
Dictionary<LibraryPathPartKind, string> values = [];
|
||||
foreach (LibraryPathPartKind kind in candidateKinds.Take(_faker.Random.Int(1, candidateKinds.Length)))
|
||||
values[kind] = _faker.Lorem.Word();
|
||||
return values;
|
||||
}
|
||||
}
|
||||
+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())];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user