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

@@ -0,0 +1,46 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.Authentication;
using Lumina.Domain.SharedKernel.Common.Enums.Authorization;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.DTO.Authentication;
/// <summary>
/// Fixture class for the <see cref="PermissionDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class PermissionDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="PermissionDto"/>.
/// </summary>
/// <param name="id">Optional. The Id of the permission.</param>
/// <param name="permissionName">Optional. The name of the permission.</param>
/// <returns>The created <see cref="PermissionDto"/>.</returns>
public PermissionDto Create(
Guid? id = null,
AuthorizationPermission? permissionName = null)
{
return new PermissionDto(
id ?? Guid.NewGuid(),
permissionName ?? _faker.PickRandom<AuthorizationPermission>()
);
}
/// <summary>
/// Creates a list of <see cref="PermissionDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<PermissionDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,44 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.Authentication;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.DTO.Authentication;
/// <summary>
/// Fixture class for the <see cref="RoleDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class RoleDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="RoleDto"/>.
/// </summary>
/// <param name="id">Optional. The unique identifier of the role.</param>
/// <param name="roleName">Optional. The name of the role.</param>
/// <returns>The created <see cref="RoleDto"/>.</returns>
public RoleDto Create(
Guid? id = null,
string? roleName = null)
{
return new RoleDto(
id ?? Guid.NewGuid(),
roleName ?? _faker.Lorem.Word());
}
/// <summary>
/// Creates a list of <see cref="RoleDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<RoleDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,86 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.Common;
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
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.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
/// <summary>
/// Fixture class for the <see cref="BookMetadataDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class BookMetadataDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="BookMetadataDto"/>.
/// </summary>
/// <param name="title">Optional. The title of the book.</param>
/// <param name="originalTitle">Optional. The original title of the book.</param>
/// <param name="description">Optional. A brief description or summary of the book.</param>
/// <param name="goodreadsId">Optional. The Goodreads ID of the book.</param>
/// <param name="format">Optional. The format of the book.</param>
/// <param name="publisher">Optional. The name of the publisher of the book.</param>
/// <param name="pageCount">Optional. The number of pages in the book.</param>
/// <param name="includeOptionalProperties">Whether optional properties should be included.</param>
/// <returns>The created <see cref="BookMetadataDto"/>.</returns>
public BookMetadataDto Create(
string? title = null,
string? originalTitle = null,
string? description = null,
string? goodreadsId = null,
BookFormat? format = null,
string? publisher = null,
int? pageCount = null,
bool includeOptionalProperties = true)
{
int releaseYear = _faker.Random.Int(1900, 2024);
return new BookMetadataDto(
title ?? _faker.Lorem.Sentence(3),
originalTitle,
description,
includeOptionalProperties
? new ReleaseInfoDto(new DateOnly(releaseYear, 1, 1), releaseYear, null, null, _faker.Address.CountryCode(), null)
: null,
includeOptionalProperties ? [new GenreDto(_faker.Lorem.Word())] : null,
includeOptionalProperties ? [new TagDto(_faker.Lorem.Word())] : null,
includeOptionalProperties ? new LanguageInfoDto("en", "English", "English") : null,
null,
publisher,
pageCount,
format ?? _faker.PickRandom<BookFormat>(),
null,
includeOptionalProperties ? _faker.Random.Int(1, 10) : null,
null,
null,
goodreadsId,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null);
}
/// <summary>
/// Creates a list of <see cref="BookMetadataDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<BookMetadataDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,59 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
/// <summary>
/// Fixture class for the <see cref="BookMetadataLookupDto"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class BookMetadataLookupDtoFixture
{
private readonly Faker _faker = new();
/// <summary>
/// Creates a random valid <see cref="BookMetadataLookupDto"/>.
/// </summary>
/// <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="isbn">Optional. The ISBN of the book.</param>
/// <param name="openLibraryId">Optional. The Open Library ID of the book.</param>
/// <param name="title">Optional. The title of the book.</param>
/// <param name="author">Optional. The author of the book.</param>
/// <param name="languageCode">Optional. The language code of the book.</param>
/// <returns>The created <see cref="BookMetadataLookupDto"/>.</returns>
public BookMetadataLookupDto Create(
Guid? libraryId = null,
string? path = null,
string? isbn = null,
string? openLibraryId = null,
string? title = null,
string? author = null,
string? languageCode = null)
{
return new BookMetadataLookupDto(
libraryId ?? Guid.NewGuid(),
path ?? _faker.System.FilePath(),
isbn,
openLibraryId,
title,
author,
languageCode);
}
/// <summary>
/// Creates a list of <see cref="BookMetadataLookupDto"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<BookMetadataLookupDto> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}