Centralizes and standardizes test fixtures.

This commit is contained in:
BinaryAlley committed 2026-08-15 02:58:17 -07:00
1 parent dfc513da4f
commit b648e2f054
294 files changed
+3807 -4437

No files matched your search

@@ -0,0 +1,59 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.Authentication;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.Authentication;
/// <summary>
/// Fixture class for the <see cref="ChangePasswordRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class ChangePasswordRequestFixture
{
private readonly Faker _faker;
/// <summary>
/// Initializes a new instance of the <see cref="ChangePasswordRequestFixture"/> class.
/// </summary>
public ChangePasswordRequestFixture()
{
_faker = new Faker();
}
/// <summary>
/// Creates a random valid <see cref="ChangePasswordRequest"/>.
/// </summary>
/// <param name="username">Optional. The username for the password change.</param>
/// <param name="currentPassword">Optional. The current password.</param>
/// <param name="newPassword">Optional. The new password.</param>
/// <param name="newPasswordConfirm">Optional. The new password confirmation.</param>
/// <returns>The created <see cref="ChangePasswordRequest"/>.</returns>
public ChangePasswordRequest Create(
string? username = null,
string? currentPassword = null,
string? newPassword = null,
string? newPasswordConfirm = null)
{
string generatedNewPassword = newPassword ?? _faker.Internet.Password();
return new ChangePasswordRequest(
username ?? _faker.Internet.UserName(),
currentPassword ?? _faker.Internet.Password(),
generatedNewPassword,
newPasswordConfirm ?? generatedNewPassword
);
}
/// <summary>
/// Creates a list of <see cref="ChangePasswordRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<ChangePasswordRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,55 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.Authentication;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.Authentication;
/// <summary>
/// Fixture class for the <see cref="LoginRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class LoginRequestFixture
{
private readonly Faker _faker;
/// <summary>
/// Initializes a new instance of the <see cref="LoginRequestFixture"/> class.
/// </summary>
public LoginRequestFixture()
{
_faker = new Faker();
}
/// <summary>
/// Creates a random valid <see cref="LoginRequest"/>.
/// </summary>
/// <param name="username">Optional. The username for login.</param>
/// <param name="password">Optional. The password for login.</param>
/// <param name="totpCode">Optional. The TOTP code for two-factor authentication.</param>
/// <returns>The created <see cref="LoginRequest"/>.</returns>
public LoginRequest Create(
string? username = null,
string? password = null,
string? totpCode = null)
{
return new LoginRequest(
username ?? _faker.Internet.UserName(),
password ?? _faker.Internet.Password(),
totpCode ?? _faker.Random.Number(100000, 999999).ToString()
);
}
/// <summary>
/// Creates a list of <see cref="LoginRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<LoginRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,52 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.Authentication;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.Authentication;
/// <summary>
/// Fixture class for the <see cref="RecoverPasswordRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class RecoverPasswordRequestFixture
{
private readonly Faker _faker;
/// <summary>
/// Initializes a new instance of the <see cref="RecoverPasswordRequestFixture"/> class.
/// </summary>
public RecoverPasswordRequestFixture()
{
_faker = new Faker();
}
/// <summary>
/// Creates a random valid <see cref="RecoverPasswordRequest"/>.
/// </summary>
/// <param name="username">Optional. The username for password recovery.</param>
/// <param name="totpCode">Optional. The TOTP code for verification.</param>
/// <returns>The created <see cref="RecoverPasswordRequest"/>.</returns>
public RecoverPasswordRequest Create(
string? username = null,
string? totpCode = null)
{
return new RecoverPasswordRequest(
username ?? _faker.Internet.UserName(),
totpCode ?? _faker.Random.Number(100000, 999999).ToString()
);
}
/// <summary>
/// Creates a list of <see cref="RecoverPasswordRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<RecoverPasswordRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}
@@ -0,0 +1,59 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.Requests.Authentication;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
#endregion
namespace Lumina.Contracts.Fixtures.Core.Requests.Authentication;
/// <summary>
/// Fixture class for the <see cref="RegistrationRequest"/> record.
/// </summary>
[ExcludeFromCodeCoverage]
public class RegistrationRequestFixture
{
private readonly Faker _faker;
/// <summary>
/// Initializes a new instance of the <see cref="RegistrationRequestFixture"/> class.
/// </summary>
public RegistrationRequestFixture()
{
_faker = new Faker();
}
/// <summary>
/// Creates a random valid <see cref="RegistrationRequest"/>.
/// </summary>
/// <param name="username">Optional. The username for registration.</param>
/// <param name="password">Optional. The password for registration.</param>
/// <param name="passwordConfirm">Optional. The password confirmation.</param>
/// <param name="use2fa">Optional. Whether to use two-factor authentication.</param>
/// <returns>The created <see cref="RegistrationRequest"/>.</returns>
public RegistrationRequest Create(
string? username = null,
string? password = null,
string? passwordConfirm = null,
bool? use2fa = null)
{
string generatedPassword = password ?? _faker.Internet.Password();
return new RegistrationRequest(
username ?? _faker.Internet.UserName(),
generatedPassword,
passwordConfirm ?? generatedPassword,
use2fa ?? _faker.Random.Bool()
);
}
/// <summary>
/// Creates a list of <see cref="RegistrationRequest"/>.
/// </summary>
/// <param name="count">The number of elements to create.</param>
/// <returns>The created list.</returns>
public List<RegistrationRequest> CreateMany(int count = 3)
{
return [.. Enumerable.Range(0, count).Select(_ => Create())];
}
}