mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 17:11:10 +00:00
test: adds unit, integration and security test projects for the web project
This commit is contained in:
1 parent
7b56033a15
commit
7ad7ad308e
70 files changed
+4993
No files matched your search
+42
@@ -0,0 +1,42 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.Requests.Authorization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Authorization;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for generating <see cref="AddRoleRequest"/> test data.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AddRoleRequestFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="AddRoleRequest"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="roleName">Optional name of the role.</param>
|
||||
/// <param name="permissions">Optional collection of permission identifiers.</param>
|
||||
/// <returns>A configured <see cref="AddRoleRequest"/> instance.</returns>
|
||||
public AddRoleRequest Create(string? roleName = null, List<Guid>? permissions = null)
|
||||
{
|
||||
Faker faker = new();
|
||||
return new AddRoleRequest(
|
||||
RoleName: roleName ?? faker.Commerce.Department(),
|
||||
Permissions: permissions ?? [Guid.NewGuid(), Guid.NewGuid()]
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="AddRoleRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="AddRoleRequest"/> instances.</returns>
|
||||
public List<AddRoleRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.Requests.Authorization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Authorization;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for generating <see cref="DeleteRoleRequest"/> test data.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class DeleteRoleRequestFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="DeleteRoleRequest"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="roleId">Optional identifier of the role.</param>
|
||||
/// <returns>A configured <see cref="DeleteRoleRequest"/> instance.</returns>
|
||||
public DeleteRoleRequest Create(Guid? roleId = null)
|
||||
{
|
||||
return new DeleteRoleRequest(
|
||||
RoleId: roleId ?? Guid.NewGuid()
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="DeleteRoleRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="DeleteRoleRequest"/> instances.</returns>
|
||||
public List<DeleteRoleRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.Requests.FileSystemManagement.Directories;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.FileSystemManagement.Directories;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for generating <see cref="GetDirectoriesRequest"/> test data.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetDirectoriesRequestFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="GetDirectoriesRequest"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="path">Optional file system path whose directories are retrieved.</param>
|
||||
/// <param name="includeHiddenElements">Whether hidden file system elements are included or not.</param>
|
||||
/// <returns>A configured <see cref="GetDirectoriesRequest"/> instance.</returns>
|
||||
public GetDirectoriesRequest Create(string? path = null, bool includeHiddenElements = false)
|
||||
{
|
||||
return new GetDirectoriesRequest(
|
||||
Path: path ?? $"/media/{System.Guid.NewGuid():N}",
|
||||
IncludeHiddenElements: includeHiddenElements
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="GetDirectoriesRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="GetDirectoriesRequest"/> instances.</returns>
|
||||
public List<GetDirectoriesRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.Requests.FileSystemManagement.Path;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.FileSystemManagement.Path;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for generating <see cref="ValidatePathRequest"/> test data.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ValidatePathRequestFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ValidatePathRequest"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="path">Optional file system path to validate.</param>
|
||||
/// <returns>A configured <see cref="ValidatePathRequest"/> instance.</returns>
|
||||
public ValidatePathRequest Create(string? path = null)
|
||||
{
|
||||
return new ValidatePathRequest(
|
||||
Path: path ?? $"/media/{System.Guid.NewGuid():N}"
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="ValidatePathRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ValidatePathRequest"/> instances.</returns>
|
||||
public List<ValidatePathRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.Enums.Common;
|
||||
using Lumina.Presentation.Web.Common.Requests.Libraries;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Libraries;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for generating <see cref="GetBooksLiteRequest"/> test data.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetBooksLiteRequestFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="GetBooksLiteRequest"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">Optional identifier of the media library.</param>
|
||||
/// <param name="currentPage">Optional page of results to retrieve.</param>
|
||||
/// <param name="perPage">Optional number of books to retrieve per page.</param>
|
||||
/// <param name="searchTerm">Optional search term used to filter results.</param>
|
||||
/// <param name="filterAlphaKey">Optional alpha key used to filter the results.</param>
|
||||
/// <param name="ignoreThePrefixForAlphaPicker">Whether the leading "The " prefix is ignored by the alpha picker.</param>
|
||||
/// <param name="sortBy">Optional name of the field by which to sort the results.</param>
|
||||
/// <param name="sortOrder">Optional direction in which to sort the results.</param>
|
||||
/// <returns>A configured <see cref="GetBooksLiteRequest"/> instance.</returns>
|
||||
public GetBooksLiteRequest Create(
|
||||
Guid? libraryId = null,
|
||||
int? currentPage = null,
|
||||
int? perPage = null,
|
||||
string? searchTerm = null,
|
||||
string? filterAlphaKey = null,
|
||||
bool ignoreThePrefixForAlphaPicker = false,
|
||||
string? sortBy = null,
|
||||
SortOrder? sortOrder = null)
|
||||
{
|
||||
return new GetBooksLiteRequest
|
||||
{
|
||||
LibraryId = libraryId ?? Guid.NewGuid(),
|
||||
CurrentPage = currentPage,
|
||||
PerPage = perPage,
|
||||
SearchTerm = searchTerm,
|
||||
FilterAlphaKey = filterAlphaKey,
|
||||
IgnoreThePrefixForAlphaPicker = ignoreThePrefixForAlphaPicker,
|
||||
SortBy = sortBy,
|
||||
SortOrder = sortOrder
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="GetBooksLiteRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="GetBooksLiteRequest"/> instances.</returns>
|
||||
public List<GetBooksLiteRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.Requests.Library.Management;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Library.Management;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for generating <see cref="DeleteLibraryRequest"/> test data.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class DeleteLibraryRequestFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="DeleteLibraryRequest"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="id">Optional identifier of the media library.</param>
|
||||
/// <returns>A configured <see cref="DeleteLibraryRequest"/> instance.</returns>
|
||||
public DeleteLibraryRequest Create(Guid? id = null)
|
||||
{
|
||||
return new DeleteLibraryRequest(
|
||||
Id: id ?? Guid.NewGuid()
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="DeleteLibraryRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="DeleteLibraryRequest"/> instances.</returns>
|
||||
public List<DeleteLibraryRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.Requests.Plugins;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Plugins;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for generating <see cref="UpdatePluginSettingsRequest"/> test data.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UpdatePluginSettingsRequestFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="UpdatePluginSettingsRequest"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="pluginId">Optional identifier of the plugin.</param>
|
||||
/// <param name="settings">Optional dictionary of settings.</param>
|
||||
/// <returns>A configured <see cref="UpdatePluginSettingsRequest"/> instance.</returns>
|
||||
public UpdatePluginSettingsRequest Create(Guid? pluginId = null, Dictionary<string, string>? settings = null)
|
||||
{
|
||||
Faker faker = new();
|
||||
return new UpdatePluginSettingsRequest
|
||||
{
|
||||
PluginId = pluginId ?? Guid.NewGuid(),
|
||||
Settings = settings ?? new Dictionary<string, string> { [faker.Lorem.Word()] = faker.Lorem.Word() }
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="UpdatePluginSettingsRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="UpdatePluginSettingsRequest"/> instances.</returns>
|
||||
public List<UpdatePluginSettingsRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.Requests.Tools;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Tools;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for generating <see cref="SetLanguageRequest"/> test data.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class SetLanguageRequestFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="SetLanguageRequest"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="newCulture">Optional new culture to set.</param>
|
||||
/// <param name="returnUrl">Optional URL to return to, after setting the new culture.</param>
|
||||
/// <returns>A configured <see cref="SetLanguageRequest"/> instance.</returns>
|
||||
public SetLanguageRequest Create(string? newCulture = "en-US", string? returnUrl = null)
|
||||
{
|
||||
return new SetLanguageRequest(
|
||||
NewCulture: newCulture,
|
||||
ReturnUrl: returnUrl
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="SetLanguageRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="SetLanguageRequest"/> instances.</returns>
|
||||
public List<SetLanguageRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.Requests.UsersManagement.Authentication;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.UsersManagement.Authentication;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for generating <see cref="LoginViewRequest"/> test data.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LoginViewRequestFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="LoginViewRequest"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="returnUrl">Optional URL to return to, after login.</param>
|
||||
/// <returns>A configured <see cref="LoginViewRequest"/> instance.</returns>
|
||||
public LoginViewRequest Create(string? returnUrl = null)
|
||||
{
|
||||
Faker faker = new();
|
||||
return new LoginViewRequest(
|
||||
ReturnUrl: returnUrl ?? $"/{faker.Random.AlphaNumeric(8)}"
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="LoginViewRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="LoginViewRequest"/> instances.</returns>
|
||||
public List<LoginViewRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.Requests.UsersManagement;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.UsersManagement;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for generating <see cref="ChangePasswordRequest"/> test data.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ChangePasswordRequestFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ChangePasswordRequest"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="username">Optional username.</param>
|
||||
/// <param name="currentPassword">Optional current password.</param>
|
||||
/// <param name="newPassword">Optional new password.</param>
|
||||
/// <param name="newPasswordConfirm">Optional confirmation of the new password.</param>
|
||||
/// <returns>A configured <see cref="ChangePasswordRequest"/> instance.</returns>
|
||||
public ChangePasswordRequest Create(string? username = null, string? currentPassword = null, string? newPassword = null, string? newPasswordConfirm = null)
|
||||
{
|
||||
Faker faker = new();
|
||||
string generatedNewPassword = newPassword ?? faker.Internet.Password(12);
|
||||
return new ChangePasswordRequest(
|
||||
Username: username ?? faker.Internet.UserName(),
|
||||
CurrentPassword: currentPassword ?? faker.Internet.Password(12),
|
||||
NewPassword: generatedNewPassword,
|
||||
NewPasswordConfirm: newPasswordConfirm ?? generatedNewPassword
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="ChangePasswordRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="ChangePasswordRequest"/> instances.</returns>
|
||||
public List<ChangePasswordRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.Requests.UsersManagement;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.UsersManagement;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for generating <see cref="LoginRequest"/> test data.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LoginRequestFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="LoginRequest"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="username">Optional username.</param>
|
||||
/// <param name="password">Optional password.</param>
|
||||
/// <param name="totpCode">Optional TOTP code.</param>
|
||||
/// <param name="returnUrl">Optional URL to return to, after login.</param>
|
||||
/// <returns>A configured <see cref="LoginRequest"/> instance.</returns>
|
||||
public LoginRequest Create(string? username = null, string? password = null, string? totpCode = null, string? returnUrl = null)
|
||||
{
|
||||
Faker faker = new();
|
||||
return new LoginRequest(
|
||||
Username: username ?? faker.Internet.UserName(),
|
||||
Password: password ?? faker.Internet.Password(12),
|
||||
TotpCode: totpCode,
|
||||
ReturnUrl: returnUrl
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="LoginRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="LoginRequest"/> instances.</returns>
|
||||
public List<LoginRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.Requests.UsersManagement;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.UsersManagement;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for generating <see cref="RecoverPasswordRequest"/> test data.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class RecoverPasswordRequestFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="RecoverPasswordRequest"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="username">Optional username.</param>
|
||||
/// <param name="totpCode">Optional TOTP code.</param>
|
||||
/// <returns>A configured <see cref="RecoverPasswordRequest"/> instance.</returns>
|
||||
public RecoverPasswordRequest Create(string? username = null, string? totpCode = null)
|
||||
{
|
||||
Faker faker = new();
|
||||
return new RecoverPasswordRequest(
|
||||
Username: username ?? faker.Internet.UserName(),
|
||||
TotpCode: totpCode
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="RecoverPasswordRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="RecoverPasswordRequest"/> instances.</returns>
|
||||
public List<RecoverPasswordRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Presentation.Web.Common.Requests.UsersManagement;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Fixtures.Common.Requests.UsersManagement;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for generating <see cref="RegisterRequest"/> test data.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class RegisterRequestFixture
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="RegisterRequest"/> instance with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="username">Optional username.</param>
|
||||
/// <param name="password">Optional password.</param>
|
||||
/// <param name="passwordConfirm">Optional password confirmation.</param>
|
||||
/// <param name="registrationType">Optional registration type, e.g. "Admin" or "User".</param>
|
||||
/// <param name="use2fa">Whether two-factor authentication is enabled for the account.</param>
|
||||
/// <returns>A configured <see cref="RegisterRequest"/> instance.</returns>
|
||||
public RegisterRequest Create(string? username = null, string? password = null, string? passwordConfirm = null, string? registrationType = "User", bool use2fa = true)
|
||||
{
|
||||
Faker faker = new();
|
||||
string generatedPassword = password ?? faker.Internet.Password(12);
|
||||
return new RegisterRequest(
|
||||
Username: username ?? faker.Internet.UserName(),
|
||||
Password: generatedPassword,
|
||||
PasswordConfirm: passwordConfirm ?? generatedPassword,
|
||||
RegistrationType: registrationType,
|
||||
Use2fa: use2fa
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates multiple <see cref="RegisterRequest"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="RegisterRequest"/> instances.</returns>
|
||||
public List<RegisterRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user