mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 19:21:10 +00:00
Merge branch 'refactor/standardize-test-fixtures-and-docs' into feature/add-artwork-provider-and-metadata-aggregation
This commit is contained in:
commit
4ff184d8a5
388 files changed
+13829
-2814
No files matched your search
+39
@@ -0,0 +1,39 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Responses.Authentication;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Responses.Authentication;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="ChangePasswordResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ChangePasswordResponseFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ChangePasswordResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="isPasswordChanged">Optional. Whether the password was changed.</param>
|
||||
/// <returns>The created <see cref="ChangePasswordResponse"/>.</returns>
|
||||
public ChangePasswordResponse Create(
|
||||
bool? isPasswordChanged = null)
|
||||
{
|
||||
return new ChangePasswordResponse(isPasswordChanged ?? _faker.Random.Bool());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="ChangePasswordResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<ChangePasswordResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Responses.Authentication;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Responses.Authentication;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LoginResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LoginResponseFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LoginResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the authenticated user.</param>
|
||||
/// <param name="username">Optional. The username of the authenticated user.</param>
|
||||
/// <param name="token">Optional. The authentication token of the user.</param>
|
||||
/// <param name="usesTotp">Optional. Whether the user uses two-factor authentication.</param>
|
||||
/// <returns>The created <see cref="LoginResponse"/>.</returns>
|
||||
public LoginResponse Create(
|
||||
Guid? id = null,
|
||||
string? username = null,
|
||||
string? token = null,
|
||||
bool? usesTotp = null)
|
||||
{
|
||||
return new LoginResponse(
|
||||
id ?? Guid.NewGuid(),
|
||||
username ?? _faker.Internet.UserName(),
|
||||
token ?? _faker.Random.Hexadecimal(32),
|
||||
usesTotp ?? _faker.Random.Bool());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="LoginResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<LoginResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Responses.Authentication;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Responses.Authentication;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="RecoverPasswordResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class RecoverPasswordResponseFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="RecoverPasswordResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="isPasswordReset">Optional. Whether the password was reset.</param>
|
||||
/// <returns>The created <see cref="RecoverPasswordResponse"/>.</returns>
|
||||
public RecoverPasswordResponse Create(
|
||||
bool? isPasswordReset = null)
|
||||
{
|
||||
return new RecoverPasswordResponse(isPasswordReset ?? _faker.Random.Bool());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="RecoverPasswordResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<RecoverPasswordResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Responses.Authorization;
|
||||
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.Responses.Authorization;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="AuthorizationResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AuthorizationResponseFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="AuthorizationResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="userId">Optional. The Id of the user.</param>
|
||||
/// <param name="role">Optional. The role of the user.</param>
|
||||
/// <param name="permissions">Optional. The permissions of the user.</param>
|
||||
/// <returns>The created <see cref="AuthorizationResponse"/>.</returns>
|
||||
public AuthorizationResponse Create(
|
||||
Guid? userId = null,
|
||||
string? role = null,
|
||||
IReadOnlySet<AuthorizationPermission>? permissions = null)
|
||||
{
|
||||
return new AuthorizationResponse(
|
||||
userId ?? Guid.NewGuid(),
|
||||
role,
|
||||
permissions ?? new HashSet<AuthorizationPermission>());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="AuthorizationResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<AuthorizationResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Responses.Authorization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Responses.Authorization;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="RoleResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class RoleResponseFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="RoleResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional. The Id of the role.</param>
|
||||
/// <param name="roleName">Optional. The name of the role.</param>
|
||||
/// <returns>The created <see cref="RoleResponse"/>.</returns>
|
||||
public RoleResponse Create(
|
||||
Guid? id = null,
|
||||
string? roleName = null)
|
||||
{
|
||||
return new RoleResponse(id ?? Guid.NewGuid(), roleName ?? _faker.Commerce.Department());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="RoleResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<RoleResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.FileSystem;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.FileSystem;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Responses.FileSystemManagement.FileSystem;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="FileSystemTypeResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class FileSystemTypeResponseFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="FileSystemTypeResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="platformType">Optional. The type of the file system platform.</param>
|
||||
/// <returns>The created <see cref="FileSystemTypeResponse"/>.</returns>
|
||||
public FileSystemTypeResponse Create(
|
||||
PlatformType? platformType = null)
|
||||
{
|
||||
return new FileSystemTypeResponse(platformType ?? _faker.PickRandom<PlatformType>());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="FileSystemTypeResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<FileSystemTypeResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Path;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Responses.FileSystemManagement.Path;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PathExistsResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PathExistsResponseFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PathExistsResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="exists">Optional. Whether the path exists.</param>
|
||||
/// <returns>The created <see cref="PathExistsResponse"/>.</returns>
|
||||
public PathExistsResponse Create(
|
||||
bool? exists = null)
|
||||
{
|
||||
return new PathExistsResponse(exists ?? _faker.Random.Bool());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="PathExistsResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<PathExistsResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Path;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Responses.FileSystemManagement.Path;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="PathValidResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PathValidResponseFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="PathValidResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="isValid">Optional. Whether the path is valid.</param>
|
||||
/// <returns>The created <see cref="PathValidResponse"/>.</returns>
|
||||
public PathValidResponse Create(
|
||||
bool? isValid = null)
|
||||
{
|
||||
return new PathValidResponse(isValid ?? _faker.Random.Bool());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="PathValidResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<PathValidResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+4
-3
@@ -15,6 +15,8 @@ namespace Lumina.Contracts.Fixtures.Core.Responses.FileSystemManagement.Thumbnai
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ThumbnailResponseFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="ThumbnailResponse"/>.
|
||||
/// </summary>
|
||||
@@ -23,10 +25,9 @@ public class ThumbnailResponseFixture
|
||||
/// <returns>The created <see cref="ThumbnailResponse"/>.</returns>
|
||||
public ThumbnailResponse Create(ImageType? type = null, byte[]? bytes = null)
|
||||
{
|
||||
Faker faker = new();
|
||||
return new ThumbnailResponse(
|
||||
type ?? faker.PickRandom<ImageType>(),
|
||||
bytes ?? faker.Random.Bytes(20)
|
||||
type ?? _faker.PickRandom<ImageType>(),
|
||||
bytes ?? _faker.Random.Bytes(20)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
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="MediaLibraryScanResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaLibraryScanResponseFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MediaLibraryScanResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="scanId">Optional. The Id of the media library scan.</param>
|
||||
/// <param name="libraryId">Optional. The Id of the media library the scan belongs to.</param>
|
||||
/// <returns>The created <see cref="MediaLibraryScanResponse"/>.</returns>
|
||||
public MediaLibraryScanResponse Create(
|
||||
Guid? scanId = null,
|
||||
Guid? libraryId = null)
|
||||
{
|
||||
return new MediaLibraryScanResponse(scanId ?? Guid.NewGuid(), libraryId ?? Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="MediaLibraryScanResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<MediaLibraryScanResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+4
-2
@@ -40,7 +40,8 @@ public class BookResponseFixture
|
||||
WrittenContentMetadataDto? metadata = null,
|
||||
BookFormat? format = null,
|
||||
MetadataStatus? metadataStatus = null,
|
||||
DateTime? createdOnUtc = null)
|
||||
DateTime? createdOnUtc = null,
|
||||
string? coverPath = null)
|
||||
{
|
||||
DateTime resolvedCreatedOnUtc = createdOnUtc ?? _faker.Date.Past().ToUniversalTime();
|
||||
return new BookResponse(
|
||||
@@ -70,7 +71,8 @@ public class BookResponseFixture
|
||||
_faker.Date.Recent().ToUniversalTime(),
|
||||
_faker.Company.CompanyName(),
|
||||
resolvedCreatedOnUtc,
|
||||
_faker.Random.Bool() ? _faker.Date.Recent().ToUniversalTime() : null
|
||||
_faker.Random.Bool() ? _faker.Date.Recent().ToUniversalTime() : null,
|
||||
coverPath ?? (_faker.Random.Bool() ? _faker.System.FilePath() : null)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Responses.UsersManagement;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Responses.UsersManagement;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="InitializationResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class InitializationResponseFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="InitializationResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="isInitialized">Optional. Whether the application is initialized.</param>
|
||||
/// <returns>The created <see cref="InitializationResponse"/>.</returns>
|
||||
public InitializationResponse Create(
|
||||
bool? isInitialized = null)
|
||||
{
|
||||
return new InitializationResponse(isInitialized ?? _faker.Random.Bool());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="InitializationResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<InitializationResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user