Hardens test assertions and adds missing test coverage.

This commit is contained in:
BinaryAlley committed 2026-08-18 08:28:16 -07:00
1 parent 6b86fd5805
commit 1189bbaf36
489 files changed
+39982 -512

No files matched your search

@@ -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,
@@ -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())];
}
}
@@ -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())];
}
}
@@ -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())];
}
}
@@ -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())];
}
}
@@ -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())];
}
}
@@ -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())];
}
}