mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 18: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
+79
@@ -0,0 +1,79 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.Management;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryResponseFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the media library.</param>
|
||||
/// <param name="userId">Optional. The Id of the user owning the media library.</param>
|
||||
/// <param name="title">Optional. The title of the media library.</param>
|
||||
/// <param name="libraryType">Optional. The type of the media library.</param>
|
||||
/// <param name="contentLocations">Optional. The file system paths of the media library content directories.</param>
|
||||
/// <param name="coverImage">Optional. The path of the image file used as the cover of the library.</param>
|
||||
/// <param name="isEnabled">Optional. Whether the media library is enabled.</param>
|
||||
/// <param name="isLocked">Optional. Whether the media library is locked.</param>
|
||||
/// <param name="downloadMetadataFromWeb">Optional. Whether metadata should be downloaded from the web.</param>
|
||||
/// <param name="shouldSaveMetadataInMediaDirectories">Optional. Whether metadata should be saved in the media directories.</param>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Optional. Whether unchanged directories should be skipped during scan.</param>
|
||||
/// <param name="createdOnUtc">Optional. The date and time when the library was created.</param>
|
||||
/// <param name="updatedOnUtc">Optional. The date and time when the library was updated.</param>
|
||||
/// <returns>The created <see cref="LibraryResponse"/>.</returns>
|
||||
public LibraryResponse Create(
|
||||
Guid? id = null,
|
||||
Guid? userId = null,
|
||||
string? title = null,
|
||||
LibraryType? libraryType = null,
|
||||
List<string>? contentLocations = null,
|
||||
string? coverImage = null,
|
||||
bool? isEnabled = null,
|
||||
bool? isLocked = null,
|
||||
bool? downloadMetadataFromWeb = null,
|
||||
bool? shouldSaveMetadataInMediaDirectories = null,
|
||||
bool? shouldSkipUnchangedDirectoriesDuringScan = null,
|
||||
DateTime? createdOnUtc = null,
|
||||
DateTime? updatedOnUtc = null)
|
||||
{
|
||||
return new LibraryResponse(
|
||||
id ?? Guid.NewGuid(),
|
||||
userId ?? Guid.NewGuid(),
|
||||
title ?? _faker.Commerce.Department(),
|
||||
libraryType ?? _faker.PickRandom<LibraryType>(),
|
||||
contentLocations ?? [_faker.System.DirectoryPath(), _faker.System.DirectoryPath()],
|
||||
coverImage,
|
||||
isEnabled ?? _faker.Random.Bool(),
|
||||
isLocked ?? _faker.Random.Bool(),
|
||||
downloadMetadataFromWeb ?? _faker.Random.Bool(),
|
||||
shouldSaveMetadataInMediaDirectories ?? _faker.Random.Bool(),
|
||||
shouldSkipUnchangedDirectoriesDuringScan ?? _faker.Random.Bool(),
|
||||
createdOnUtc ?? _faker.Date.Past().ToUniversalTime(),
|
||||
updatedOnUtc
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="LibraryResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<LibraryResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.Management;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MediaLibraryScanJobProgressResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaLibraryScanJobProgressResponseFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MediaLibraryScanJobProgressResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="completedItems">Optional. The number of processed scan job items.</param>
|
||||
/// <param name="totalItems">Optional. The total number of scan job items.</param>
|
||||
/// <param name="currentOperation">Optional. The current processing operation in the scan job.</param>
|
||||
/// <param name="progressPercentage">Optional. The progress percentage of the scan job.</param>
|
||||
/// <returns>The created <see cref="MediaLibraryScanJobProgressResponse"/>.</returns>
|
||||
public MediaLibraryScanJobProgressResponse Create(
|
||||
int? completedItems = null,
|
||||
int? totalItems = null,
|
||||
string? currentOperation = null,
|
||||
decimal? progressPercentage = null)
|
||||
{
|
||||
return new MediaLibraryScanJobProgressResponse(
|
||||
completedItems ?? _faker.Random.Int(0, 100),
|
||||
totalItems ?? _faker.Random.Int(100, 1000),
|
||||
currentOperation ?? _faker.Lorem.Word(),
|
||||
progressPercentage ?? _faker.Random.Decimal(0m, 100m)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="MediaLibraryScanJobProgressResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<MediaLibraryScanJobProgressResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.Management;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MediaLibraryScanProgressResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaLibraryScanProgressResponseFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
private readonly MediaLibraryScanJobProgressResponseFixture _mediaLibraryScanJobProgressResponseFixture = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MediaLibraryScanProgressResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="scanId">Optional. The Id of the media library scan.</param>
|
||||
/// <param name="userId">Optional. The Id of the user initiating the media library scan.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the media library that is scanned.</param>
|
||||
/// <param name="totalJobs">Optional. The total number of jobs to be processed by the scan.</param>
|
||||
/// <param name="completedJobs">Optional. The number of jobs that have been processed.</param>
|
||||
/// <param name="currentJobProgress">Optional. The progress of the currently processing job.</param>
|
||||
/// <param name="status">Optional. The status of the scan.</param>
|
||||
/// <param name="overallProgressPercentage">Optional. The overall progress percentage of the scan.</param>
|
||||
/// <returns>The created <see cref="MediaLibraryScanProgressResponse"/>.</returns>
|
||||
public MediaLibraryScanProgressResponse Create(
|
||||
Guid? scanId = null,
|
||||
Guid? userId = null,
|
||||
Guid? libraryId = null,
|
||||
int? totalJobs = null,
|
||||
int? completedJobs = null,
|
||||
MediaLibraryScanJobProgressResponse? currentJobProgress = null,
|
||||
string? status = null,
|
||||
decimal? overallProgressPercentage = null)
|
||||
{
|
||||
return new MediaLibraryScanProgressResponse(
|
||||
scanId ?? Guid.NewGuid(),
|
||||
userId ?? Guid.NewGuid(),
|
||||
libraryId ?? Guid.NewGuid(),
|
||||
totalJobs ?? _faker.Random.Int(1, 10),
|
||||
completedJobs ?? _faker.Random.Int(0, 10),
|
||||
currentJobProgress ?? _mediaLibraryScanJobProgressResponseFixture.Create(),
|
||||
status ?? _faker.Lorem.Word(),
|
||||
overallProgressPercentage ?? _faker.Random.Decimal(0m, 100m)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="MediaLibraryScanProgressResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<MediaLibraryScanProgressResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="BookLiteResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class BookLiteResponseFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="BookLiteResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the book.</param>
|
||||
/// <param name="title">Optional. The title of the book.</param>
|
||||
/// <param name="releaseYear">Optional. The release year of the book.</param>
|
||||
/// <param name="coverPath">Optional. The path of the image representing the cover of the book.</param>
|
||||
/// <returns>The created <see cref="BookLiteResponse"/>.</returns>
|
||||
public BookLiteResponse Create(
|
||||
Guid? id = null,
|
||||
string? title = null,
|
||||
int? releaseYear = null,
|
||||
string? coverPath = null)
|
||||
{
|
||||
return new BookLiteResponse(
|
||||
id ?? Guid.NewGuid(),
|
||||
title ?? _faker.Commerce.ProductName(),
|
||||
releaseYear ?? _faker.Random.Int(1900, 2024),
|
||||
coverPath ?? _faker.System.FilePath()
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="BookLiteResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<BookLiteResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using Lumina.Contracts.DTO.MediaContributors;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="BookResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class BookResponseFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="BookResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the book.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the media library the book belongs to.</param>
|
||||
/// <param name="path">Optional. The file system path of the book.</param>
|
||||
/// <param name="metadata">Optional. The written content metadata of the book.</param>
|
||||
/// <param name="format">Optional. The format of the book.</param>
|
||||
/// <param name="metadataStatus">Optional. The metadata enrichment status of the book.</param>
|
||||
/// <param name="createdOnUtc">Optional. The date and time when the book was created.</param>
|
||||
/// <returns>The created <see cref="BookResponse"/>.</returns>
|
||||
public BookResponse Create(
|
||||
Guid? id = null,
|
||||
Guid? libraryId = null,
|
||||
string? path = null,
|
||||
WrittenContentMetadataDto? metadata = null,
|
||||
BookFormat? format = null,
|
||||
MetadataStatus? metadataStatus = null,
|
||||
DateTime? createdOnUtc = null)
|
||||
{
|
||||
DateTime resolvedCreatedOnUtc = createdOnUtc ?? _faker.Date.Past().ToUniversalTime();
|
||||
return new BookResponse(
|
||||
id ?? Guid.NewGuid(),
|
||||
libraryId ?? Guid.NewGuid(),
|
||||
path ?? _faker.System.FilePath(),
|
||||
metadata ?? CreateMetadata(),
|
||||
format ?? _faker.PickRandom<BookFormat>(),
|
||||
_faker.Lorem.Word(),
|
||||
_faker.Random.Int(1, 10),
|
||||
new BookSeriesDto(_faker.Lorem.Word()),
|
||||
_faker.Random.AlphaNumeric(10),
|
||||
_faker.Random.AlphaNumeric(5),
|
||||
_faker.Random.AlphaNumeric(8),
|
||||
_faker.Random.AlphaNumeric(10),
|
||||
_faker.Random.AlphaNumeric(7),
|
||||
_faker.Random.AlphaNumeric(7),
|
||||
_faker.Random.AlphaNumeric(6),
|
||||
_faker.Random.AlphaNumeric(10),
|
||||
_faker.Random.AlphaNumeric(8),
|
||||
[new IsbnDto(_faker.Random.Replace("###-#-##-#####-#"), IsbnFormat.Isbn13)],
|
||||
[new MediaContributorDto(
|
||||
new MediaContributorNameDto(_faker.Name.FullName(), _faker.Name.FullName()),
|
||||
new MediaContributorRoleDto(_faker.Commerce.ProductAdjective(), _faker.Commerce.Department()))],
|
||||
[new BookRatingDto(_faker.Random.Decimal(1m, 5m), 5m, BookRatingSource.Goodreads, _faker.Random.Int(1, 1000))],
|
||||
metadataStatus ?? _faker.PickRandom<MetadataStatus>(),
|
||||
_faker.Date.Recent().ToUniversalTime(),
|
||||
_faker.Company.CompanyName(),
|
||||
resolvedCreatedOnUtc,
|
||||
_faker.Random.Bool() ? _faker.Date.Recent().ToUniversalTime() : null
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="BookResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<BookResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
|
||||
private WrittenContentMetadataDto CreateMetadata()
|
||||
{
|
||||
return new WrittenContentMetadataDto(
|
||||
_faker.Lorem.Sentence(3),
|
||||
_faker.Lorem.Sentence(3),
|
||||
_faker.Lorem.Paragraph(),
|
||||
new ReleaseInfoDto(_faker.Date.PastDateOnly(), _faker.Random.Int(1900, 2024), null, null, _faker.Address.CountryCode(), null),
|
||||
[new GenreDto(_faker.Lorem.Word())],
|
||||
[new TagDto(_faker.Lorem.Word())],
|
||||
new LanguageInfoDto("en", "English", "English"),
|
||||
null,
|
||||
_faker.Company.CompanyName(),
|
||||
_faker.Random.Int(100, 1000)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user