diff --git a/tests/Common/Lumina.Application.Fixtures/Common/DTO/Filtering/BaseFilterDtoFixture.cs b/tests/Common/Lumina.Application.Fixtures/Common/DTO/Filtering/BaseFilterDtoFixture.cs
new file mode 100644
index 00000000..24071540
--- /dev/null
+++ b/tests/Common/Lumina.Application.Fixtures/Common/DTO/Filtering/BaseFilterDtoFixture.cs
@@ -0,0 +1,41 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Application.Common.DTO.Filtering;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Fixtures.Common.DTO.Filtering;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class BaseFilterDtoFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The search term used to filter results.
+ /// The created .
+ public BaseFilterDto Create(string? searchTerm = null)
+ {
+ return new BaseFilterDto
+ {
+ SearchTerm = searchTerm ?? _faker.Lorem.Sentence()
+ };
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Application.Fixtures/Common/DTO/Filtering/LibraryFilterDtoFixture.cs b/tests/Common/Lumina.Application.Fixtures/Common/DTO/Filtering/LibraryFilterDtoFixture.cs
new file mode 100644
index 00000000..f9a8971d
--- /dev/null
+++ b/tests/Common/Lumina.Application.Fixtures/Common/DTO/Filtering/LibraryFilterDtoFixture.cs
@@ -0,0 +1,52 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Application.Common.DTO.Filtering;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Fixtures.Common.DTO.Filtering;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class LibraryFilterDtoFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The Id of the media library used to filter data.
+ /// Optional. The search term used to filter results.
+ /// Optional. The alpha key used to filter by the first character of the item title.
+ /// Whether the leading "The " prefix should be ignored when computing the alpha key, or not.
+ /// The created .
+ public LibraryFilterDto Create(
+ Guid? libraryId = null,
+ string? searchTerm = null,
+ string? filterAlphaKey = null,
+ bool shouldIgnoreThePrefixForAlphaPicker = false)
+ {
+ return new LibraryFilterDto
+ {
+ LibraryId = libraryId ?? _faker.Random.Guid(),
+ SearchTerm = searchTerm,
+ FilterAlphaKey = filterAlphaKey,
+ ShouldIgnoreThePrefixForAlphaPicker = shouldIgnoreThePrefixForAlphaPicker
+ };
+ }
+
+ ///
+ /// Creates a list of instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Application.Fixtures/Common/DTO/Pagination/PaginatedResultDtoFixture.cs b/tests/Common/Lumina.Application.Fixtures/Common/DTO/Pagination/PaginatedResultDtoFixture.cs
new file mode 100644
index 00000000..0cdc69be
--- /dev/null
+++ b/tests/Common/Lumina.Application.Fixtures/Common/DTO/Pagination/PaginatedResultDtoFixture.cs
@@ -0,0 +1,55 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Application.Common.DTO.Pagination;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Fixtures.Common.DTO.Pagination;
+
+///
+/// Fixture class for the record.
+///
+/// The type of the data items contained in the paginated result.
+[ExcludeFromCodeCoverage]
+public class PaginatedResultDtoFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The collection of data items.
+ /// Optional. The current page number.
+ /// Optional. The number of items per page.
+ /// Optional. The total number of elements available.
+ /// Optional. The total number of pages.
+ /// The created .
+ public PaginatedResultDto Create(
+ IReadOnlyList? data = null,
+ int? currentPage = null,
+ int? perPage = null,
+ int? count = null,
+ int? numberOfPages = null)
+ {
+ return new PaginatedResultDto
+ {
+ Data = data ?? [],
+ CurrentPage = currentPage ?? _faker.Random.Int(1, 10),
+ PerPage = perPage ?? _faker.Random.Int(1, 100),
+ Count = count ?? _faker.Random.Int(0, 1000),
+ NumberOfPages = numberOfPages ?? _faker.Random.Int(1, 100)
+ };
+ }
+
+ ///
+ /// Creates a list of instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List> CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Application.Fixtures/Common/DTO/Pagination/PaginationDataDtoFixture.cs b/tests/Common/Lumina.Application.Fixtures/Common/DTO/Pagination/PaginationDataDtoFixture.cs
new file mode 100644
index 00000000..2bbc63cf
--- /dev/null
+++ b/tests/Common/Lumina.Application.Fixtures/Common/DTO/Pagination/PaginationDataDtoFixture.cs
@@ -0,0 +1,45 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Application.Common.DTO.Pagination;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Fixtures.Common.DTO.Pagination;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class PaginationDataDtoFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The current page number in a paginated collection.
+ /// Optional. The number of items to include per page in paginated results.
+ /// The created .
+ public PaginationDataDto Create(
+ int? currentPage = null,
+ int? perPage = null)
+ {
+ return new PaginationDataDto
+ {
+ CurrentPage = currentPage ?? _faker.Random.Int(1, 100),
+ PerPage = perPage ?? _faker.Random.Int(1, 200)
+ };
+ }
+
+ ///
+ /// Creates a list of instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Authorization/RoleEntityFixture.cs b/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Authorization/RoleEntityFixture.cs
new file mode 100644
index 00000000..3ffee2c1
--- /dev/null
+++ b/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Authorization/RoleEntityFixture.cs
@@ -0,0 +1,61 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Application.Common.DataAccess.Entities.Authorization;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.Authorization;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class RoleEntityFixture
+{
+ private readonly RolePermissionEntityFixture _rolePermissionEntityFixture = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The Id of the role.
+ /// Optional. The name of the role.
+ /// Optional. The role permission associations of the role.
+ /// Whether the role should include role permission associations or not.
+ /// Optional. The Id of the user that created the role.
+ /// Optional. The time and date when the role was added.
+ /// The created .
+ public RoleEntity Create(
+ Guid? id = null,
+ string? roleName = null,
+ IEnumerable? rolePermissions = null,
+ bool includeRolePermissions = false,
+ Guid? createdBy = null,
+ DateTime? createdOnUtc = null)
+ {
+ return new Faker()
+ .CustomInstantiator(faker => new RoleEntity
+ {
+ Id = id ?? faker.Random.Guid(),
+ RoleName = roleName ?? faker.Random.String2(faker.Random.Number(1, 50)),
+ RolePermissions = includeRolePermissions ? (rolePermissions ?? _rolePermissionEntityFixture.CreateMany()).ToList() : [],
+ CreatedOnUtc = createdOnUtc ?? faker.Date.Past(),
+ CreatedBy = createdBy ?? faker.Random.Guid(),
+ UpdatedOnUtc = null,
+ UpdatedBy = null
+ })
+ .Generate();
+ }
+
+ ///
+ /// Creates a list of instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Authorization/RolePermissionEntityFixture.cs b/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Authorization/RolePermissionEntityFixture.cs
index 3270b06f..7029f0fd 100644
--- a/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Authorization/RolePermissionEntityFixture.cs
+++ b/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Authorization/RolePermissionEntityFixture.cs
@@ -2,6 +2,7 @@
using Bogus;
using Lumina.Application.Common.DataAccess.Entities.Authorization;
using Lumina.Domain.SharedKernel.Common.Enums.Authorization;
+using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
@@ -20,23 +21,33 @@ public class RolePermissionEntityFixture
///
/// Creates a random valid .
///
+ /// Optional. The Id of the role permission association.
+ /// Optional. The Id of the role the permission is granted to.
+ /// Optional. The role the permission is granted to.
+ /// Optional. The Id of the permission granted to the role.
+ /// Optional. The permission granted to the role.
/// The created .
- public RolePermissionEntity Create()
+ public RolePermissionEntity Create(
+ Guid? id = null,
+ Guid? roleId = null,
+ RoleEntity? role = null,
+ Guid? permissionId = null,
+ PermissionEntity? permission = null)
{
- PermissionEntity permission = new()
+ RoleEntity resolvedRole = role ?? new RoleEntity
{
- Id = _faker.Random.Guid(),
- PermissionName = _faker.PickRandom(),
+ Id = roleId ?? _faker.Random.Guid(),
+ RoleName = _faker.Random.String2(10),
CreatedOnUtc = _faker.Date.Past(),
CreatedBy = _faker.Random.Guid(),
UpdatedOnUtc = _faker.Date.Recent(),
UpdatedBy = _faker.Random.Guid()
};
- RoleEntity role = new()
+ PermissionEntity resolvedPermission = permission ?? new PermissionEntity
{
- Id = _faker.Random.Guid(),
- RoleName = _faker.Random.String2(10),
+ Id = permissionId ?? _faker.Random.Guid(),
+ PermissionName = _faker.PickRandom(),
CreatedOnUtc = _faker.Date.Past(),
CreatedBy = _faker.Random.Guid(),
UpdatedOnUtc = _faker.Date.Recent(),
@@ -46,11 +57,11 @@ public class RolePermissionEntityFixture
return new Faker()
.CustomInstantiator(f => new RolePermissionEntity
{
- Id = f.Random.Guid(),
- RoleId = role.Id,
- Role = role,
- PermissionId = permission.Id,
- Permission = permission,
+ Id = id ?? f.Random.Guid(),
+ RoleId = resolvedRole.Id,
+ Role = role ?? resolvedRole,
+ PermissionId = resolvedPermission.Id,
+ Permission = permission ?? resolvedPermission,
CreatedOnUtc = f.Date.Past(),
CreatedBy = f.Random.Guid(),
UpdatedOnUtc = f.Date.Recent(),
diff --git a/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Authorization/UserAuthorizationEntityFixture.cs b/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Authorization/UserAuthorizationEntityFixture.cs
index 4e1bada0..57514f07 100644
--- a/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Authorization/UserAuthorizationEntityFixture.cs
+++ b/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Authorization/UserAuthorizationEntityFixture.cs
@@ -20,16 +20,22 @@ public class UserAuthorizationEntityFixture
///
/// Optional. The user Id to use. If null, a random GUID will be generated.
/// Whether the user should have admin role.
+ /// Optional. The role associated to the user. If null, it is derived from the flag.
+ /// Optional. The permissions associated to the user. If null, a default set is generated.
/// The created entity.
- public UserAuthorizationEntity Create(Guid? userId = null, bool isAdmin = false)
+ public UserAuthorizationEntity Create(
+ Guid? userId = null,
+ bool isAdmin = false,
+ string? role = null,
+ IReadOnlySet? permissions = null)
{
- string role = isAdmin ? "Admin" : string.Empty;
+ string resolvedRole = role ?? (isAdmin ? "Admin" : string.Empty);
return new UserAuthorizationEntity
{
UserId = userId ?? Guid.NewGuid(),
- Role = role,
- Permissions = new HashSet
+ Role = resolvedRole,
+ Permissions = permissions ?? new HashSet
{
AuthorizationPermission.CanViewUsers,
AuthorizationPermission.CanRegisterUsers
diff --git a/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Authorization/UserRoleEntityFixture.cs b/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Authorization/UserRoleEntityFixture.cs
index e7142a7d..acce952c 100644
--- a/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Authorization/UserRoleEntityFixture.cs
+++ b/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Authorization/UserRoleEntityFixture.cs
@@ -1,6 +1,8 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Application.Common.DataAccess.Entities.Authorization;
+using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
+using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
@@ -14,36 +16,52 @@ namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.Authorization;
[ExcludeFromCodeCoverage]
public class UserRoleEntityFixture
{
+ private readonly Faker _faker = new();
+
///
/// Creates a random valid .
///
+ /// Optional. The Id of the user role association.
+ /// Optional. The Id of the user the role is granted to.
+ /// Optional. The user the role is granted to.
+ /// Optional. The Id of the role granted to the user.
+ /// Optional. The role granted to the user.
/// The created .
- public UserRoleEntity Create()
+ public UserRoleEntity Create(
+ Guid? id = null,
+ Guid? userId = null,
+ UserEntity? user = null,
+ Guid? roleId = null,
+ RoleEntity? role = null)
{
+ UserEntity resolvedUser = user ?? new UserEntity
+ {
+ Id = userId ?? _faker.Random.Guid(),
+ Username = _faker.Internet.UserName(),
+ Password = _faker.Internet.Password(),
+ Libraries = [],
+ UserRole = null,
+ UserPermissions = [],
+ CreatedOnUtc = _faker.Date.Past(),
+ CreatedBy = _faker.Random.Guid()
+ };
+
+ RoleEntity resolvedRole = role ?? new RoleEntity
+ {
+ Id = roleId ?? _faker.Random.Guid(),
+ RoleName = _faker.Random.String2(_faker.Random.Number(1, 50)),
+ CreatedOnUtc = _faker.Date.Past(),
+ CreatedBy = _faker.Random.Guid()
+ };
+
return new Faker()
.CustomInstantiator(f => new UserRoleEntity
{
- Id = f.Random.Guid(),
- UserId = f.Random.Guid(),
- User = new()
- {
- Id = f.Random.Guid(),
- Username = f.Internet.UserName(),
- Password = f.Internet.Password(),
- Libraries = [],
- UserRole = null,
- UserPermissions = [],
- CreatedOnUtc = f.Date.Past(),
- CreatedBy = f.Random.Guid()
- },
- RoleId = f.Random.Guid(),
- Role = new()
- {
- Id = f.Random.Guid(),
- RoleName = f.Random.String2(f.Random.Number(1, 50)),
- CreatedOnUtc = f.Date.Past(),
- CreatedBy = f.Random.Guid()
- },
+ Id = id ?? f.Random.Guid(),
+ UserId = resolvedUser.Id,
+ User = user ?? resolvedUser,
+ RoleId = resolvedRole.Id,
+ Role = role ?? resolvedRole,
CreatedOnUtc = f.Date.Past(),
CreatedBy = f.Random.Guid()
})
diff --git a/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Common/GenreEntityFixture.cs b/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Common/GenreEntityFixture.cs
new file mode 100644
index 00000000..a0cc7ad3
--- /dev/null
+++ b/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Common/GenreEntityFixture.cs
@@ -0,0 +1,41 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Application.Common.DataAccess.Entities.Common;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.Common;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class GenreEntityFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The name of the genre.
+ /// Whether the name should be included, or forced to .
+ /// The created .
+ public GenreEntity Create(
+ string? name = null,
+ bool includeName = true)
+ {
+ return new GenreEntity(includeName ? name ?? _faker.Lorem.Word() : null);
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Common/TagEntityFixture.cs b/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Common/TagEntityFixture.cs
new file mode 100644
index 00000000..1985f046
--- /dev/null
+++ b/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/Common/TagEntityFixture.cs
@@ -0,0 +1,41 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Application.Common.DataAccess.Entities.Common;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.Common;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class TagEntityFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The name of the tag.
+ /// Whether the name should be included, or forced to .
+ /// The created .
+ public TagEntity Create(
+ string? name = null,
+ bool includeName = true)
+ {
+ return new TagEntity(includeName ? name ?? _faker.Lorem.Word() : null);
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/MediaLibrary/WrittenContentLibrary/BookLibrary/BookEntityFixture.cs b/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/MediaLibrary/WrittenContentLibrary/BookLibrary/BookEntityFixture.cs
index 19c76868..fe191177 100644
--- a/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/MediaLibrary/WrittenContentLibrary/BookLibrary/BookEntityFixture.cs
+++ b/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/MediaLibrary/WrittenContentLibrary/BookLibrary/BookEntityFixture.cs
@@ -28,13 +28,15 @@ public class BookEntityFixture
/// Optional. The file system path of the book.
/// Optional. The title of the book.
/// Optional. The original title of the book.
+ /// Whether the book should include its owned metadata collections (Tags, Genres, ISBNs, Ratings) or not.
/// The created .
public BookEntity Create(
Guid? id = null,
Guid? libraryId = null,
string? path = null,
string? title = null,
- string? originalTitle = null)
+ string? originalTitle = null,
+ bool includeMetadata = true)
{
int releaseYear = _random.Next(2000, 2010);
int reReleaseYear = _random.Next(2010, 2020);
@@ -58,8 +60,8 @@ public class BookEntityFixture
.RuleFor(x => x.OriginalLanguageCode, f => f.Random.String2(2))
.RuleFor(x => x.OriginalLanguageName, f => f.Random.String2(f.Random.Number(1, 50)))
.RuleFor(x => x.OriginalLanguageNativeName, f => f.Random.String2(f.Random.Number(1, 50)))
- .RuleFor(x => x.Tags, f => [.. CreateTags(f.Random.Number(1, 5))])
- .RuleFor(x => x.Genres, f => [.. CreateGenres(f.Random.Number(1, 5))])
+ .RuleFor(x => x.Tags, f => includeMetadata ? [.. CreateTags(f.Random.Number(1, 5))] : [])
+ .RuleFor(x => x.Genres, f => includeMetadata ? [.. CreateGenres(f.Random.Number(1, 5))] : [])
.RuleFor(x => x.Publisher, f => f.Random.String2(f.Random.Number(1, 100)))
.RuleFor(x => x.PageCount, _random.Next(100, 300))
.RuleFor(x => x.Format, f => f.PickRandom())
@@ -74,8 +76,8 @@ public class BookEntityFixture
.RuleFor(x => x.GoogleBooksId, CreateGoogleBooksId)
.RuleFor(x => x.BarnesAndNobleId, f => f.Random.String2(10, "0123456789"))
.RuleFor(x => x.AppleBooksId, f => $"id{f.Random.Number(1, 999999)}")
- .RuleFor(x => x.ISBNs, f => CreateIsbns(f.Random.Number(1, 5)))
- .RuleFor(x => x.Ratings, f => CreateBookRatings(f.Random.Number(1, 5)))
+ .RuleFor(x => x.ISBNs, f => includeMetadata ? CreateIsbns(f.Random.Number(1, 5)) : [])
+ .RuleFor(x => x.Ratings, f => includeMetadata ? CreateBookRatings(f.Random.Number(1, 5)) : [])
.RuleFor(x => x.CreatedOnUtc, f => f.Date.Past())
.RuleFor(x => x.UpdatedOnUtc, f => f.Date.Recent())
.Generate();
diff --git a/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/MediaLibrary/WrittenContentLibrary/BookLibrary/IsbnEntityFixture.cs b/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/MediaLibrary/WrittenContentLibrary/BookLibrary/IsbnEntityFixture.cs
new file mode 100644
index 00000000..0ad25a7d
--- /dev/null
+++ b/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/MediaLibrary/WrittenContentLibrary/BookLibrary/IsbnEntityFixture.cs
@@ -0,0 +1,46 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
+using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class IsbnEntityFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The ISBN value.
+ /// Optional. The format of the ISBN.
+ /// Whether the value should be included, or forced to .
+ /// The created .
+ public IsbnEntity Create(
+ string? value = null,
+ IsbnFormat? format = null,
+ bool includeValue = true)
+ {
+ return new IsbnEntity(
+ includeValue ? value ?? _faker.Random.String2(13, "0123456789") : null,
+ format);
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/UsersManagement/UserEntityFixture.cs b/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/UsersManagement/UserEntityFixture.cs
index 8fbb2def..ee757fb6 100644
--- a/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/UsersManagement/UserEntityFixture.cs
+++ b/tests/Common/Lumina.Application.Fixtures/Common/DataAccess/Entities/UsersManagement/UserEntityFixture.cs
@@ -1,5 +1,6 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
+using Lumina.Application.Common.DataAccess.Entities.Authorization;
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
@@ -23,13 +24,28 @@ public class UserEntityFixture
/// Number of libraries to generate. Default is 0.
/// Optional username to pin, or to generate a random one.
/// Optional password to pin, or to generate a random one.
+ /// Optional Id to pin, or to generate a random one.
+ /// Optional user role association to pin when including it.
+ /// Optional user permission associations to pin when including them.
+ /// Whether the user should include a user role association or not.
+ /// Whether the user should include user permission associations or not.
+ /// Optional collection of libraries to pin for the user, or to generate them based on .
/// The created user entity.
- public UserEntity Create(int libraryCount = 0, string? username = null, string? password = null)
+ public UserEntity Create(
+ int libraryCount = 0,
+ string? username = null,
+ string? password = null,
+ Guid? id = null,
+ UserRoleEntity? userRole = null,
+ IEnumerable? userPermissions = null,
+ bool includeUserRole = false,
+ bool includeUserPermissions = false,
+ ICollection? libraries = null)
{
- Guid userId = Guid.NewGuid();
- List libraries = libraryCount > 0
+ Guid userId = id ?? Guid.NewGuid();
+ ICollection resolvedLibraries = libraries ?? (libraryCount > 0
? CreateLibraries(libraryCount, userId)
- : [];
+ : []);
return new Faker()
.CustomInstantiator(f => new UserEntity
@@ -39,9 +55,9 @@ public class UserEntityFixture
Password = default!,
CreatedOnUtc = default,
TotpSecret = default,
- Libraries = libraries,
- UserPermissions = [],
- UserRole = null,
+ Libraries = resolvedLibraries,
+ UserPermissions = includeUserPermissions ? (userPermissions ?? []).ToList() : [],
+ UserRole = includeUserRole ? userRole : null,
CreatedBy = userId
})
.RuleFor(x => x.Username, f => username ?? f.Internet.UserName())
diff --git a/tests/Common/Lumina.Application.Fixtures/Common/Infrastructure/Models/DTO/Themes/ThemeArchiveDtoFixture.cs b/tests/Common/Lumina.Application.Fixtures/Common/Infrastructure/Models/DTO/Themes/ThemeArchiveDtoFixture.cs
new file mode 100644
index 00000000..103743bb
--- /dev/null
+++ b/tests/Common/Lumina.Application.Fixtures/Common/Infrastructure/Models/DTO/Themes/ThemeArchiveDtoFixture.cs
@@ -0,0 +1,46 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Application.Common.Infrastructure.Models.DTO.Themes;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Fixtures.Common.Infrastructure.Models.DTO.Themes;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class ThemeArchiveDtoFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The bytes of the ZIP archive.
+ /// Optional. The file name to expose when downloading the archive.
+ /// Optional. The MIME content type of the archive.
+ /// The created .
+ public ThemeArchiveDto Create(
+ byte[]? bytes = null,
+ string? fileName = null,
+ string? contentType = null)
+ {
+ return new ThemeArchiveDto(
+ bytes ?? _faker.Random.Bytes(10),
+ fileName ?? _faker.System.FileName(),
+ contentType ?? _faker.System.MimeType());
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Application.Fixtures/Common/Infrastructure/Models/DTO/Themes/ThemeAssetDtoFixture.cs b/tests/Common/Lumina.Application.Fixtures/Common/Infrastructure/Models/DTO/Themes/ThemeAssetDtoFixture.cs
new file mode 100644
index 00000000..dce663b9
--- /dev/null
+++ b/tests/Common/Lumina.Application.Fixtures/Common/Infrastructure/Models/DTO/Themes/ThemeAssetDtoFixture.cs
@@ -0,0 +1,43 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Application.Common.Infrastructure.Models.DTO.Themes;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Fixtures.Common.Infrastructure.Models.DTO.Themes;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class ThemeAssetDtoFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The bytes of the asset file.
+ /// Optional. The MIME content type of the asset file.
+ /// The created .
+ public ThemeAssetDto Create(
+ byte[]? bytes = null,
+ string? contentType = null)
+ {
+ return new ThemeAssetDto(
+ bytes ?? _faker.Random.Bytes(10),
+ contentType ?? _faker.System.MimeType());
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Application.Fixtures/Core/Admin/Authorization/Permissions/Queries/GetPermissions/GetPermissionsQueryFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/Admin/Authorization/Permissions/Queries/GetPermissions/GetPermissionsQueryFixture.cs
new file mode 100644
index 00000000..962a415c
--- /dev/null
+++ b/tests/Common/Lumina.Application.Fixtures/Core/Admin/Authorization/Permissions/Queries/GetPermissions/GetPermissionsQueryFixture.cs
@@ -0,0 +1,34 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.Admin.Authorization.Permissions.Queries.GetPermissions;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Fixtures.Core.Admin.Authorization.Permissions.Queries.GetPermissions;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class GetPermissionsQueryFixture
+{
+ ///
+ /// Creates a random valid query to get permissions.
+ ///
+ /// The created query.
+ public GetPermissionsQuery Create()
+ {
+ return new GetPermissionsQuery();
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Application.Fixtures/Core/Maintenance/ApplicationSetup/Queries/CheckInitialization/CheckInitializationQueryFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/Maintenance/ApplicationSetup/Queries/CheckInitialization/CheckInitializationQueryFixture.cs
new file mode 100644
index 00000000..5bf4cfed
--- /dev/null
+++ b/tests/Common/Lumina.Application.Fixtures/Core/Maintenance/ApplicationSetup/Queries/CheckInitialization/CheckInitializationQueryFixture.cs
@@ -0,0 +1,34 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.Maintenance.ApplicationSetup.Queries.CheckInitialization;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Fixtures.Core.Maintenance.ApplicationSetup.Queries.CheckInitialization;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class CheckInitializationQueryFixture
+{
+ ///
+ /// Creates a .
+ ///
+ /// The created .
+ public CheckInitializationQuery Create()
+ {
+ return new CheckInitializationQuery();
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/Management/Commands/CancelLibrariesScan/CancelLibrariesScanCommandFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/Management/Commands/CancelLibrariesScan/CancelLibrariesScanCommandFixture.cs
new file mode 100644
index 00000000..0c35040a
--- /dev/null
+++ b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/Management/Commands/CancelLibrariesScan/CancelLibrariesScanCommandFixture.cs
@@ -0,0 +1,34 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.MediaLibrary.Management.Commands.CancelLibrariesScan;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Fixtures.Core.MediaLibrary.Management.Commands.CancelLibrariesScan;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class CancelLibrariesScanCommandFixture
+{
+ ///
+ /// Creates a .
+ ///
+ /// The created .
+ public CancelLibrariesScanCommand Create()
+ {
+ return new CancelLibrariesScanCommand();
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/Management/Commands/ScanLibraries/ScanLibrariesCommandFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/Management/Commands/ScanLibraries/ScanLibrariesCommandFixture.cs
new file mode 100644
index 00000000..69e2519a
--- /dev/null
+++ b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/Management/Commands/ScanLibraries/ScanLibrariesCommandFixture.cs
@@ -0,0 +1,34 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.MediaLibrary.Management.Commands.ScanLibraries;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Fixtures.Core.MediaLibrary.Management.Commands.ScanLibraries;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class ScanLibrariesCommandFixture
+{
+ ///
+ /// Creates a .
+ ///
+ /// The created .
+ public ScanLibrariesCommand Create()
+ {
+ return new ScanLibrariesCommand();
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/Management/Queries/GetEnabledLibraries/GetEnabledLibrariesQueryFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/Management/Queries/GetEnabledLibraries/GetEnabledLibrariesQueryFixture.cs
new file mode 100644
index 00000000..df7be1bc
--- /dev/null
+++ b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/Management/Queries/GetEnabledLibraries/GetEnabledLibrariesQueryFixture.cs
@@ -0,0 +1,34 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.MediaLibrary.Management.Queries.GetEnabledLibraries;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Fixtures.Core.MediaLibrary.Management.Queries.GetEnabledLibraries;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class GetEnabledLibrariesQueryFixture
+{
+ ///
+ /// Creates a .
+ ///
+ /// The created .
+ public GetEnabledLibrariesQuery Create()
+ {
+ return new GetEnabledLibrariesQuery();
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/Management/Queries/GetLibraries/GetLibrariesQueryFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/Management/Queries/GetLibraries/GetLibrariesQueryFixture.cs
new file mode 100644
index 00000000..084f8b5d
--- /dev/null
+++ b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/Management/Queries/GetLibraries/GetLibrariesQueryFixture.cs
@@ -0,0 +1,34 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.MediaLibrary.Management.Queries.GetLibraries;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Fixtures.Core.MediaLibrary.Management.Queries.GetLibraries;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class GetLibrariesQueryFixture
+{
+ ///
+ /// Creates a .
+ ///
+ /// The created .
+ public GetLibrariesQuery Create()
+ {
+ return new GetLibrariesQuery();
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/Management/Queries/GetRunningLibraryScans/GetRunningLibraryScansQueryFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/Management/Queries/GetRunningLibraryScans/GetRunningLibraryScansQueryFixture.cs
new file mode 100644
index 00000000..9b322530
--- /dev/null
+++ b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/Management/Queries/GetRunningLibraryScans/GetRunningLibraryScansQueryFixture.cs
@@ -0,0 +1,34 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.MediaLibrary.Management.Queries.GetRunningLibraryScans;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Fixtures.Core.MediaLibrary.Management.Queries.GetRunningLibraryScans;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class GetRunningLibraryScansQueryFixture
+{
+ ///
+ /// Creates a .
+ ///
+ /// The created .
+ public GetRunningLibraryScansQuery Create()
+ {
+ return new GetRunningLibraryScansQuery();
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooks/GetBooksQueryFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooks/GetBooksQueryFixture.cs
index caa8d830..9cfd04eb 100644
--- a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooks/GetBooksQueryFixture.cs
+++ b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooks/GetBooksQueryFixture.cs
@@ -28,20 +28,22 @@ public class GetBooksQueryFixture
/// Optional. The search term used to filter results.
/// Optional. The name of the field by which to sort the results.
/// Optional. The direction in which to sort the results.
+ /// Whether the query should include pagination data or not.
/// The created query to get books.
public GetBooksQuery Create(
Guid? libraryId = null,
PaginationDataDto? paginationData = null,
string? searchTerm = null,
string? sortBy = null,
- SortOrder? sortOrder = null)
+ SortOrder? sortOrder = null,
+ bool includePaginationData = true)
{
return new GetBooksQuery(
- paginationData ?? new PaginationDataDto
+ includePaginationData ? paginationData ?? new PaginationDataDto
{
CurrentPage = _faker.Random.Number(1, 100),
PerPage = _faker.Random.Number(1, 200)
- },
+ } : null,
new LibraryFilterDto
{
LibraryId = libraryId ?? _faker.Random.Guid(),
diff --git a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooksLite/GetBooksLiteQueryFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooksLite/GetBooksLiteQueryFixture.cs
index c7a7d0d9..a93511b1 100644
--- a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooksLite/GetBooksLiteQueryFixture.cs
+++ b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/WrittenContentLibrary/BooksLibrary/Books/Queries/GetBooksLite/GetBooksLiteQueryFixture.cs
@@ -27,31 +27,33 @@ public class GetBooksLiteQueryFixture
/// Optional. The pagination data of the query.
/// Optional. The search term used to filter results.
/// Optional. The alpha key used to filter the results by the first character of their title, for the alpha picker.
- /// Optional. Whether the leading "The " prefix of a title should be ignored when computing the alpha key, or not.
+ /// Optional. Whether the leading "The " prefix of a title should be ignored when computing the alpha key, or not.
/// Optional. The name of the field by which to sort the results.
/// Optional. The direction in which to sort the results.
+ /// Whether the query should include pagination data or not.
/// The created query to get the lightweight details of books.
public GetBooksLiteQuery Create(
Guid? libraryId = null,
PaginationDataDto? paginationData = null,
string? searchTerm = null,
string? filterAlphaKey = null,
- bool ignoreThePrefixForAlphaPicker = false,
+ bool shouldIgnoreThePrefixForAlphaPicker = false,
string? sortBy = null,
- SortOrder? sortOrder = null)
+ SortOrder? sortOrder = null,
+ bool includePaginationData = true)
{
return new GetBooksLiteQuery(
- paginationData ?? new PaginationDataDto
+ includePaginationData ? paginationData ?? new PaginationDataDto
{
CurrentPage = _faker.Random.Number(1, 100),
PerPage = _faker.Random.Number(1, 200)
- },
+ } : null,
new LibraryFilterDto
{
LibraryId = libraryId ?? _faker.Random.Guid(),
SearchTerm = searchTerm,
FilterAlphaKey = filterAlphaKey,
- IgnoreThePrefixForAlphaPicker = ignoreThePrefixForAlphaPicker
+ ShouldIgnoreThePrefixForAlphaPicker = shouldIgnoreThePrefixForAlphaPicker
},
sortBy,
sortOrder ?? _faker.PickRandom()
diff --git a/tests/Common/Lumina.Application.Fixtures/Core/Plugins/Queries/GetPlugins/GetPluginsQueryFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/Plugins/Queries/GetPlugins/GetPluginsQueryFixture.cs
new file mode 100644
index 00000000..3b82f852
--- /dev/null
+++ b/tests/Common/Lumina.Application.Fixtures/Core/Plugins/Queries/GetPlugins/GetPluginsQueryFixture.cs
@@ -0,0 +1,34 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.Plugins.Queries.GetPlugins;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Fixtures.Core.Plugins.Queries.GetPlugins;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class GetPluginsQueryFixture
+{
+ ///
+ /// Creates a .
+ ///
+ /// The created .
+ public GetPluginsQuery Create()
+ {
+ return new GetPluginsQuery();
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Application.Fixtures/Core/UsersManagement/Settings/Queries/GetUserSettings/GetUserSettingsQueryFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/UsersManagement/Settings/Queries/GetUserSettings/GetUserSettingsQueryFixture.cs
new file mode 100644
index 00000000..6fc4a7a9
--- /dev/null
+++ b/tests/Common/Lumina.Application.Fixtures/Core/UsersManagement/Settings/Queries/GetUserSettings/GetUserSettingsQueryFixture.cs
@@ -0,0 +1,34 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Application.Core.UsersManagement.Settings.Queries.GetUserSettings;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Application.Fixtures.Core.UsersManagement.Settings.Queries.GetUserSettings;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class GetUserSettingsQueryFixture
+{
+ ///
+ /// Creates a random valid query to get the settings of the current user.
+ ///
+ /// The created query.
+ public GetUserSettingsQuery Create()
+ {
+ return new GetUserSettingsQuery();
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/Common/GenreDtoFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/Common/GenreDtoFixture.cs
new file mode 100644
index 00000000..24179b03
--- /dev/null
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/Common/GenreDtoFixture.cs
@@ -0,0 +1,41 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Contracts.DTO.Common;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Contracts.Fixtures.Core.DTO.Common;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class GenreDtoFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The name of the genre.
+ /// Whether the name should be included, or forced to .
+ /// The created .
+ public GenreDto Create(
+ string? name = null,
+ bool includeName = true)
+ {
+ return new GenreDto(includeName ? name ?? _faker.Lorem.Word() : null);
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/Common/LanguageInfoDtoFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/Common/LanguageInfoDtoFixture.cs
new file mode 100644
index 00000000..e67f358d
--- /dev/null
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/Common/LanguageInfoDtoFixture.cs
@@ -0,0 +1,46 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Contracts.DTO.Common;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Contracts.Fixtures.Core.DTO.Common;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class LanguageInfoDtoFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The ISO code of the language.
+ /// Optional. The name of the language in English.
+ /// Optional. The native name of the language.
+ /// The created .
+ public LanguageInfoDto Create(
+ string? languageCode = null,
+ string? languageName = null,
+ string? nativeName = null)
+ {
+ return new LanguageInfoDto(
+ languageCode ?? _faker.Random.String2(2),
+ languageName ?? _faker.Lorem.Word(),
+ nativeName ?? _faker.Lorem.Word());
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/Common/ReleaseInfoDtoFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/Common/ReleaseInfoDtoFixture.cs
new file mode 100644
index 00000000..6de91897
--- /dev/null
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/Common/ReleaseInfoDtoFixture.cs
@@ -0,0 +1,53 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Contracts.DTO.Common;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Contracts.Fixtures.Core.DTO.Common;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class ReleaseInfoDtoFixture
+{
+ ///
+ /// Creates an , preserving the values that are not provided as .
+ ///
+ /// Optional. The original release date of the content.
+ /// Optional. The original release year of the content.
+ /// Optional. The re-release date of the content.
+ /// Optional. The re-release year of the content.
+ /// Optional. The country where the content was released.
+ /// Optional. The version or edition of the content's release.
+ /// The created .
+ public ReleaseInfoDto Create(
+ DateOnly? originalReleaseDate = null,
+ int? originalReleaseYear = null,
+ DateOnly? reReleaseDate = null,
+ int? reReleaseYear = null,
+ string? releaseCountry = null,
+ string? releaseVersion = null)
+ {
+ return new ReleaseInfoDto(
+ originalReleaseDate,
+ originalReleaseYear,
+ reReleaseDate,
+ reReleaseYear,
+ releaseCountry,
+ releaseVersion);
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/Common/TagDtoFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/Common/TagDtoFixture.cs
new file mode 100644
index 00000000..4dd94b80
--- /dev/null
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/Common/TagDtoFixture.cs
@@ -0,0 +1,41 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Contracts.DTO.Common;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Contracts.Fixtures.Core.DTO.Common;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class TagDtoFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The name of the tag.
+ /// Whether the name should be included, or forced to .
+ /// The created .
+ public TagDto Create(
+ string? name = null,
+ bool includeName = true)
+ {
+ return new TagDto(includeName ? name ?? _faker.Lorem.Word() : null);
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaContributors/MediaContributorDtoFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaContributors/MediaContributorDtoFixture.cs
new file mode 100644
index 00000000..6082894e
--- /dev/null
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaContributors/MediaContributorDtoFixture.cs
@@ -0,0 +1,45 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Contracts.DTO.MediaContributors;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Contracts.Fixtures.Core.DTO.MediaContributors;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class MediaContributorDtoFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The display name of the media contributor.
+ /// Optional. The name of the role assigned to the media contributor.
+ /// Optional. The category of the role.
+ /// The created .
+ public MediaContributorDto Create(
+ string? displayName = null,
+ string? roleName = null,
+ string? roleCategory = null)
+ {
+ return new MediaContributorDto(
+ Name: new MediaContributorNameDto(DisplayName: displayName ?? _faker.Name.FullName(), LegalName: null),
+ Role: new MediaContributorRoleDto(Name: roleName ?? _faker.Commerce.Department(), Category: roleCategory ?? "Writing"));
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaContributors/MediaContributorNameDtoFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaContributors/MediaContributorNameDtoFixture.cs
new file mode 100644
index 00000000..a332a8a7
--- /dev/null
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaContributors/MediaContributorNameDtoFixture.cs
@@ -0,0 +1,43 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Contracts.DTO.MediaContributors;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Contracts.Fixtures.Core.DTO.MediaContributors;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class MediaContributorNameDtoFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The display name of the media contributor.
+ /// Optional. The legal name of the media contributor.
+ /// The created .
+ public MediaContributorNameDto Create(
+ string? displayName = null,
+ string? legalName = null)
+ {
+ return new MediaContributorNameDto(
+ displayName ?? _faker.Name.FullName(),
+ legalName ?? _faker.Name.FullName());
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaContributors/MediaContributorRoleDtoFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaContributors/MediaContributorRoleDtoFixture.cs
new file mode 100644
index 00000000..93e8d187
--- /dev/null
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaContributors/MediaContributorRoleDtoFixture.cs
@@ -0,0 +1,43 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Contracts.DTO.MediaContributors;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Contracts.Fixtures.Core.DTO.MediaContributors;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class MediaContributorRoleDtoFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The name of the role assigned to the media contributor.
+ /// Optional. The category of the role.
+ /// The created .
+ public MediaContributorRoleDto Create(
+ string? name = null,
+ string? category = null)
+ {
+ return new MediaContributorRoleDto(
+ name ?? _faker.Commerce.Department(),
+ category ?? _faker.Commerce.Department());
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/BookMetadataDtoFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/BookMetadataDtoFixture.cs
index 7fa9d6e3..498147dc 100644
--- a/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/BookMetadataDtoFixture.cs
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaLibrary/WrittenContentLibrary/BookLibrary/BookMetadataDtoFixture.cs
@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Contracts.DTO.Common;
+using Lumina.Contracts.DTO.MediaContributors;
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
using System;
@@ -25,53 +26,93 @@ public class BookMetadataDtoFixture
/// Optional. The title of the book.
/// Optional. The original title of the book.
/// Optional. A brief description or summary of the book.
- /// Optional. The Goodreads ID of the book.
- /// Optional. The format of the book.
+ /// Optional. The release information of the book.
+ /// Optional. The genres of the book.
+ /// Optional. The tags of the book.
+ /// Optional. The language of the book.
+ /// Optional. The original language of the book.
/// Optional. The name of the publisher of the book.
/// Optional. The number of pages in the book.
- /// Whether optional properties should be included.
+ /// Optional. The format of the book.
+ /// Optional. The edition of the book.
+ /// Optional. The volume or book number in the series.
+ /// Optional. The series the book is part of.
+ /// Optional. The ASIN of the book.
+ /// Optional. The Goodreads ID of the book.
+ /// Optional. The LCCN of the book.
+ /// Optional. The OCLC number of the book.
+ /// Optional. The Open Library ID of the book.
+ /// Optional. The LibraryThing ID of the book.
+ /// Optional. The Google Books ID of the book.
+ /// Optional. The Barnes and Noble ID of the book.
+ /// Optional. The Apple Books ID of the book.
+ /// Optional. The ISBNs of the book.
+ /// Optional. The contributors of the book.
+ /// Optional. The ratings of the book.
+ /// Optional. The path of the cover image of the book.
+ /// Whether the title should be included, or forced to .
+ /// Whether the properties that are not explicitly provided should be randomized, or left .
/// The created .
public BookMetadataDto Create(
string? title = null,
string? originalTitle = null,
string? description = null,
- string? goodreadsId = null,
- BookFormat? format = null,
+ ReleaseInfoDto? releaseInfo = null,
+ List? genres = null,
+ List? tags = null,
+ LanguageInfoDto? language = null,
+ LanguageInfoDto? originalLanguage = null,
string? publisher = null,
int? pageCount = null,
+ BookFormat? format = null,
+ string? edition = null,
+ float? volumeNumber = null,
+ BookSeriesDto? series = null,
+ string? asin = null,
+ string? goodreadsId = null,
+ string? lccn = null,
+ string? oclcNumber = null,
+ string? openLibraryId = null,
+ string? libraryThingId = null,
+ string? googleBooksId = null,
+ string? barnesAndNobleId = null,
+ string? appleBooksId = null,
+ List? isbns = null,
+ List? contributors = null,
+ List? ratings = null,
+ string? coverImagePath = null,
+ bool includeTitle = true,
bool includeOptionalProperties = true)
{
int releaseYear = _faker.Random.Int(1900, 2024);
return new BookMetadataDto(
- title ?? _faker.Lorem.Sentence(3),
+ includeTitle ? title ?? (includeOptionalProperties ? _faker.Lorem.Sentence(3) : null) : null,
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,
+ releaseInfo ?? (includeOptionalProperties ? new ReleaseInfoDto(new DateOnly(releaseYear, 1, 1), releaseYear, null, null, _faker.Address.CountryCode(), null) : null),
+ genres ?? (includeOptionalProperties ? [new GenreDto(_faker.Lorem.Word())] : null),
+ tags ?? (includeOptionalProperties ? [new TagDto(_faker.Lorem.Word())] : null),
+ language ?? (includeOptionalProperties ? new LanguageInfoDto("en", "English", "English") : null),
+ originalLanguage,
publisher,
pageCount,
- format ?? _faker.PickRandom(),
- null,
- includeOptionalProperties ? _faker.Random.Int(1, 10) : null,
- null,
- null,
+ format ?? (includeOptionalProperties ? _faker.PickRandom() : null),
+ edition,
+ volumeNumber ?? (includeOptionalProperties ? _faker.Random.Int(1, 10) : null),
+ series,
+ asin,
goodreadsId,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null);
+ lccn,
+ oclcNumber,
+ openLibraryId,
+ libraryThingId,
+ googleBooksId,
+ barnesAndNobleId,
+ appleBooksId,
+ isbns,
+ contributors,
+ ratings,
+ coverImagePath);
}
///
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaLibrary/WrittenContentLibrary/WrittenContentMetadataDtoFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaLibrary/WrittenContentLibrary/WrittenContentMetadataDtoFixture.cs
new file mode 100644
index 00000000..6775e3d6
--- /dev/null
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/DTO/MediaLibrary/WrittenContentLibrary/WrittenContentMetadataDtoFixture.cs
@@ -0,0 +1,65 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Contracts.DTO.Common;
+using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class WrittenContentMetadataDtoFixture
+{
+ ///
+ /// Creates a with the requested values, leaving unspecified properties as .
+ ///
+ /// Optional. The title of the written content.
+ /// Optional. The original title of the written content.
+ /// Optional. A brief description or summary of the written content.
+ /// Optional. The release information of the written content.
+ /// Optional. The genres associated with the written content.
+ /// Optional. The tags that describe or categorize the written content.
+ /// Optional. The language in which the written content is written.
+ /// Optional. The original language of the written content.
+ /// Optional. The name of the publisher of the written content.
+ /// Optional. The number of pages in the written content.
+ /// The created .
+ public WrittenContentMetadataDto Create(
+ string? title = null,
+ string? originalTitle = null,
+ string? description = null,
+ ReleaseInfoDto? releaseInfo = null,
+ List? genres = null,
+ List? tags = null,
+ LanguageInfoDto? language = null,
+ LanguageInfoDto? originalLanguage = null,
+ string? publisher = null,
+ int? pageCount = null)
+ {
+ return new WrittenContentMetadataDto(
+ title,
+ originalTitle,
+ description,
+ releaseInfo,
+ genres,
+ tags,
+ language,
+ originalLanguage,
+ publisher,
+ pageCount);
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Authorization/AddRoleRequestFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Authorization/AddRoleRequestFixture.cs
new file mode 100644
index 00000000..a28b3057
--- /dev/null
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Authorization/AddRoleRequestFixture.cs
@@ -0,0 +1,42 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Contracts.Requests.Authorization;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Contracts.Fixtures.Core.Requests.Authorization;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class AddRoleRequestFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The name of the role.
+ /// Optional. The Ids of the permissions granted to the role.
+ /// The created .
+ public AddRoleRequest Create(
+ string? roleName = null,
+ List? permissions = null)
+ {
+ return new AddRoleRequest(roleName ?? _faker.Commerce.Department(), permissions ?? []);
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Authorization/DeleteRoleRequestFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Authorization/DeleteRoleRequestFixture.cs
new file mode 100644
index 00000000..820d3494
--- /dev/null
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Authorization/DeleteRoleRequestFixture.cs
@@ -0,0 +1,40 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Contracts.Requests.Authorization;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Contracts.Fixtures.Core.Requests.Authorization;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class DeleteRoleRequestFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The Id of the role to delete.
+ /// The created .
+ public DeleteRoleRequest Create(
+ Guid? roleId = null)
+ {
+ return new DeleteRoleRequest(roleId ?? Guid.NewGuid());
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Authorization/GetRolePermissionsRequestFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Authorization/GetRolePermissionsRequestFixture.cs
new file mode 100644
index 00000000..a2a022cf
--- /dev/null
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Authorization/GetRolePermissionsRequestFixture.cs
@@ -0,0 +1,37 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Contracts.Requests.Authorization;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Contracts.Fixtures.Core.Requests.Authorization;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class GetRolePermissionsRequestFixture
+{
+ ///
+ /// Creates a random valid .
+ ///
+ /// The Id of the role whose permissions are retrieved.
+ /// The created .
+ public GetRolePermissionsRequest Create(
+ Guid? roleId = null)
+ {
+ return new GetRolePermissionsRequest(roleId ?? Guid.NewGuid());
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Authorization/GetUserPermissionsRequestFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Authorization/GetUserPermissionsRequestFixture.cs
new file mode 100644
index 00000000..7d597f77
--- /dev/null
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Authorization/GetUserPermissionsRequestFixture.cs
@@ -0,0 +1,37 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Contracts.Requests.Authorization;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Contracts.Fixtures.Core.Requests.Authorization;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class GetUserPermissionsRequestFixture
+{
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The Id of the user whose permissions are retrieved.
+ /// The created .
+ public GetUserPermissionsRequest Create(
+ Guid? userId = null)
+ {
+ return new GetUserPermissionsRequest(userId ?? Guid.NewGuid());
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Authorization/GetUserRoleRequestFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Authorization/GetUserRoleRequestFixture.cs
new file mode 100644
index 00000000..aa32e308
--- /dev/null
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/Authorization/GetUserRoleRequestFixture.cs
@@ -0,0 +1,37 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Contracts.Requests.Authorization;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Contracts.Fixtures.Core.Requests.Authorization;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class GetUserRoleRequestFixture
+{
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The Id of the user whose role is retrieved.
+ /// The created .
+ public GetUserRoleRequest Create(
+ Guid? userId = null)
+ {
+ return new GetUserRoleRequest(userId ?? Guid.NewGuid());
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/AddBookRequestFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/AddBookRequestFixture.cs
index c8f5ad7d..0217fa67 100644
--- a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/AddBookRequestFixture.cs
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/AddBookRequestFixture.cs
@@ -9,6 +9,7 @@ using Lumina.Contracts.Fixtures.Common.Setup;
using Lumina.Contracts.Requests.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
@@ -37,8 +38,48 @@ public class AddBookRequestFixture
///
/// Creates a random valid request to add a book.
///
+ /// Optional. The Id of the media library the book belongs to.
+ /// Optional. The file system path of the book.
+ /// Optional. The written content metadata of the book.
+ /// Optional. The format of the book.
+ /// Optional. The edition of the book.
+ /// Optional. The volume or book number in the series.
+ /// Optional. The series the book is part of.
+ /// Optional. The ASIN of the book.
+ /// Optional. The Goodreads Id of the book.
+ /// Optional. The LCCN of the book.
+ /// Optional. The OCLC number of the book.
+ /// Optional. The Open Library Id of the book.
+ /// Optional. The LibraryThing Id of the book.
+ /// Optional. The Google Books Id of the book.
+ /// Optional. The Barnes and Noble Id of the book.
+ /// Optional. The Apple Books Id of the book.
+ /// Optional. The ISBNs of the book.
+ /// Optional. The contributors of the book.
+ /// Optional. The ratings of the book.
+ /// Whether the properties that are not explicitly provided should be randomized, or left .
/// The created request to add a book.
- public AddBookRequest Create()
+ public AddBookRequest Create(
+ Guid? libraryId = null,
+ string? path = null,
+ WrittenContentMetadataDto? metadata = null,
+ BookFormat? format = null,
+ string? edition = null,
+ float? volumeNumber = null,
+ BookSeriesDto? series = null,
+ string? asin = null,
+ string? goodreadsId = null,
+ string? lccn = null,
+ string? oclcNumber = null,
+ string? openLibraryId = null,
+ string? libraryThingId = null,
+ string? googleBooksId = null,
+ string? barnesAndNobleId = null,
+ string? appleBooksId = null,
+ List? isbns = null,
+ List? contributors = null,
+ List? ratings = null,
+ bool includeOptionalProperties = true)
{
int releaseYear = _random.Next(2000, 2010);
int reReleaseYear = _random.Next(2010, 2020);
@@ -128,7 +169,7 @@ public class AddBookRequestFixture
.RuleFor(e => e.LanguageCode, f => f.Random.String2(2))
.RuleFor(e => e.NativeName, f => f.Random.String2(f.Random.Number(1, 50)));
- Faker metadata = new Faker()
+ Faker metadataFaker = new Faker()
.CustomInstantiator(f => new WrittenContentMetadataDto(
default!,
default,
@@ -210,62 +251,91 @@ public class AddBookRequestFixture
default!,
default!
))
- .RuleFor(x => x.LibraryId, _fixture.Create())
- .RuleFor(x => x.Path, f => f.System.FilePath())
- .RuleFor(x => x.Metadata, metadata)
- .RuleFor(x => x.Format, _fixture.Create())
- .RuleFor(x => x.Edition, f => f.Random.String2(f.Random.Number(1, 50)))
- .RuleFor(x => x.VolumeNumber, _random.Next(1, 3))
- .RuleFor(x => x.ASIN, f => f.Random.String2(10))
- .RuleFor(x => x.GoodreadsId, _random.Next(100000, 500000).ToString())
- .RuleFor(x => x.LCCN, f =>
- {
- string letters = new([.. Enumerable.Range(0, f.Random.Number(0, 3)).Select(_ => f.Random.Char('a', 'z'))]);
- string digits = f.Random.String2(f.Random.Number(8, 10), "0123456789");
- return letters + digits;
- })
- .RuleFor(x => x.OCLCNumber, f =>
- {
- string[] prefixes = ["ocm", "ocn", "on", "(OCoLC)"];
- string prefix = f.Random.ArrayElement(prefixes);
- string number;
- switch (prefix)
- {
- case "ocm":
- number = f.Random.String2(8, "0123456789");
- break;
- case "ocn":
- number = f.Random.String2(f.Random.Number(9, 11), "0123456789");
- break;
- case "on":
- number = f.Random.String2(10, "0123456789");
- break;
- case "(OCoLC)":
- number = f.Random.String2(f.Random.Number(8, 10), "0123456789");
- break;
- default:
- number = f.Random.String2(f.Random.Number(8, 10), "0123456789");
- return number;
- }
- return prefix + number;
- })
- .RuleFor(x => x.OpenLibraryId, f =>
- {
- int firstDigit = f.Random.Number(1, 9);
- string remainingDigits = f.Random.String2(f.Random.Number(0, 6), "0123456789");
- char suffix = f.Random.ArrayElement(['A', 'M', 'W']);
- return $"OL{firstDigit}{remainingDigits}{suffix}";
- })
- .RuleFor(x => x.LibraryThingId, f => f.Random.String2(f.Random.Number(1, 50)))
- .RuleFor(x => x.GoogleBooksId, f =>
- {
- const string VALID_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
- return new string([.. Enumerable.Repeat(VALID_CHARS, 12).Select(s => s[f.Random.Number(VALID_CHARS.Length - 1)])]);
- })
- .RuleFor(x => x.BarnesAndNobleId, f => f.Random.String2(10, "0123456789"))
- .RuleFor(x => x.AppleBooksId, f => $"id{f.Random.Number(1, 999999)}")
- .RuleFor(p => p.ISBNs, f => isbn.Generate(f.Random.Number(1, 5)))
- .RuleFor(p => p.Ratings, f => rating.Generate(f.Random.Number(1, 5)))
- .RuleFor(x => x.Contributors, f => mediaContributor.Generate(f.Random.Number(1, 5)));
+ .RuleFor(x => x.LibraryId, libraryId ?? _fixture.Create())
+ .RuleFor(x => x.Path, f => path ?? f.System.FilePath())
+ .RuleFor(x => x.Metadata, metadata ?? metadataFaker)
+ .RuleFor(x => x.Format, format ?? (includeOptionalProperties ? _fixture.Create() : null))
+ .RuleFor(x => x.Edition, f => edition ?? (includeOptionalProperties ? f.Random.String2(f.Random.Number(1, 50)) : null))
+ .RuleFor(x => x.VolumeNumber, volumeNumber ?? (includeOptionalProperties ? (float?)_random.Next(1, 3) : null))
+ .RuleFor(x => x.Series, series)
+ .RuleFor(x => x.ASIN, f => asin ?? (includeOptionalProperties ? f.Random.String2(10) : null))
+ .RuleFor(x => x.GoodreadsId, goodreadsId ?? (includeOptionalProperties ? _random.Next(100000, 500000).ToString() : null))
+ .RuleFor(x => x.LCCN, f => lccn ?? (includeOptionalProperties ? CreateLccn(f) : null))
+ .RuleFor(x => x.OCLCNumber, f => oclcNumber ?? (includeOptionalProperties ? CreateOclcNumber(f) : null))
+ .RuleFor(x => x.OpenLibraryId, f => openLibraryId ?? (includeOptionalProperties ? CreateOpenLibraryId(f) : null))
+ .RuleFor(x => x.LibraryThingId, f => libraryThingId ?? (includeOptionalProperties ? f.Random.String2(f.Random.Number(1, 50)) : null))
+ .RuleFor(x => x.GoogleBooksId, f => googleBooksId ?? (includeOptionalProperties ? CreateGoogleBooksId(f) : null))
+ .RuleFor(x => x.BarnesAndNobleId, f => barnesAndNobleId ?? (includeOptionalProperties ? f.Random.String2(10, "0123456789") : null))
+ .RuleFor(x => x.AppleBooksId, f => appleBooksId ?? (includeOptionalProperties ? $"id{f.Random.Number(1, 999999)}" : null))
+ .RuleFor(p => p.ISBNs, f => isbns ?? (includeOptionalProperties ? isbn.Generate(f.Random.Number(1, 5)) : null))
+ .RuleFor(p => p.Ratings, f => ratings ?? (includeOptionalProperties ? rating.Generate(f.Random.Number(1, 5)) : null))
+ .RuleFor(x => x.Contributors, f => contributors ?? (includeOptionalProperties ? mediaContributor.Generate(f.Random.Number(1, 5)) : null));
+ }
+
+ ///
+ /// Generates a random LCCN (Library of Congress Control Number).
+ ///
+ /// The faker used to generate the value.
+ /// The generated LCCN.
+ private static string CreateLccn(Faker faker)
+ {
+ string letters = new([.. Enumerable.Range(0, faker.Random.Number(0, 3)).Select(_ => faker.Random.Char('a', 'z'))]);
+ string digits = faker.Random.String2(faker.Random.Number(8, 10), "0123456789");
+ return letters + digits;
+ }
+
+ ///
+ /// Generates a random OCLC number (WorldCat identifier).
+ ///
+ /// The faker used to generate the value.
+ /// The generated OCLC number.
+ private static string CreateOclcNumber(Faker faker)
+ {
+ string[] prefixes = ["ocm", "ocn", "on", "(OCoLC)"];
+ string prefix = faker.Random.ArrayElement(prefixes);
+ string number;
+ switch (prefix)
+ {
+ case "ocm":
+ number = faker.Random.String2(8, "0123456789");
+ break;
+ case "ocn":
+ number = faker.Random.String2(faker.Random.Number(9, 11), "0123456789");
+ break;
+ case "on":
+ number = faker.Random.String2(10, "0123456789");
+ break;
+ case "(OCoLC)":
+ number = faker.Random.String2(faker.Random.Number(8, 10), "0123456789");
+ break;
+ default:
+ number = faker.Random.String2(faker.Random.Number(8, 10), "0123456789");
+ return number;
+ }
+ return prefix + number;
+ }
+
+ ///
+ /// Generates a random Open Library Id.
+ ///
+ /// The faker used to generate the value.
+ /// The generated Open Library Id.
+ private static string CreateOpenLibraryId(Faker faker)
+ {
+ int firstDigit = faker.Random.Number(1, 9);
+ string remainingDigits = faker.Random.String2(faker.Random.Number(0, 6), "0123456789");
+ char suffix = faker.Random.ArrayElement(['A', 'M', 'W']);
+ return $"OL{firstDigit}{remainingDigits}{suffix}";
+ }
+
+ ///
+ /// Generates a random Google Books Id.
+ ///
+ /// The faker used to generate the value.
+ /// The generated Google Books Id.
+ private static string CreateGoogleBooksId(Faker faker)
+ {
+ const string VALID_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
+ return new string([.. Enumerable.Repeat(VALID_CHARS, 12).Select(s => s[faker.Random.Number(VALID_CHARS.Length - 1)])]);
}
}
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/GetBookRequestFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/GetBookRequestFixture.cs
new file mode 100644
index 00000000..92ed937f
--- /dev/null
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/GetBookRequestFixture.cs
@@ -0,0 +1,37 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class GetBookRequestFixture
+{
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The unique identifier of the book to retrieve.
+ /// The created .
+ public GetBookRequest Create(
+ string? id = null)
+ {
+ return new GetBookRequest(id ?? Guid.NewGuid().ToString());
+ }
+
+ ///
+ /// Creates a list of instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/GetBooksLiteRequestFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/GetBooksLiteRequestFixture.cs
index ea878333..b7ea3062 100644
--- a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/GetBooksLiteRequestFixture.cs
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/GetBooksLiteRequestFixture.cs
@@ -26,7 +26,7 @@ public class GetBooksLiteRequestFixture
/// Optional. The maximum number of books to retrieve per page.
/// Optional. The search term used to filter results.
/// Optional. The alpha key used to filter the results by the first character of their title, for the alpha picker.
- /// Optional. Whether the leading "The " prefix of a title should be ignored when computing the alpha key, or not.
+ /// Optional. Whether the leading "The " prefix of a title should be ignored when computing the alpha key, or not.
/// Optional. The name of the field by which to sort the results.
/// Optional. The direction in which to sort the results.
/// The created .
@@ -36,7 +36,7 @@ public class GetBooksLiteRequestFixture
int? perPage = null,
string? searchTerm = null,
string? filterAlphaKey = null,
- bool ignoreThePrefixForAlphaPicker = false,
+ bool shouldIgnoreThePrefixForAlphaPicker = false,
string? sortBy = null,
SortOrder? sortOrder = null)
{
@@ -46,7 +46,7 @@ public class GetBooksLiteRequestFixture
PerPage: perPage ?? _faker.Random.Number(1, 200),
SearchTerm: searchTerm ?? _faker.Lorem.Word(),
FilterAlphaKey: filterAlphaKey,
- IgnoreThePrefixForAlphaPicker: ignoreThePrefixForAlphaPicker,
+ ShouldIgnoreThePrefixForAlphaPicker: shouldIgnoreThePrefixForAlphaPicker,
SortBy: sortBy ?? _faker.Lorem.Word(),
SortOrder: sortOrder ?? _faker.PickRandom()
);
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/Authentication/ChangePasswordResponseFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/Authentication/ChangePasswordResponseFixture.cs
new file mode 100644
index 00000000..0f15870a
--- /dev/null
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/Authentication/ChangePasswordResponseFixture.cs
@@ -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;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class ChangePasswordResponseFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. Whether the password was changed.
+ /// The created .
+ public ChangePasswordResponse Create(
+ bool? isPasswordChanged = null)
+ {
+ return new ChangePasswordResponse(isPasswordChanged ?? _faker.Random.Bool());
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/Authentication/LoginResponseFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/Authentication/LoginResponseFixture.cs
new file mode 100644
index 00000000..43b60891
--- /dev/null
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/Authentication/LoginResponseFixture.cs
@@ -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;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class LoginResponseFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The Id of the authenticated user.
+ /// Optional. The username of the authenticated user.
+ /// Optional. The authentication token of the user.
+ /// Optional. Whether the user uses two-factor authentication.
+ /// The created .
+ 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());
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/Authentication/RecoverPasswordResponseFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/Authentication/RecoverPasswordResponseFixture.cs
new file mode 100644
index 00000000..a0a338de
--- /dev/null
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/Authentication/RecoverPasswordResponseFixture.cs
@@ -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;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class RecoverPasswordResponseFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. Whether the password was reset.
+ /// The created .
+ public RecoverPasswordResponse Create(
+ bool? isPasswordReset = null)
+ {
+ return new RecoverPasswordResponse(isPasswordReset ?? _faker.Random.Bool());
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/Authorization/AuthorizationResponseFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/Authorization/AuthorizationResponseFixture.cs
new file mode 100644
index 00000000..737bfaeb
--- /dev/null
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/Authorization/AuthorizationResponseFixture.cs
@@ -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;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class AuthorizationResponseFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The Id of the user.
+ /// Optional. The role of the user.
+ /// Optional. The permissions of the user.
+ /// The created .
+ public AuthorizationResponse Create(
+ Guid? userId = null,
+ string? role = null,
+ IReadOnlySet? permissions = null)
+ {
+ return new AuthorizationResponse(
+ userId ?? Guid.NewGuid(),
+ role,
+ permissions ?? new HashSet());
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/Authorization/RoleResponseFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/Authorization/RoleResponseFixture.cs
new file mode 100644
index 00000000..1fdcad3f
--- /dev/null
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/Authorization/RoleResponseFixture.cs
@@ -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;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class RoleResponseFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The Id of the role.
+ /// Optional. The name of the role.
+ /// The created .
+ public RoleResponse Create(
+ Guid? id = null,
+ string? roleName = null)
+ {
+ return new RoleResponse(id ?? Guid.NewGuid(), roleName ?? _faker.Commerce.Department());
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/FileSystemManagement/FileSystem/FileSystemTypeResponseFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/FileSystemManagement/FileSystem/FileSystemTypeResponseFixture.cs
new file mode 100644
index 00000000..9a33d454
--- /dev/null
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/FileSystemManagement/FileSystem/FileSystemTypeResponseFixture.cs
@@ -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;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class FileSystemTypeResponseFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The type of the file system platform.
+ /// The created .
+ public FileSystemTypeResponse Create(
+ PlatformType? platformType = null)
+ {
+ return new FileSystemTypeResponse(platformType ?? _faker.PickRandom());
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/FileSystemManagement/Path/PathExistsResponseFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/FileSystemManagement/Path/PathExistsResponseFixture.cs
new file mode 100644
index 00000000..3d0d53bf
--- /dev/null
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/FileSystemManagement/Path/PathExistsResponseFixture.cs
@@ -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;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class PathExistsResponseFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. Whether the path exists.
+ /// The created .
+ public PathExistsResponse Create(
+ bool? exists = null)
+ {
+ return new PathExistsResponse(exists ?? _faker.Random.Bool());
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/FileSystemManagement/Path/PathValidResponseFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/FileSystemManagement/Path/PathValidResponseFixture.cs
new file mode 100644
index 00000000..d3f9fb85
--- /dev/null
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/FileSystemManagement/Path/PathValidResponseFixture.cs
@@ -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;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class PathValidResponseFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. Whether the path is valid.
+ /// The created .
+ public PathValidResponse Create(
+ bool? isValid = null)
+ {
+ return new PathValidResponse(isValid ?? _faker.Random.Bool());
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/FileSystemManagement/Thumbnails/ThumbnailResponseFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/FileSystemManagement/Thumbnails/ThumbnailResponseFixture.cs
index a3112552..9ee8b49e 100644
--- a/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/FileSystemManagement/Thumbnails/ThumbnailResponseFixture.cs
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/FileSystemManagement/Thumbnails/ThumbnailResponseFixture.cs
@@ -15,6 +15,8 @@ namespace Lumina.Contracts.Fixtures.Core.Responses.FileSystemManagement.Thumbnai
[ExcludeFromCodeCoverage]
public class ThumbnailResponseFixture
{
+ private readonly Faker _faker = new();
+
///
/// Creates a random valid .
///
@@ -23,10 +25,9 @@ public class ThumbnailResponseFixture
/// The created .
public ThumbnailResponse Create(ImageType? type = null, byte[]? bytes = null)
{
- Faker faker = new();
return new ThumbnailResponse(
- type ?? faker.PickRandom(),
- bytes ?? faker.Random.Bytes(20)
+ type ?? _faker.PickRandom(),
+ bytes ?? _faker.Random.Bytes(20)
);
}
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/MediaLibrary/Management/MediaLibraryScanResponseFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/MediaLibrary/Management/MediaLibraryScanResponseFixture.cs
new file mode 100644
index 00000000..3b9610ef
--- /dev/null
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/MediaLibrary/Management/MediaLibraryScanResponseFixture.cs
@@ -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;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class MediaLibraryScanResponseFixture
+{
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The Id of the media library scan.
+ /// Optional. The Id of the media library the scan belongs to.
+ /// The created .
+ public MediaLibraryScanResponse Create(
+ Guid? scanId = null,
+ Guid? libraryId = null)
+ {
+ return new MediaLibraryScanResponse(scanId ?? Guid.NewGuid(), libraryId ?? Guid.NewGuid());
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookResponseFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookResponseFixture.cs
index da74bf7d..e7dd6e27 100644
--- a/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookResponseFixture.cs
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/MediaLibrary/WrittenContentLibrary/BookLibrary/Books/BookResponseFixture.cs
@@ -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)
);
}
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/UsersManagement/InitializationResponseFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/UsersManagement/InitializationResponseFixture.cs
new file mode 100644
index 00000000..1d48b9ce
--- /dev/null
+++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Responses/UsersManagement/InitializationResponseFixture.cs
@@ -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;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class InitializationResponseFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. Whether the application is initialized.
+ /// The created .
+ public InitializationResponse Create(
+ bool? isInitialized = null)
+ {
+ return new InitializationResponse(isInitialized ?? _faker.Random.Bool());
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Contracts.Fixtures/Responses/Common/PaginatedResponseFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Responses/Common/PaginatedResponseFixture.cs
new file mode 100644
index 00000000..007d5790
--- /dev/null
+++ b/tests/Common/Lumina.Contracts.Fixtures/Responses/Common/PaginatedResponseFixture.cs
@@ -0,0 +1,55 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Contracts.Responses.Common;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Contracts.Fixtures.Responses.Common;
+
+///
+/// Fixture class for the record.
+///
+/// The type of the data items contained in the paginated response.
+[ExcludeFromCodeCoverage]
+public class PaginatedResponseFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The collection of data items.
+ /// Optional. The current page number.
+ /// Optional. The number of items per page.
+ /// Optional. The total number of elements available.
+ /// Optional. The total number of pages.
+ /// The created .
+ public PaginatedResponse Create(
+ IReadOnlyList? data = null,
+ int? currentPage = null,
+ int? perPage = null,
+ int? count = null,
+ int? numberOfPages = null)
+ {
+ return new PaginatedResponse
+ {
+ Data = data ?? [],
+ CurrentPage = currentPage ?? _faker.Random.Int(1, 10),
+ PerPage = perPage ?? _faker.Random.Int(1, 100),
+ Count = count ?? _faker.Random.Int(0, 1000),
+ NumberOfPages = numberOfPages ?? _faker.Random.Int(1, 100)
+ };
+ }
+
+ ///
+ /// Creates a list of instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List> CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/WrittenContentLibraryBoundedContext/BookLibraryAggregate/BookFixture.cs b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/WrittenContentLibraryBoundedContext/BookLibraryAggregate/BookFixture.cs
index 19f28754..5b4a81cf 100644
--- a/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/WrittenContentLibraryBoundedContext/BookLibraryAggregate/BookFixture.cs
+++ b/tests/Common/Lumina.Domain.Fixtures/Core/BoundedContexts/WrittenContentLibraryBoundedContext/BookLibraryAggregate/BookFixture.cs
@@ -50,7 +50,7 @@ public class BookFixture
_fixture.Create(),
_fixture.Create(),
_fixture.Create>(),
- _fixture.Create>(),
+ _fixture.Create>(),
_fixture.Create>(),
_fixture.Create>(),
_fixture.Create>(),
diff --git a/tests/Common/Lumina.Infrastructure.Fixtures/Common/Models/DTO/Configuration/ThemeEngineOptionsDtoFixture.cs b/tests/Common/Lumina.Infrastructure.Fixtures/Common/Models/DTO/Configuration/ThemeEngineOptionsDtoFixture.cs
index fa0c6533..43c545af 100644
--- a/tests/Common/Lumina.Infrastructure.Fixtures/Common/Models/DTO/Configuration/ThemeEngineOptionsDtoFixture.cs
+++ b/tests/Common/Lumina.Infrastructure.Fixtures/Common/Models/DTO/Configuration/ThemeEngineOptionsDtoFixture.cs
@@ -15,6 +15,8 @@ namespace Lumina.Infrastructure.Fixtures.Common.Models.DTO.Configuration;
[ExcludeFromCodeCoverage]
public class ThemeEngineOptionsDtoFixture
{
+ private readonly Faker _faker = new();
+
///
/// Creates a random valid .
///
@@ -35,16 +37,15 @@ public class ThemeEngineOptionsDtoFixture
long? maxSingleFileBytes = null,
int? maxEntries = null)
{
- Faker faker = new();
return new ThemeEngineOptionsDto
{
- StoragePath = storagePath ?? faker.System.DirectoryPath(),
- BundledThemesPath = bundledThemesPath ?? faker.System.DirectoryPath(),
- DefaultThemeId = defaultThemeId ?? faker.Lorem.Word(),
- MaxArchiveBytes = maxArchiveBytes ?? faker.Random.Long(1_000_000, 100_000_000),
- MaxExpandedBytes = maxExpandedBytes ?? faker.Random.Long(10_000_000, 500_000_000),
- MaxSingleFileBytes = maxSingleFileBytes ?? faker.Random.Long(1_000_000, 50_000_000),
- MaxEntries = maxEntries ?? faker.Random.Int(1, 1000)
+ StoragePath = storagePath ?? _faker.System.DirectoryPath(),
+ BundledThemesPath = bundledThemesPath ?? _faker.System.DirectoryPath(),
+ DefaultThemeId = defaultThemeId ?? _faker.Lorem.Word(),
+ MaxArchiveBytes = maxArchiveBytes ?? _faker.Random.Long(1_000_000, 100_000_000),
+ MaxExpandedBytes = maxExpandedBytes ?? _faker.Random.Long(10_000_000, 500_000_000),
+ MaxSingleFileBytes = maxSingleFileBytes ?? _faker.Random.Long(1_000_000, 50_000_000),
+ MaxEntries = maxEntries ?? _faker.Random.Int(1, 1000)
};
}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Api/StubApiHttpClient.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Api/StubApiHttpClient.cs
index 4aa21845..2b3c67cf 100644
--- a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Api/StubApiHttpClient.cs
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Api/StubApiHttpClient.cs
@@ -10,7 +10,6 @@ using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
-using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
@@ -29,6 +28,7 @@ public class StubApiHttpClient : IApiHttpClient
private readonly Dictionary> _postResponseFactories = [];
private readonly Dictionary> _putResponseFactories = [];
private readonly HashSet _deleteSuccessEndpoints = [];
+ private BlobDataDto? _blobResponse;
///
/// Gets the authorization response returned for the auth/get-authorization endpoint.
@@ -167,6 +167,15 @@ public class StubApiHttpClient : IApiHttpClient
_deleteSuccessEndpoints.Add(endpoint);
}
+ ///
+ /// Registers the blob response returned when a blob endpoint is called.
+ ///
+ /// The blob response to return.
+ public void RegisterBlobResponse(BlobDataDto blob)
+ {
+ _blobResponse = blob;
+ }
+
///
/// Resets all registered responses and captured requests, keeping only the default responses.
///
@@ -176,6 +185,7 @@ public class StubApiHttpClient : IApiHttpClient
_postResponseFactories.Clear();
_putResponseFactories.Clear();
_deleteSuccessEndpoints.Clear();
+ _blobResponse = null;
GetEndpointsCalled.Clear();
PostRequests.Clear();
PutRequests.Clear();
@@ -222,6 +232,8 @@ public class StubApiHttpClient : IApiHttpClient
/// A model containing the deserialized blob.
public Task GetBlobAsync(string endpoint, CancellationToken cancellationToken = default)
{
+ if (_blobResponse is not null)
+ return Task.FromResult(_blobResponse);
throw new NotSupportedException("Blob retrieval is not supported by the test stub.");
}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Authorization/PermissionDtoFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Authorization/PermissionDtoFixture.cs
new file mode 100644
index 00000000..0c21230c
--- /dev/null
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Authorization/PermissionDtoFixture.cs
@@ -0,0 +1,46 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Presentation.Web.Common.DTO.Authorization;
+using Lumina.Presentation.Web.Common.Enums.Authorization;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Authorization;
+
+///
+/// Fixture class for generating test data.
+///
+[ExcludeFromCodeCoverage]
+public class PermissionDtoFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a new instance with randomized test data.
+ ///
+ /// Optional unique identifier of the permission.
+ /// Optional name of the permission.
+ /// A configured instance.
+ public PermissionDto Create(
+ Guid? id = null,
+ AuthorizationPermission? permission = null)
+ {
+ return new PermissionDto(
+ Id: id ?? Guid.NewGuid(),
+ PermissionName: permission ?? _faker.Random.Enum()
+ );
+ }
+
+ ///
+ /// Creates multiple instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Authorization/RoleDtoFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Authorization/RoleDtoFixture.cs
index 858f0dc7..855fc922 100644
--- a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Authorization/RoleDtoFixture.cs
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Authorization/RoleDtoFixture.cs
@@ -15,6 +15,8 @@ namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Authorization;
[ExcludeFromCodeCoverage]
public class RoleDtoFixture
{
+ private readonly Faker _faker = new();
+
///
/// Creates a new instance with randomized test data.
///
@@ -23,10 +25,9 @@ public class RoleDtoFixture
/// A configured instance.
public RoleDto Create(Guid? id = null, string? roleName = null)
{
- Faker faker = new();
return new RoleDto(
Id: id ?? Guid.NewGuid(),
- RoleName: roleName ?? faker.Commerce.Department()
+ RoleName: roleName ?? _faker.Commerce.Department()
);
}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Authorization/RolePermissionsDtoFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Authorization/RolePermissionsDtoFixture.cs
new file mode 100644
index 00000000..9b78d6ff
--- /dev/null
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Authorization/RolePermissionsDtoFixture.cs
@@ -0,0 +1,43 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.DTO.Authorization;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Authorization;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class RolePermissionsDtoFixture
+{
+ private readonly RoleDtoFixture _roleDtoFixture = new();
+ private readonly PermissionDtoFixture _permissionDtoFixture = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The authorization role.
+ /// Optional. The permissions of the authorization role.
+ /// The created .
+ public RolePermissionsDto Create(
+ RoleDto? role = null,
+ PermissionDto[]? permissions = null)
+ {
+ return new RolePermissionsDto(
+ role ?? _roleDtoFixture.Create(),
+ permissions ?? [.. _permissionDtoFixture.CreateMany()]);
+ }
+
+ ///
+ /// Creates a list of instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Common/ProblemDetailsDtoFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Common/ProblemDetailsDtoFixture.cs
new file mode 100644
index 00000000..fbb0e8e7
--- /dev/null
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Common/ProblemDetailsDtoFixture.cs
@@ -0,0 +1,54 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Presentation.Web.Common.DTO.Common;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Common;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class ProblemDetailsDtoFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The URI reference that identifies the problem type.
+ /// Optional. A short, human-readable summary of the problem type.
+ /// Optional. The HTTP status code generated by the server.
+ /// Optional. A detailed explanation specific to this occurrence of the problem.
+ /// Optional. A URI reference that identifies the specific occurrence of the problem.
+ /// The created .
+ public ProblemDetailsDto Create(
+ string? type = null,
+ string? title = null,
+ int? status = null,
+ string? detail = null,
+ string? instance = null)
+ {
+ return new ProblemDetailsDto
+ {
+ Type = type ?? "https://tools.ietf.org/html/rfc4918#section-11.2",
+ Title = title ?? _faker.Lorem.Word(),
+ Status = status ?? _faker.Random.Int(400, 599),
+ Detail = detail ?? _faker.Lorem.Sentence(),
+ Instance = instance
+ };
+ }
+
+ ///
+ /// Creates a list of instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Configuration/EncryptionSettingsDtoFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Configuration/EncryptionSettingsDtoFixture.cs
new file mode 100644
index 00000000..38c39d50
--- /dev/null
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Configuration/EncryptionSettingsDtoFixture.cs
@@ -0,0 +1,42 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Presentation.Web.Common.DTO.Configuration;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Configuration;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class EncryptionSettingsDtoFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The secret key used to encrypt data.
+ /// The created .
+ public EncryptionSettingsDto Create(
+ string? secretKey = null)
+ {
+ return new EncryptionSettingsDto
+ {
+ SecretKey = secretKey ?? _faker.Random.String2(44, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=")
+ };
+ }
+
+ ///
+ /// Creates a list of instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Configuration/ServerConfigurationDtoFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Configuration/ServerConfigurationDtoFixture.cs
new file mode 100644
index 00000000..f07bfccd
--- /dev/null
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Configuration/ServerConfigurationDtoFixture.cs
@@ -0,0 +1,48 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Presentation.Web.Common.DTO.Configuration;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Configuration;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class ServerConfigurationDtoFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The remote API server path version.
+ /// Optional. The remote API server path.
+ /// Optional. The remote API server port.
+ /// The created .
+ public ServerConfigurationDto Create(
+ char? apiVersion = null,
+ string? baseAddress = null,
+ ushort? port = null)
+ {
+ return new ServerConfigurationDto
+ {
+ ApiVersion = apiVersion ?? _faker.Random.Char('1', '9'),
+ BaseAddress = baseAddress ?? "http://localhost",
+ Port = port ?? _faker.Random.UShort()
+ };
+ }
+
+ ///
+ /// Creates a list of instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/FileSystemManagement/BlobDataDtoFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/FileSystemManagement/BlobDataDtoFixture.cs
new file mode 100644
index 00000000..2f1a331c
--- /dev/null
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/FileSystemManagement/BlobDataDtoFixture.cs
@@ -0,0 +1,45 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class BlobDataDtoFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The binary data as a byte array.
+ /// Optional. The content type (MIME type) of the blob data.
+ /// The created .
+ public BlobDataDto Create(
+ byte[]? data = null,
+ string? contentType = null)
+ {
+ return new BlobDataDto
+ {
+ Data = data ?? _faker.Random.Bytes(32),
+ ContentType = contentType ?? _faker.System.MimeType()
+ };
+ }
+
+ ///
+ /// Creates a list of instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/FileSystemManagement/DirectoryDtoFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/FileSystemManagement/DirectoryDtoFixture.cs
new file mode 100644
index 00000000..ce8f3e32
--- /dev/null
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/FileSystemManagement/DirectoryDtoFixture.cs
@@ -0,0 +1,54 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.IO;
+using System.Linq;
+#endregion
+
+namespace Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class DirectoryDtoFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The full path to the directory.
+ /// Optional. The name of the directory.
+ /// Optional. The children items of the directory.
+ /// Whether the directory should include children items, or an empty collection.
+ /// The created .
+ public DirectoryDto Create(
+ string? path = null,
+ string? name = null,
+ List? items = null,
+ bool includeItems = false)
+ {
+ string generatedPath = _faker.System.DirectoryPath();
+ return new DirectoryDto
+ {
+ Path = path ?? generatedPath,
+ Name = name ?? Path.GetFileName(generatedPath),
+ DateCreated = _faker.Date.Past(),
+ DateModified = _faker.Date.Recent(),
+ Items = includeItems ? (items ?? []) : []
+ };
+ }
+
+ ///
+ /// Creates a list of instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/FileSystemManagement/FileDtoFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/FileSystemManagement/FileDtoFixture.cs
new file mode 100644
index 00000000..fc636ac0
--- /dev/null
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/FileSystemManagement/FileDtoFixture.cs
@@ -0,0 +1,52 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.IO;
+using System.Linq;
+#endregion
+
+namespace Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
+
+///
+/// Fixture class for generating test data.
+///
+[ExcludeFromCodeCoverage]
+public class FileDtoFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a new instance with randomized test data.
+ ///
+ /// Optional. The full path to the file.
+ /// Optional. The name of the file.
+ /// Optional. The size of the file, in bytes.
+ /// A configured instance.
+ public FileDto Create(
+ string? path = null,
+ string? name = null,
+ long? size = null)
+ {
+ string generatedPath = _faker.System.FilePath();
+ return new FileDto
+ {
+ Path = path ?? generatedPath,
+ Name = name ?? Path.GetFileName(generatedPath),
+ DateCreated = _faker.Date.Past(),
+ DateModified = _faker.Date.Recent(),
+ Size = size ?? _faker.Random.Long(0, 10_000_000)
+ };
+ }
+
+ ///
+ /// Creates multiple instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/FileSystemManagement/FileSystemTreeNodeDtoFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/FileSystemManagement/FileSystemTreeNodeDtoFixture.cs
new file mode 100644
index 00000000..513aaae0
--- /dev/null
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/FileSystemManagement/FileSystemTreeNodeDtoFixture.cs
@@ -0,0 +1,54 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
+using Lumina.Presentation.Web.Common.Enums.FileSystem;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.IO;
+using System.Linq;
+#endregion
+
+namespace Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
+
+///
+/// Fixture class for generating test data.
+///
+[ExcludeFromCodeCoverage]
+public class FileSystemTreeNodeDtoFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a new instance with randomized test data.
+ ///
+ /// Optional. The full path of the file or directory.
+ /// Optional. The name of the file or directory.
+ /// Optional. The type of the item, indicating whether it is a file, directory, or drive.
+ /// A configured instance.
+ public FileSystemTreeNodeDto Create(
+ string? path = null,
+ string? name = null,
+ FileSystemItemType? itemType = null)
+ {
+ string generatedPath = _faker.System.FilePath();
+ return new FileSystemTreeNodeDto
+ {
+ Path = path ?? generatedPath,
+ Name = name ?? Path.GetFileName(generatedPath),
+ ItemType = itemType ?? _faker.PickRandom(),
+ IsExpanded = _faker.Random.Bool(),
+ ChildrenLoaded = _faker.Random.Bool(),
+ Children = []
+ };
+ }
+
+ ///
+ /// Creates multiple instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/FileSystemManagement/FileSystemTypeDtoFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/FileSystemManagement/FileSystemTypeDtoFixture.cs
new file mode 100644
index 00000000..e4c61cb2
--- /dev/null
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/FileSystemManagement/FileSystemTypeDtoFixture.cs
@@ -0,0 +1,43 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
+using Lumina.Presentation.Web.Common.Enums.FileSystem;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
+
+///
+/// Fixture class for generating test data.
+///
+[ExcludeFromCodeCoverage]
+public class FileSystemTypeDtoFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a new instance with randomized test data.
+ ///
+ /// Optional file system platform type.
+ /// A configured instance.
+ public FileSystemTypeDto Create(
+ PlatformType? platformType = null)
+ {
+ return new FileSystemTypeDto
+ {
+ PlatformType = platformType ?? _faker.PickRandom()
+ };
+ }
+
+ ///
+ /// Creates multiple instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/FileSystemManagement/PathExistsDtoFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/FileSystemManagement/PathExistsDtoFixture.cs
new file mode 100644
index 00000000..8b65f0bb
--- /dev/null
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/FileSystemManagement/PathExistsDtoFixture.cs
@@ -0,0 +1,41 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
+
+///
+/// Fixture class for generating test data.
+///
+[ExcludeFromCodeCoverage]
+public class PathExistsDtoFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a new instance with randomized test data.
+ ///
+ /// Optional value indicating whether a file system path exists or not.
+ /// A configured instance.
+ public PathExistsDto Create(
+ bool? exists = null)
+ {
+ return new PathExistsDto(
+ Exists: exists ?? _faker.Random.Bool()
+ );
+ }
+
+ ///
+ /// Creates multiple instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/FileSystemManagement/PathSegmentDtoFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/FileSystemManagement/PathSegmentDtoFixture.cs
new file mode 100644
index 00000000..99d78637
--- /dev/null
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/FileSystemManagement/PathSegmentDtoFixture.cs
@@ -0,0 +1,42 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
+
+///
+/// Fixture class for generating test data.
+///
+[ExcludeFromCodeCoverage]
+public class PathSegmentDtoFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a new instance with randomized test data.
+ ///
+ /// Optional. The returned path.
+ /// A configured instance.
+ public PathSegmentDto Create(
+ string? path = null)
+ {
+ return new PathSegmentDto
+ {
+ Path = path ?? _faker.System.FilePath()
+ };
+ }
+
+ ///
+ /// Creates multiple instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/FileSystemManagement/PathSeparatorDtoFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/FileSystemManagement/PathSeparatorDtoFixture.cs
new file mode 100644
index 00000000..c96d8615
--- /dev/null
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/FileSystemManagement/PathSeparatorDtoFixture.cs
@@ -0,0 +1,41 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
+
+///
+/// Fixture class for generating test data.
+///
+[ExcludeFromCodeCoverage]
+public class PathSeparatorDtoFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a new instance with randomized test data.
+ ///
+ /// Optional file system path separator.
+ /// A configured instance.
+ public PathSeparatorDto Create(
+ string? separator = null)
+ {
+ return new PathSeparatorDto(
+ Separator: separator ?? (_faker.Random.Bool() ? "\\" : "/")
+ );
+ }
+
+ ///
+ /// Creates multiple instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/FileSystemManagement/PathValidDtoFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/FileSystemManagement/PathValidDtoFixture.cs
new file mode 100644
index 00000000..3bf00678
--- /dev/null
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/FileSystemManagement/PathValidDtoFixture.cs
@@ -0,0 +1,41 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
+
+///
+/// Fixture class for generating test data.
+///
+[ExcludeFromCodeCoverage]
+public class PathValidDtoFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a new instance with randomized test data.
+ ///
+ /// Optional value indicating whether a file system path is valid or not.
+ /// A configured instance.
+ public PathValidDto Create(
+ bool? isValid = null)
+ {
+ return new PathValidDto(
+ IsValid: isValid ?? _faker.Random.Bool()
+ );
+ }
+
+ ///
+ /// Creates multiple instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Libraries/BookLiteDtoFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Libraries/BookLiteDtoFixture.cs
new file mode 100644
index 00000000..c9332206
--- /dev/null
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Libraries/BookLiteDtoFixture.cs
@@ -0,0 +1,56 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Presentation.Web.Common.DTO.Libraries;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Libraries;
+
+///
+/// Fixture class for the class.
+///
+[ExcludeFromCodeCoverage]
+public class BookLiteDtoFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The Id of the book.
+ /// Optional. The title of the book.
+ /// Optional. The release year of the book.
+ /// Optional. The path of the image representing the cover of the book.
+ /// Whether the release year should be included, or forced to .
+ /// Whether the cover path should be included, or forced to .
+ /// The created .
+ public BookLiteDto Create(
+ Guid? id = null,
+ string? title = null,
+ int? releaseYear = null,
+ string? coverPath = null,
+ bool includeReleaseYear = false,
+ bool includeCoverPath = false)
+ {
+ return new BookLiteDto
+ {
+ Id = id ?? _faker.Random.Guid(),
+ Title = title ?? _faker.Lorem.Sentence(3),
+ ReleaseYear = includeReleaseYear ? (releaseYear ?? _faker.Random.Int(1900, 2024)) : null,
+ CoverPath = includeCoverPath ? (coverPath ?? _faker.System.FilePath()) : null
+ };
+ }
+
+ ///
+ /// Creates a list of instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Libraries/LibraryScanJobProgressDtoFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Libraries/LibraryScanJobProgressDtoFixture.cs
new file mode 100644
index 00000000..8419793d
--- /dev/null
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Libraries/LibraryScanJobProgressDtoFixture.cs
@@ -0,0 +1,53 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Presentation.Web.Common.DTO.Libraries;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Libraries;
+
+///
+/// Fixture class for generating test data.
+///
+[ExcludeFromCodeCoverage]
+public class LibraryScanJobProgressDtoFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a new instance with randomized test data.
+ ///
+ /// Optional number of completed items of the media library scan job.
+ /// Optional total number of items of the media library scan job.
+ /// Optional current operation being performed by the media library scan job.
+ /// Optional completion ratio of the media library scan job, as a percentage.
+ /// A configured instance.
+ public LibraryScanJobProgressDto Create(
+ int? completedItems = null,
+ int? totalItems = null,
+ string? currentOperation = null,
+ decimal? progressPercentage = null)
+ {
+ int completed = completedItems ?? _faker.Random.Int(0, 100);
+ int total = totalItems ?? _faker.Random.Int(completed, 100);
+ return new LibraryScanJobProgressDto
+ {
+ CompletedItems = completed,
+ TotalItems = total,
+ CurrentOperation = currentOperation ?? _faker.Hacker.Verb(),
+ ProgressPercentage = progressPercentage ?? (total > 0 ? (decimal)completed / total * 100 : 0)
+ };
+ }
+
+ ///
+ /// Creates multiple instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Libraries/LibraryScanProgressDtoFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Libraries/LibraryScanProgressDtoFixture.cs
new file mode 100644
index 00000000..08af8992
--- /dev/null
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Libraries/LibraryScanProgressDtoFixture.cs
@@ -0,0 +1,66 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Presentation.Web.Common.DTO.Libraries;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Libraries;
+
+///
+/// Fixture class for generating test data.
+///
+[ExcludeFromCodeCoverage]
+public class LibraryScanProgressDtoFixture
+{
+ private readonly Faker _faker = new();
+
+ private readonly LibraryScanJobProgressDtoFixture _libraryScanJobProgressDtoFixture = new();
+
+ ///
+ /// Creates a new instance with randomized test data.
+ ///
+ /// Optional unique identifier of the media library scan.
+ /// Optional unique identifier of the user initiating the media library scan.
+ /// Optional unique identifier of the media library that is scanned.
+ /// Optional number of completed jobs of the media library scan job.
+ /// Optional total number of jobs of the media library scan job.
+ /// Optional status of the media library scan.
+ /// Whether the current job progress should be included, or forced to .
+ /// A configured instance.
+ public LibraryScanProgressDto Create(
+ Guid? scanId = null,
+ Guid? userId = null,
+ Guid? libraryId = null,
+ int? completedJobs = null,
+ int? totalJobs = null,
+ string? status = null,
+ bool includeCurrentJobProgress = false)
+ {
+ int completed = completedJobs ?? _faker.Random.Int(0, 10);
+ int total = totalJobs ?? _faker.Random.Int(completed, 10);
+ return new LibraryScanProgressDto
+ {
+ ScanId = scanId ?? Guid.NewGuid(),
+ UserId = userId ?? Guid.NewGuid(),
+ LibraryId = libraryId ?? Guid.NewGuid(),
+ CompletedJobs = completed,
+ TotalJobs = total,
+ CurrentJobProgress = includeCurrentJobProgress ? _libraryScanJobProgressDtoFixture.Create() : null,
+ Status = status ?? _faker.PickRandom("Running", "Completed", "Failed"),
+ OverallProgressPercentage = total > 0 ? (decimal)completed / total * 100 : 0
+ };
+ }
+
+ ///
+ /// Creates multiple instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Libraries/PaginatedBookLiteDtoFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Libraries/PaginatedBookLiteDtoFixture.cs
new file mode 100644
index 00000000..8bf4938f
--- /dev/null
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Libraries/PaginatedBookLiteDtoFixture.cs
@@ -0,0 +1,54 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Presentation.Web.Common.DTO.Libraries;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Libraries;
+
+///
+/// Fixture class for generating test data.
+///
+[ExcludeFromCodeCoverage]
+public class PaginatedBookLiteDtoFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a new instance with randomized test data.
+ ///
+ /// Optional collection of lightweight book elements.
+ /// Optional current page number in a paginated collection.
+ /// Optional number of items to include per page in paginated results.
+ /// Optional total number of elements available in the paginated result set.
+ /// Optional total number of pages based on the elements available and per page.
+ /// A configured instance.
+ public PaginatedBookLiteDto Create(
+ IReadOnlyList? data = null,
+ int? currentPage = null,
+ int? perPage = null,
+ int? count = null,
+ int? numberOfPages = null)
+ {
+ return new PaginatedBookLiteDto
+ {
+ Data = data ?? [],
+ CurrentPage = currentPage ?? _faker.Random.Int(1, 10),
+ PerPage = perPage ?? _faker.Random.Int(1, 100),
+ Count = count ?? _faker.Random.Int(0, 1000),
+ NumberOfPages = numberOfPages ?? _faker.Random.Int(1, 100)
+ };
+ }
+
+ ///
+ /// Creates multiple instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeInfoDtoFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeInfoDtoFixture.cs
index 7fa24e10..a6265310 100644
--- a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeInfoDtoFixture.cs
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeInfoDtoFixture.cs
@@ -1,7 +1,6 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Presentation.Web.Common.DTO.Themes;
-using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
@@ -15,6 +14,8 @@ namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Themes;
[ExcludeFromCodeCoverage]
public class ThemeInfoDtoFixture
{
+ private readonly Faker _faker = new();
+
///
/// Creates a new instance with randomized test data.
///
@@ -37,16 +38,15 @@ public class ThemeInfoDtoFixture
bool? isBundled = null,
bool? isDeleted = null)
{
- Faker faker = new();
return new ThemeInfoDto(
- Id: id ?? faker.Lorem.Word(),
- Name: name ?? faker.Commerce.ProductName(),
- Description: description ?? faker.Lorem.Sentence(),
- Author: author ?? faker.Name.FullName(),
- Version: version ?? faker.System.Semver(),
- PreviewUrl: previewUrl ?? $"/theme-assets/{faker.Lorem.Word()}/preview.png",
- IsBundled: isBundled ?? faker.Random.Bool(),
- IsDeleted: isDeleted ?? faker.Random.Bool()
+ Id: id ?? _faker.Lorem.Word(),
+ Name: name ?? _faker.Commerce.ProductName(),
+ Description: description ?? _faker.Lorem.Sentence(),
+ Author: author ?? _faker.Name.FullName(),
+ Version: version ?? _faker.System.Semver(),
+ PreviewUrl: previewUrl ?? $"/theme-assets/{_faker.Lorem.Word()}/preview.png",
+ IsBundled: isBundled ?? _faker.Random.Bool(),
+ IsDeleted: isDeleted ?? _faker.Random.Bool()
);
}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeLayoutPageDtoFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeLayoutPageDtoFixture.cs
new file mode 100644
index 00000000..5632286e
--- /dev/null
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeLayoutPageDtoFixture.cs
@@ -0,0 +1,46 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Presentation.Web.Common.DTO.Themes;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Themes;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class ThemeLayoutPageDtoFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. The title of the page, displayed by the themed shell.
+ /// Optional. The rendered HTML content of the page section.
+ /// Optional. The rendered script element of the page section, when the template defines one.
+ /// The created .
+ public ThemeLayoutPageDto Create(
+ string? title = null,
+ string? content = null,
+ string? script = null)
+ {
+ return new ThemeLayoutPageDto(
+ title ?? _faker.Lorem.Word(),
+ content ?? _faker.Lorem.Paragraph(),
+ script ?? _faker.Lorem.Word());
+ }
+
+ ///
+ /// Creates a list of instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeNavEntryDtoFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeNavEntryDtoFixture.cs
new file mode 100644
index 00000000..76cc62a7
--- /dev/null
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeNavEntryDtoFixture.cs
@@ -0,0 +1,53 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Presentation.Web.Common.DTO.Themes;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Themes;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class ThemeNavEntryDtoFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional label of the entry.
+ /// Optional URL of the link, or for a submenu.
+ /// Whether to set , or when .
+ /// Optional CSS classes of the link.
+ /// Whether to set , or when .
+ /// Optional child links of a submenu.
+ /// The created .
+ public ThemeNavEntryDto Create(
+ string? label = null,
+ string? url = null,
+ bool includeUrl = false,
+ string? cssClass = null,
+ bool includeCssClass = false,
+ IReadOnlyList? children = null)
+ {
+ return new ThemeNavEntryDto(
+ Label: label ?? _faker.Lorem.Word(),
+ Url: includeUrl ? (url ?? _faker.Internet.Url()) : null,
+ CssClass: includeCssClass ? (cssClass ?? _faker.Lorem.Word()) : null,
+ Children: children ?? []);
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeNavMenuDtoFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeNavMenuDtoFixture.cs
index 5016ae36..b2bb7ae1 100644
--- a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeNavMenuDtoFixture.cs
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeNavMenuDtoFixture.cs
@@ -15,6 +15,9 @@ namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Themes;
[ExcludeFromCodeCoverage]
public class ThemeNavMenuDtoFixture
{
+ private readonly Faker _faker = new();
+ private readonly ThemeNavSectionDtoFixture _themeNavSectionDtoFixture = new();
+
///
/// Creates a new instance with randomized test data.
///
@@ -27,57 +30,14 @@ public class ThemeNavMenuDtoFixture
IReadOnlyList? mobileSections = null,
IReadOnlyList? menubarSections = null)
{
- Faker faker = new();
- ThemeNavSectionDto[] generatedSections = [CreateSection()];
+ ThemeNavSectionDto[] generatedSections = [_themeNavSectionDtoFixture.Create()];
return new ThemeNavMenuDto(
- SiteName: siteName ?? faker.Company.CompanyName(),
+ SiteName: siteName ?? _faker.Company.CompanyName(),
MobileSections: mobileSections ?? generatedSections,
MenubarSections: menubarSections ?? generatedSections
);
}
- ///
- /// Creates a single instance with randomized test data.
- ///
- /// Optional label of the section.
- /// Optional entries of the section.
- /// A configured instance.
- public ThemeNavSectionDto CreateSection(string? label = null, IReadOnlyList? items = null)
- {
- Faker faker = new();
- return new ThemeNavSectionDto(
- Label: label ?? faker.Lorem.Word(),
- Items: items ?? [CreateEntry()]
- );
- }
-
- ///
- /// Creates a single instance with randomized test data.
- ///
- /// Optional label of the entry.
- /// Optional URL of the link, or for a submenu.
- /// Whether to set , or when .
- /// Optional CSS classes of the link.
- /// Whether to set , or when .
- /// Optional child links of a submenu.
- /// A configured instance.
- public ThemeNavEntryDto CreateEntry(
- string? label = null,
- string? url = null,
- bool includeUrl = false,
- string? cssClass = null,
- bool includeCssClass = false,
- IReadOnlyList? children = null)
- {
- Faker faker = new();
- return new ThemeNavEntryDto(
- Label: label ?? faker.Lorem.Word(),
- Url: includeUrl ? (url ?? faker.Internet.Url()) : null,
- CssClass: includeCssClass ? (cssClass ?? faker.Lorem.Word()) : null,
- Children: children ?? []
- );
- }
-
///
/// Creates multiple instances with randomized test data.
///
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeNavSectionDtoFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeNavSectionDtoFixture.cs
new file mode 100644
index 00000000..348b85b0
--- /dev/null
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeNavSectionDtoFixture.cs
@@ -0,0 +1,44 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Presentation.Web.Common.DTO.Themes;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Themes;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class ThemeNavSectionDtoFixture
+{
+ private readonly Faker _faker = new();
+ private readonly ThemeNavEntryDtoFixture _themeNavEntryDtoFixture = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional label of the section.
+ /// Optional entries of the section.
+ /// The created .
+ public ThemeNavSectionDto Create(
+ string? label = null,
+ IReadOnlyList? items = null)
+ {
+ return new ThemeNavSectionDto(
+ Label: label ?? _faker.Lorem.Word(),
+ Items: items ?? [_themeNavEntryDtoFixture.Create()]);
+ }
+
+ ///
+ /// Creates a list of .
+ ///
+ /// The number of elements to create.
+ /// The created list.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemePageDtoFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemePageDtoFixture.cs
index 684f568a..eabcf668 100644
--- a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemePageDtoFixture.cs
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemePageDtoFixture.cs
@@ -1,7 +1,6 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Presentation.Web.Common.DTO.Themes;
-using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
@@ -15,6 +14,8 @@ namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Themes;
[ExcludeFromCodeCoverage]
public class ThemePageDtoFixture
{
+ private readonly Faker _faker = new();
+
///
/// Creates a new instance with randomized test data.
///
@@ -29,12 +30,11 @@ public class ThemePageDtoFixture
string? description = null,
IReadOnlyDictionary? pageData = null)
{
- Faker faker = new();
return new ThemePageDto
{
- PageKey = pageKey ?? faker.Lorem.Word(),
- Title = title ?? faker.Lorem.Sentence(),
- Description = description ?? faker.Lorem.Sentence(),
+ PageKey = pageKey ?? _faker.Lorem.Word(),
+ Title = title ?? _faker.Lorem.Sentence(),
+ Description = description ?? _faker.Lorem.Sentence(),
PageData = pageData ?? new Dictionary()
};
}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemePageRenderResultDtoFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemePageRenderResultDtoFixture.cs
new file mode 100644
index 00000000..647af988
--- /dev/null
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemePageRenderResultDtoFixture.cs
@@ -0,0 +1,44 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Presentation.Web.Common.DTO.Themes;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Themes;
+
+///
+/// Fixture class for generating test data.
+///
+[ExcludeFromCodeCoverage]
+public class ThemePageRenderResultDtoFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a new instance with randomized test data.
+ ///
+ /// Optional rendered HTML content of the page section.
+ /// Optional rendered script element of the page section.
+ /// A configured instance.
+ public ThemePageRenderResultDto Create(
+ string? content = null,
+ string? script = null)
+ {
+ return new ThemePageRenderResultDto(
+ Content: content ?? _faker.Lorem.Paragraph(),
+ Script: script ?? _faker.Lorem.Paragraph()
+ );
+ }
+
+ ///
+ /// Creates multiple instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeRenderDocumentDtoFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeRenderDocumentDtoFixture.cs
index 45a22191..9e9717de 100644
--- a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeRenderDocumentDtoFixture.cs
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeRenderDocumentDtoFixture.cs
@@ -14,6 +14,7 @@ namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Themes;
[ExcludeFromCodeCoverage]
public class ThemeRenderDocumentDtoFixture
{
+ private readonly Faker _faker = new();
private readonly ThemeInfoDtoFixture _themeInfoDtoFixture = new();
///
@@ -22,12 +23,13 @@ public class ThemeRenderDocumentDtoFixture
/// Optional metadata of the resolved theme.
/// Optional raw template source to render.
/// A configured instance.
- public ThemeRenderDocumentDto Create(ThemeInfoDto? theme = null, string? template = null)
+ public ThemeRenderDocumentDto Create(
+ ThemeInfoDto? theme = null,
+ string? template = null)
{
- Faker faker = new();
return new ThemeRenderDocumentDto(
Theme: theme ?? _themeInfoDtoFixture.Create(),
- Template: template ?? faker.Lorem.Paragraph()
+ Template: template ?? _faker.Lorem.Paragraph()
);
}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeResponseDtoFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeResponseDtoFixture.cs
index ab1803a5..36901ca5 100644
--- a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeResponseDtoFixture.cs
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeResponseDtoFixture.cs
@@ -16,6 +16,8 @@ namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Themes;
[ExcludeFromCodeCoverage]
public class ThemeResponseDtoFixture
{
+ private readonly Faker _faker = new();
+
///
/// Creates a new instance with randomized test data.
///
@@ -48,19 +50,18 @@ public class ThemeResponseDtoFixture
DateTime? installedAtUtc = null,
bool? isDeleted = null)
{
- Faker faker = new();
return new ThemeResponseDto(
Id: id ?? Guid.NewGuid(),
- ThemeId: themeId ?? faker.Lorem.Word(),
- Name: name ?? faker.Commerce.ProductName(),
- Description: description ?? faker.Lorem.Sentence(),
- Author: author ?? faker.Name.FullName(),
- Version: version ?? faker.System.Semver(),
- PreviewPath: includePreviewPath ? (previewPath ?? (faker.Random.Bool() ? faker.System.FilePath() : null)) : null,
+ ThemeId: themeId ?? _faker.Lorem.Word(),
+ Name: name ?? _faker.Commerce.ProductName(),
+ Description: description ?? _faker.Lorem.Sentence(),
+ Author: author ?? _faker.Name.FullName(),
+ Version: version ?? _faker.System.Semver(),
+ PreviewPath: includePreviewPath ? (previewPath ?? (_faker.Random.Bool() ? _faker.System.FilePath() : null)) : null,
InstallSource: installSource ?? ThemeInstallSource.Uploaded,
- IsCurrent: includeIsCurrent ? (isCurrent ?? (faker.Random.Bool() ? true : null)) : null,
- InstalledAtUtc: installedAtUtc ?? faker.Date.Recent(),
- IsDeleted: isDeleted ?? faker.Random.Bool()
+ IsCurrent: includeIsCurrent ? (isCurrent ?? (_faker.Random.Bool() ? true : null)) : null,
+ InstalledAtUtc: installedAtUtc ?? _faker.Date.Recent(),
+ IsDeleted: isDeleted ?? _faker.Random.Bool()
);
}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeSettingsResponseDtoFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeSettingsResponseDtoFixture.cs
index 03f0032e..71ad89cc 100644
--- a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeSettingsResponseDtoFixture.cs
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeSettingsResponseDtoFixture.cs
@@ -14,6 +14,8 @@ namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Themes;
[ExcludeFromCodeCoverage]
public class ThemeSettingsResponseDtoFixture
{
+ private readonly Faker _faker = new();
+
///
/// Creates a new instance with randomized test data.
///
@@ -24,10 +26,9 @@ public class ThemeSettingsResponseDtoFixture
long? maxArchiveBytes = null,
string? defaultThemeId = null)
{
- Faker faker = new();
return new ThemeSettingsResponseDto(
- MaxArchiveBytes: maxArchiveBytes ?? faker.Random.Long(1024 * 1024, 256 * 1024 * 1024),
- DefaultThemeId: defaultThemeId ?? faker.Lorem.Word()
+ MaxArchiveBytes: maxArchiveBytes ?? _faker.Random.Long(1024 * 1024, 256 * 1024 * 1024),
+ DefaultThemeId: defaultThemeId ?? _faker.Lorem.Word()
);
}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeTemplateResponseDtoFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeTemplateResponseDtoFixture.cs
index fe00f0b4..ed45d6f5 100644
--- a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeTemplateResponseDtoFixture.cs
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/Themes/ThemeTemplateResponseDtoFixture.cs
@@ -1,7 +1,6 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
using Lumina.Presentation.Web.Common.DTO.Themes;
-using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
@@ -15,6 +14,7 @@ namespace Lumina.Presentation.Web.Fixtures.Common.DTO.Themes;
[ExcludeFromCodeCoverage]
public class ThemeTemplateResponseDtoFixture
{
+ private readonly Faker _faker = new();
private readonly ThemeResponseDtoFixture _themeResponseDtoFixture = new();
///
@@ -27,10 +27,9 @@ public class ThemeTemplateResponseDtoFixture
ThemeResponseDto? theme = null,
string? template = null)
{
- Faker faker = new();
return new ThemeTemplateResponseDto(
Theme: theme ?? _themeResponseDtoFixture.Create(),
- Template: template ?? faker.Lorem.Paragraph()
+ Template: template ?? _faker.Lorem.Paragraph()
);
}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/UsersManagement/UserDtoFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/UsersManagement/UserDtoFixture.cs
new file mode 100644
index 00000000..e6fb93e8
--- /dev/null
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/DTO/UsersManagement/UserDtoFixture.cs
@@ -0,0 +1,45 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Presentation.Web.Common.DTO.UsersManagement;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Presentation.Web.Fixtures.Common.DTO.UsersManagement;
+
+///
+/// Fixture class for generating test data.
+///
+[ExcludeFromCodeCoverage]
+public class UserDtoFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a new instance with randomized test data.
+ ///
+ /// Optional identifier of the user.
+ /// Optional username of the user.
+ /// A configured instance.
+ public UserDto Create(
+ Guid? id = null,
+ string? username = null)
+ {
+ return new UserDto(
+ Id: id ?? Guid.NewGuid(),
+ Username: username ?? _faker.Internet.UserName()
+ );
+ }
+
+ ///
+ /// Creates multiple instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Models/SectionModelFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Models/SectionModelFixture.cs
index e6a005bf..99d99d04 100644
--- a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Models/SectionModelFixture.cs
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Models/SectionModelFixture.cs
@@ -1,6 +1,5 @@
#region ========================================================================= USING =====================================================================================
using Bogus;
-using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
@@ -14,15 +13,17 @@ namespace Lumina.Presentation.Web.Fixtures.Common.Models;
[ExcludeFromCodeCoverage]
public class SectionModelFixture
{
+ private readonly Faker _faker = new();
+
///
/// Creates a new instance with randomized test data.
///
/// Optional text rendered by the section.
/// A configured instance.
- public SectionModel Create(string? text = null)
+ public SectionModel Create(
+ string? text = null)
{
- Faker faker = new();
- return new SectionModel { Text = text ?? faker.Lorem.Word() };
+ return new SectionModel { Text = text ?? _faker.Lorem.Word() };
}
///
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/Authorization/AddRoleRequestFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/Authorization/AddRoleRequestFixture.cs
index 0057f6d2..56abddbb 100644
--- a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/Authorization/AddRoleRequestFixture.cs
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/Authorization/AddRoleRequestFixture.cs
@@ -15,17 +15,20 @@ namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Authorization;
[ExcludeFromCodeCoverage]
public class AddRoleRequestFixture
{
+ private readonly Faker _faker = new();
+
///
/// Creates a new instance with randomized test data.
///
/// Optional name of the role.
/// Optional collection of permission identifiers.
/// A configured instance.
- public AddRoleRequest Create(string? roleName = null, List? permissions = null)
+ public AddRoleRequest Create(
+ string? roleName = null,
+ List? permissions = null)
{
- Faker faker = new();
return new AddRoleRequest(
- RoleName: roleName ?? faker.Commerce.Department(),
+ RoleName: roleName ?? _faker.Commerce.Department(),
Permissions: permissions ?? [Guid.NewGuid(), Guid.NewGuid()]
);
}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/Authorization/UpdateRoleRequestFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/Authorization/UpdateRoleRequestFixture.cs
new file mode 100644
index 00000000..8c6d4dda
--- /dev/null
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/Authorization/UpdateRoleRequestFixture.cs
@@ -0,0 +1,48 @@
+#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;
+
+///
+/// Fixture class for generating test data.
+///
+[ExcludeFromCodeCoverage]
+public class UpdateRoleRequestFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a new instance with randomized test data.
+ ///
+ /// Optional identifier of the role.
+ /// Optional name of the role.
+ /// Optional collection of permission identifiers.
+ /// A configured instance.
+ public UpdateRoleRequest Create(
+ Guid? roleId = null,
+ string? roleName = null,
+ List? permissions = null)
+ {
+ return new UpdateRoleRequest(
+ RoleId: roleId ?? Guid.NewGuid(),
+ RoleName: roleName ?? _faker.Commerce.Department(),
+ Permissions: permissions ?? [Guid.NewGuid(), Guid.NewGuid()]
+ );
+ }
+
+ ///
+ /// Creates multiple instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/Authorization/UpdateUserRoleAndPermissionsRequestFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/Authorization/UpdateUserRoleAndPermissionsRequestFixture.cs
new file mode 100644
index 00000000..b3f910af
--- /dev/null
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/Authorization/UpdateUserRoleAndPermissionsRequestFixture.cs
@@ -0,0 +1,45 @@
+#region ========================================================================= USING =====================================================================================
+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;
+
+///
+/// Fixture class for generating test data.
+///
+[ExcludeFromCodeCoverage]
+public class UpdateUserRoleAndPermissionsRequestFixture
+{
+ ///
+ /// Creates a new instance with randomized test data.
+ ///
+ /// Optional identifier of the user.
+ /// Optional identifier of the role assigned to the user.
+ /// Optional collection of permission identifiers assigned to the user.
+ /// A configured instance.
+ public UpdateUserRoleAndPermissionsRequest Create(
+ Guid? userId = null,
+ Guid? roleId = null,
+ List? permissions = null)
+ {
+ return new UpdateUserRoleAndPermissionsRequest(
+ UserId: userId ?? Guid.NewGuid(),
+ RoleId: roleId ?? Guid.NewGuid(),
+ Permissions: permissions ?? [Guid.NewGuid(), Guid.NewGuid()]
+ );
+ }
+
+ ///
+ /// Creates multiple instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/Libraries/GetBooksLiteRequestFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/Libraries/GetBooksLiteRequestFixture.cs
index 7bf7557f..01dfbaaa 100644
--- a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/Libraries/GetBooksLiteRequestFixture.cs
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/Libraries/GetBooksLiteRequestFixture.cs
@@ -1,5 +1,4 @@
#region ========================================================================= USING =====================================================================================
-using Bogus;
using Lumina.Presentation.Web.Common.Enums.Common;
using Lumina.Presentation.Web.Common.Requests.Libraries;
using System;
@@ -24,7 +23,7 @@ public class GetBooksLiteRequestFixture
/// Optional number of books to retrieve per page.
/// Optional search term used to filter results.
/// Optional alpha key used to filter the results.
- /// Whether the leading "The " prefix is ignored by the alpha picker.
+ /// Whether the leading "The " prefix is ignored by the alpha picker.
/// Optional name of the field by which to sort the results.
/// Optional direction in which to sort the results.
/// A configured instance.
@@ -34,7 +33,7 @@ public class GetBooksLiteRequestFixture
int? perPage = null,
string? searchTerm = null,
string? filterAlphaKey = null,
- bool ignoreThePrefixForAlphaPicker = false,
+ bool shouldIgnoreThePrefixForAlphaPicker = false,
string? sortBy = null,
SortOrder? sortOrder = null)
{
@@ -45,7 +44,7 @@ public class GetBooksLiteRequestFixture
PerPage = perPage,
SearchTerm = searchTerm,
FilterAlphaKey = filterAlphaKey,
- IgnoreThePrefixForAlphaPicker = ignoreThePrefixForAlphaPicker,
+ ShouldIgnoreThePrefixForAlphaPicker = shouldIgnoreThePrefixForAlphaPicker,
SortBy = sortBy,
SortOrder = sortOrder
};
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/Library/WrittenContentLibrary/BookLibrary/Books/GetBooksViewRequestFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/Library/WrittenContentLibrary/BookLibrary/Books/GetBooksViewRequestFixture.cs
new file mode 100644
index 00000000..85ef74c6
--- /dev/null
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/Library/WrittenContentLibrary/BookLibrary/Books/GetBooksViewRequestFixture.cs
@@ -0,0 +1,39 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.Requests.Library.WrittenContentLibrary.BookLibrary.Books;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Library.WrittenContentLibrary.BookLibrary.Books;
+
+///
+/// Fixture class for generating test data.
+///
+[ExcludeFromCodeCoverage]
+public class GetBooksViewRequestFixture
+{
+ ///
+ /// Creates a new instance.
+ ///
+ /// Optional unique identifier of the media library whose books are browsed.
+ /// A configured instance.
+ public GetBooksViewRequest Create(
+ Guid? libraryId = null)
+ {
+ return new GetBooksViewRequest(
+ LibraryId: libraryId
+ );
+ }
+
+ ///
+ /// Creates multiple instances.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/Themes/DeleteThemeRequestFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/Themes/DeleteThemeRequestFixture.cs
new file mode 100644
index 00000000..fdd4991b
--- /dev/null
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/Themes/DeleteThemeRequestFixture.cs
@@ -0,0 +1,38 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.Requests.Themes;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Themes;
+
+///
+/// Fixture class for generating test data.
+///
+[ExcludeFromCodeCoverage]
+public class DeleteThemeRequestFixture
+{
+ ///
+ /// Creates a new instance.
+ ///
+ /// Optional manifest id of the theme to delete.
+ /// A configured instance.
+ public DeleteThemeRequest Create(
+ string? themeId = null)
+ {
+ return new DeleteThemeRequest(
+ ThemeId: themeId
+ );
+ }
+
+ ///
+ /// Creates multiple instances.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/Themes/GetThemeArchiveRequestFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/Themes/GetThemeArchiveRequestFixture.cs
new file mode 100644
index 00000000..2790427b
--- /dev/null
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/Themes/GetThemeArchiveRequestFixture.cs
@@ -0,0 +1,38 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.Requests.Themes;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Themes;
+
+///
+/// Fixture class for generating test data.
+///
+[ExcludeFromCodeCoverage]
+public class GetThemeArchiveRequestFixture
+{
+ ///
+ /// Creates a new instance.
+ ///
+ /// Optional manifest id of the theme to download.
+ /// A configured instance.
+ public GetThemeArchiveRequest Create(
+ string? themeId = null)
+ {
+ return new GetThemeArchiveRequest(
+ ThemeId: themeId
+ );
+ }
+
+ ///
+ /// Creates multiple instances.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/Themes/GetThemeAssetRequestFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/Themes/GetThemeAssetRequestFixture.cs
new file mode 100644
index 00000000..a0e2c25c
--- /dev/null
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/Themes/GetThemeAssetRequestFixture.cs
@@ -0,0 +1,41 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.Requests.Themes;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Themes;
+
+///
+/// Fixture class for generating test data.
+///
+[ExcludeFromCodeCoverage]
+public class GetThemeAssetRequestFixture
+{
+ ///
+ /// Creates a new instance.
+ ///
+ /// Optional manifest id of the theme.
+ /// Optional asset path relative to the theme pack root.
+ /// A configured instance.
+ public GetThemeAssetRequest Create(
+ string? themeId = null,
+ string? path = null)
+ {
+ return new GetThemeAssetRequest(
+ ThemeId: themeId,
+ Path: path
+ );
+ }
+
+ ///
+ /// Creates multiple instances.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/Themes/RestoreThemeRequestFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/Themes/RestoreThemeRequestFixture.cs
new file mode 100644
index 00000000..d90e2661
--- /dev/null
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/Themes/RestoreThemeRequestFixture.cs
@@ -0,0 +1,38 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.Requests.Themes;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Themes;
+
+///
+/// Fixture class for generating test data.
+///
+[ExcludeFromCodeCoverage]
+public class RestoreThemeRequestFixture
+{
+ ///
+ /// Creates a new instance.
+ ///
+ /// Optional manifest id of the bundled theme to restore.
+ /// A configured instance.
+ public RestoreThemeRequest Create(
+ string? themeId = null)
+ {
+ return new RestoreThemeRequest(
+ ThemeId: themeId
+ );
+ }
+
+ ///
+ /// Creates multiple instances.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/Themes/SetCurrentThemeRequestFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/Themes/SetCurrentThemeRequestFixture.cs
new file mode 100644
index 00000000..9da2f514
--- /dev/null
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/Themes/SetCurrentThemeRequestFixture.cs
@@ -0,0 +1,38 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.Requests.Themes;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Presentation.Web.Fixtures.Common.Requests.Themes;
+
+///
+/// Fixture class for generating test data.
+///
+[ExcludeFromCodeCoverage]
+public class SetCurrentThemeRequestFixture
+{
+ ///
+ /// Creates a new instance.
+ ///
+ /// Optional manifest id of the theme to activate.
+ /// A configured instance.
+ public SetCurrentThemeRequest Create(
+ string? themeId = null)
+ {
+ return new SetCurrentThemeRequest(
+ ThemeId: themeId
+ );
+ }
+
+ ///
+ /// Creates multiple instances.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/UsersManagement/Authentication/LoginViewRequestFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/UsersManagement/Authentication/LoginViewRequestFixture.cs
index fe08c93e..a9c5a850 100644
--- a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/UsersManagement/Authentication/LoginViewRequestFixture.cs
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/UsersManagement/Authentication/LoginViewRequestFixture.cs
@@ -14,16 +14,18 @@ namespace Lumina.Presentation.Web.Fixtures.Common.Requests.UsersManagement.Authe
[ExcludeFromCodeCoverage]
public class LoginViewRequestFixture
{
+ private readonly Faker _faker = new();
+
///
/// Creates a new instance with randomized test data.
///
/// Optional URL to return to, after login.
/// A configured instance.
- public LoginViewRequest Create(string? returnUrl = null)
+ public LoginViewRequest Create(
+ string? returnUrl = null)
{
- Faker faker = new();
return new LoginViewRequest(
- ReturnUrl: returnUrl ?? $"/{faker.Random.AlphaNumeric(8)}"
+ ReturnUrl: returnUrl ?? $"/{_faker.Random.AlphaNumeric(8)}"
);
}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/UsersManagement/ChangePasswordRequestFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/UsersManagement/ChangePasswordRequestFixture.cs
index a0e75deb..ada59d24 100644
--- a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/UsersManagement/ChangePasswordRequestFixture.cs
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/UsersManagement/ChangePasswordRequestFixture.cs
@@ -14,6 +14,8 @@ namespace Lumina.Presentation.Web.Fixtures.Common.Requests.UsersManagement;
[ExcludeFromCodeCoverage]
public class ChangePasswordRequestFixture
{
+ private readonly Faker _faker = new();
+
///
/// Creates a new instance with randomized test data.
///
@@ -22,13 +24,16 @@ public class ChangePasswordRequestFixture
/// Optional new password.
/// Optional confirmation of the new password.
/// A configured instance.
- public ChangePasswordRequest Create(string? username = null, string? currentPassword = null, string? newPassword = null, string? newPasswordConfirm = null)
+ 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);
+ string generatedNewPassword = newPassword ?? _faker.Internet.Password(12);
return new ChangePasswordRequest(
- Username: username ?? faker.Internet.UserName(),
- CurrentPassword: currentPassword ?? faker.Internet.Password(12),
+ Username: username ?? _faker.Internet.UserName(),
+ CurrentPassword: currentPassword ?? _faker.Internet.Password(12),
NewPassword: generatedNewPassword,
NewPasswordConfirm: newPasswordConfirm ?? generatedNewPassword
);
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/UsersManagement/LoginRequestFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/UsersManagement/LoginRequestFixture.cs
index 9d39afdb..ff93376b 100644
--- a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/UsersManagement/LoginRequestFixture.cs
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/UsersManagement/LoginRequestFixture.cs
@@ -14,6 +14,8 @@ namespace Lumina.Presentation.Web.Fixtures.Common.Requests.UsersManagement;
[ExcludeFromCodeCoverage]
public class LoginRequestFixture
{
+ private readonly Faker _faker = new();
+
///
/// Creates a new instance with randomized test data.
///
@@ -22,12 +24,15 @@ public class LoginRequestFixture
/// Optional TOTP code.
/// Optional URL to return to, after login.
/// A configured instance.
- public LoginRequest Create(string? username = null, string? password = null, string? totpCode = null, string? returnUrl = null)
+ 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),
+ Username: username ?? _faker.Internet.UserName(),
+ Password: password ?? _faker.Internet.Password(12),
TotpCode: totpCode,
ReturnUrl: returnUrl
);
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/UsersManagement/RecoverPasswordRequestFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/UsersManagement/RecoverPasswordRequestFixture.cs
index cb8f2ce5..5ece6620 100644
--- a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/UsersManagement/RecoverPasswordRequestFixture.cs
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/UsersManagement/RecoverPasswordRequestFixture.cs
@@ -14,17 +14,20 @@ namespace Lumina.Presentation.Web.Fixtures.Common.Requests.UsersManagement;
[ExcludeFromCodeCoverage]
public class RecoverPasswordRequestFixture
{
+ private readonly Faker _faker = new();
+
///
/// Creates a new instance with randomized test data.
///
/// Optional username.
/// Optional TOTP code.
/// A configured instance.
- public RecoverPasswordRequest Create(string? username = null, string? totpCode = null)
+ public RecoverPasswordRequest Create(
+ string? username = null,
+ string? totpCode = null)
{
- Faker faker = new();
return new RecoverPasswordRequest(
- Username: username ?? faker.Internet.UserName(),
+ Username: username ?? _faker.Internet.UserName(),
TotpCode: totpCode
);
}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/UsersManagement/RegisterRequestFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/UsersManagement/RegisterRequestFixture.cs
index a6596a66..eecebc32 100644
--- a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/UsersManagement/RegisterRequestFixture.cs
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/UsersManagement/RegisterRequestFixture.cs
@@ -14,6 +14,8 @@ namespace Lumina.Presentation.Web.Fixtures.Common.Requests.UsersManagement;
[ExcludeFromCodeCoverage]
public class RegisterRequestFixture
{
+ private readonly Faker _faker = new();
+
///
/// Creates a new instance with randomized test data.
///
@@ -23,12 +25,16 @@ public class RegisterRequestFixture
/// Optional registration type, e.g. "Admin" or "User".
/// Whether two-factor authentication is enabled for the account.
/// A configured instance.
- public RegisterRequest Create(string? username = null, string? password = null, string? passwordConfirm = null, string? registrationType = "User", bool use2fa = true)
+ 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);
+ string generatedPassword = password ?? _faker.Internet.Password(12);
return new RegisterRequest(
- Username: username ?? faker.Internet.UserName(),
+ Username: username ?? _faker.Internet.UserName(),
Password: generatedPassword,
PasswordConfirm: passwordConfirm ?? generatedPassword,
RegistrationType: registrationType,
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Responses/Authorization/GetAuthorizationResponseFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Responses/Authorization/GetAuthorizationResponseFixture.cs
new file mode 100644
index 00000000..e6f47bde
--- /dev/null
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Responses/Authorization/GetAuthorizationResponseFixture.cs
@@ -0,0 +1,49 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Presentation.Web.Common.Enums.Authorization;
+using Lumina.Presentation.Web.Common.Responses.Authorization;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Presentation.Web.Fixtures.Common.Responses.Authorization;
+
+///
+/// Fixture class for generating test data.
+///
+[ExcludeFromCodeCoverage]
+public class GetAuthorizationResponseFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a new instance with randomized test data.
+ ///
+ /// Optional unique identifier of the user.
+ /// Optional role associated to the user.
+ /// Optional collection of permissions associated to the user.
+ /// A configured instance.
+ public GetAuthorizationResponse Create(
+ Guid? userId = null,
+ string? role = null,
+ AuthorizationPermission[]? permissions = null)
+ {
+ return new GetAuthorizationResponse(
+ UserId: userId ?? Guid.NewGuid(),
+ Role: role ?? _faker.Name.JobTitle(),
+ Permissions: permissions ?? [AuthorizationPermission.CanViewUsers]
+ );
+ }
+
+ ///
+ /// Creates multiple instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Responses/UsersManagement/ChangePasswordResponseFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Responses/UsersManagement/ChangePasswordResponseFixture.cs
new file mode 100644
index 00000000..2144d5b3
--- /dev/null
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Responses/UsersManagement/ChangePasswordResponseFixture.cs
@@ -0,0 +1,39 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Presentation.Web.Common.Responses.UsersManagement;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Presentation.Web.Fixtures.Common.Responses.UsersManagement;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class ChangePasswordResponseFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. Whether the password was changed or not.
+ /// The created .
+ public ChangePasswordResponse Create(
+ bool? isPasswordChanged = null)
+ {
+ return new ChangePasswordResponse(isPasswordChanged ?? _faker.Random.Bool());
+ }
+
+ ///
+ /// Creates a list of instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Responses/UsersManagement/RecoverPasswordResponseFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Responses/UsersManagement/RecoverPasswordResponseFixture.cs
new file mode 100644
index 00000000..ccd88f54
--- /dev/null
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Responses/UsersManagement/RecoverPasswordResponseFixture.cs
@@ -0,0 +1,39 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Presentation.Web.Common.Responses.UsersManagement;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Presentation.Web.Fixtures.Common.Responses.UsersManagement;
+
+///
+/// Fixture class for the record.
+///
+[ExcludeFromCodeCoverage]
+public class RecoverPasswordResponseFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a random valid .
+ ///
+ /// Optional. Whether the password was reset or not.
+ /// The created .
+ public RecoverPasswordResponse Create(
+ bool? isPasswordReset = null)
+ {
+ return new RecoverPasswordResponse(isPasswordReset ?? _faker.Random.Bool());
+ }
+
+ ///
+ /// Creates a list of instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Responses/UsersManagement/RegisterResponseFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Responses/UsersManagement/RegisterResponseFixture.cs
new file mode 100644
index 00000000..da00e31c
--- /dev/null
+++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Responses/UsersManagement/RegisterResponseFixture.cs
@@ -0,0 +1,44 @@
+#region ========================================================================= USING =====================================================================================
+using Bogus;
+using Lumina.Presentation.Web.Common.Responses.UsersManagement;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+#endregion
+
+namespace Lumina.Presentation.Web.Fixtures.Common.Responses.UsersManagement;
+
+///
+/// Fixture class for generating test data.
+///
+[ExcludeFromCodeCoverage]
+public class RegisterResponseFixture
+{
+ private readonly Faker _faker = new();
+
+ ///
+ /// Creates a new instance with randomized test data.
+ ///
+ /// Optional username of the registered user.
+ /// Optional TOTP secret used for two-factor authentication.
+ /// A configured instance.
+ public RegisterResponse Create(
+ string? username = null,
+ string? totpSecret = null)
+ {
+ return new RegisterResponse(
+ Username: username ?? _faker.Internet.UserName(),
+ TotpSecret: totpSecret ?? _faker.Random.AlphaNumeric(16)
+ );
+ }
+
+ ///
+ /// Creates multiple instances with randomized test data.
+ ///
+ /// Number of instances to create.
+ /// List of configured instances.
+ public List CreateMany(int count = 3)
+ {
+ return [.. Enumerable.Range(0, count).Select(_ => Create())];
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Common/Setup/AuthenticatedLuminaApiFactory.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Common/Setup/AuthenticatedLuminaApiFactory.cs
index 533da3dc..6d6e3966 100644
--- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Common/Setup/AuthenticatedLuminaApiFactory.cs
+++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Common/Setup/AuthenticatedLuminaApiFactory.cs
@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
using Lumina.Application.Common.DataAccess.Seed;
+using Lumina.Application.Fixtures.Common.DataAccess.Entities.UsersManagement;
using Lumina.Contracts.Requests.Authentication;
using Lumina.Contracts.Responses.Authentication;
using Lumina.DataAccess.Core.UoW;
@@ -30,6 +31,7 @@ public class AuthenticatedLuminaApiFactory : LuminaApiFactory, IDisposable
{
PropertyNameCaseInsensitive = true
};
+ private readonly UserEntityFixture _userEntityFixture = new();
///
/// Gets the username of the currently created test user.
@@ -65,17 +67,8 @@ public class AuthenticatedLuminaApiFactory : LuminaApiFactory, IDisposable
LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService();
// create test user
- UserEntity user = new()
- {
- Id = Guid.NewGuid(),
- Username = TestUsername!,
- Password = _hashService.HashString("TestPass123!"),
- Libraries = [],
- UserPermissions = [],
- UserRole = null,
- CreatedBy = Guid.NewGuid(),
- CreatedOnUtc = DateTime.UtcNow
- };
+ UserEntity user = _userEntityFixture.Create(username: TestUsername!, password: _hashService.HashString("TestPass123!"));
+ user.TotpSecret = null;
dbContext.Users.Add(user);
await dbContext.SaveChangesAsync();
@@ -127,17 +120,8 @@ public class AuthenticatedLuminaApiFactory : LuminaApiFactory, IDisposable
IDataSeedService dataSeedService = scope.ServiceProvider.GetRequiredService();
// create test user
- UserEntity user = new()
- {
- Id = Guid.NewGuid(),
- Username = TestUsername!,
- Password = _hashService.HashString("TestPass123!"),
- Libraries = [],
- UserPermissions = [],
- UserRole = null,
- CreatedBy = Guid.NewGuid(),
- CreatedOnUtc = DateTime.UtcNow
- };
+ UserEntity user = _userEntityFixture.Create(username: TestUsername!, password: _hashService.HashString("TestPass123!"));
+ user.TotpSecret = null;
dbContext.Users.Add(user);
await dbContext.SaveChangesAsync();
diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Admin/Authorization/Roles/DeleteRoleEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Admin/Authorization/Roles/DeleteRoleEndpointTests.cs
index 36436bda..9a3606d7 100644
--- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Admin/Authorization/Roles/DeleteRoleEndpointTests.cs
+++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Admin/Authorization/Roles/DeleteRoleEndpointTests.cs
@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.Authorization;
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
+using Lumina.Application.Fixtures.Common.DataAccess.Entities.Authorization;
using Lumina.DataAccess.Core.UoW;
using Lumina.Presentation.Api.IntegrationTests.Common.Setup;
using Microsoft.AspNetCore.Http;
@@ -28,6 +29,7 @@ public class DeleteRoleEndpointTests : IClassFixture();
// Create a test role first
- RoleEntity role = new()
- {
- Id = Guid.NewGuid(),
- RoleName = "TestRole",
- CreatedBy = Guid.NewGuid(),
- CreatedOnUtc = DateTime.UtcNow
- };
+ RoleEntity role = _roleEntityFixture.Create(roleName: "TestRole");
dbContext.Roles.Add(role);
await dbContext.SaveChangesAsync();
diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Admin/Authorization/Roles/UpdateRoleEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Admin/Authorization/Roles/UpdateRoleEndpointTests.cs
index 88aaf90b..a7130f4d 100644
--- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Admin/Authorization/Roles/UpdateRoleEndpointTests.cs
+++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Admin/Authorization/Roles/UpdateRoleEndpointTests.cs
@@ -1,7 +1,9 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.Authorization;
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
+using Lumina.Application.Fixtures.Common.DataAccess.Entities.Authorization;
using Lumina.Contracts.DTO.Authentication;
+using Lumina.Contracts.Fixtures.Core.Requests.Authorization;
using Lumina.Contracts.Requests.Authorization;
using Lumina.Contracts.Responses.Authorization;
using Lumina.DataAccess.Core.UoW;
@@ -33,6 +35,8 @@ public class UpdateRoleEndpointTests : IClassFixture();
- RoleEntity role = new()
- {
- Id = Guid.NewGuid(),
- RoleName = "TestRole",
- CreatedBy = Guid.NewGuid(),
- CreatedOnUtc = DateTime.UtcNow
- };
+ RoleEntity role = _roleEntityFixture.Create(roleName: "TestRole");
dbContext.Roles.Add(role);
await dbContext.SaveChangesAsync();
PermissionEntity[] permissions = [.. dbContext.Permissions.Take(2)];
- UpdateRoleRequest request = new(
- RoleId: role.Id,
- RoleName: "UpdatedRole",
- Permissions: permissions.Select(p => p.Id).ToList()
+ UpdateRoleRequest request = _updateRoleRequestFixture.Create(
+ roleId: role.Id,
+ roleName: "UpdatedRole",
+ permissions: [.. permissions.Select(p => p.Id)]
);
// Act
@@ -107,10 +105,10 @@ public class UpdateRoleEndpointTests : IClassFixture
/// Initializes a new instance of the class.
@@ -134,17 +137,7 @@ public class DeleteLibraryEndpointTests : IClassFixture();
Guid userId = Guid.NewGuid();
- dbContext.Users.Add(new UserEntity
- {
- Id = userId,
- Username = $"otheruser_{Guid.NewGuid()}",
- Password = "TestPass123!",
- Libraries = [],
- UserPermissions = [],
- UserRole = null,
- CreatedBy = userId,
- CreatedOnUtc = DateTime.UtcNow
- });
+ dbContext.Users.Add(_userEntityFixture.Create(id: userId, username: $"otheruser_{Guid.NewGuid()}", password: "TestPass123!"));
await dbContext.SaveChangesAsync();
return userId;
}
@@ -159,17 +152,7 @@ public class DeleteLibraryEndpointTests : IClassFixture();
- dbContext.Libraries.Add(new LibraryEntity
- {
- Id = libraryId,
- UserId = userId,
- Title = "Test Library",
- LibraryType = LibraryType.EBook,
- ContentLocations = [],
- CreatedBy = userId,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedBy = null
- });
+ dbContext.Libraries.Add(_libraryEntityFixture.Create(id: libraryId, userId: userId, title: "Test Library", libraryType: LibraryType.EBook, contentLocations: []));
await dbContext.SaveChangesAsync();
}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/Management/GetEnabledLibraries/GetEnabledLibrariesEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/Management/GetEnabledLibraries/GetEnabledLibrariesEndpointTests.cs
index c0249927..46812286 100644
--- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/Management/GetEnabledLibraries/GetEnabledLibrariesEndpointTests.cs
+++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/Management/GetEnabledLibraries/GetEnabledLibrariesEndpointTests.cs
@@ -1,6 +1,6 @@
#region ========================================================================= USING =====================================================================================
-using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
+using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
using Lumina.Contracts.Responses.MediaLibrary.Management;
using Lumina.DataAccess.Core.UoW;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
@@ -33,6 +33,7 @@ public class GetEnabledLibrariesEndpointTests : IClassFixture
/// Initializes a new instance of the class.
@@ -101,18 +102,7 @@ public class GetEnabledLibrariesEndpointTests : IClassFixture();
- dbContext.Libraries.Add(new LibraryEntity
- {
- Id = libraryId,
- UserId = userId,
- Title = title,
- LibraryType = LibraryType.EBook,
- ContentLocations = [],
- IsEnabled = isEnabled,
- CreatedBy = userId,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedBy = null
- });
+ dbContext.Libraries.Add(_libraryEntityFixture.Create(id: libraryId, userId: userId, title: title, libraryType: LibraryType.EBook, contentLocations: [], isEnabled: isEnabled));
await dbContext.SaveChangesAsync();
}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/Management/GetLibraries/GetLibrariesEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/Management/GetLibraries/GetLibrariesEndpointTests.cs
index f5fdf41f..f95e0c41 100644
--- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/Management/GetLibraries/GetLibrariesEndpointTests.cs
+++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/Management/GetLibraries/GetLibrariesEndpointTests.cs
@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
-using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
+using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
+using Lumina.Application.Fixtures.Common.DataAccess.Entities.UsersManagement;
using Lumina.Contracts.Responses.MediaLibrary.Management;
using Lumina.DataAccess.Core.UoW;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
@@ -8,7 +9,6 @@ using Lumina.Presentation.Api.Core.Endpoints.Library.Management.GetLibraries;
using Lumina.Presentation.Api.IntegrationTests.Common.Setup;
using Microsoft.Extensions.DependencyInjection;
using System;
-using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Net;
@@ -34,6 +34,8 @@ public class GetLibrariesEndpointTests : IClassFixture
/// Initializes a new instance of the class.
@@ -100,17 +102,7 @@ public class GetLibrariesEndpointTests : IClassFixture();
Guid userId = Guid.NewGuid();
- dbContext.Users.Add(new UserEntity
- {
- Id = userId,
- Username = $"otheruser_{Guid.NewGuid()}",
- Password = "TestPass123!",
- Libraries = [],
- UserPermissions = [],
- UserRole = null,
- CreatedBy = userId,
- CreatedOnUtc = DateTime.UtcNow
- });
+ dbContext.Users.Add(_userEntityFixture.Create(id: userId, username: $"otheruser_{Guid.NewGuid()}", password: "TestPass123!"));
await dbContext.SaveChangesAsync();
return userId;
}
@@ -126,17 +118,7 @@ public class GetLibrariesEndpointTests : IClassFixture();
- dbContext.Libraries.Add(new LibraryEntity
- {
- Id = libraryId,
- UserId = userId,
- Title = title,
- LibraryType = LibraryType.EBook,
- ContentLocations = [],
- CreatedBy = userId,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedBy = null
- });
+ dbContext.Libraries.Add(_libraryEntityFixture.Create(id: libraryId, userId: userId, title: title, libraryType: LibraryType.EBook, contentLocations: []));
await dbContext.SaveChangesAsync();
}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/Management/GetLibrary/GetLibraryEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/Management/GetLibrary/GetLibraryEndpointTests.cs
index 6acc6187..645c3e3f 100644
--- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/Management/GetLibrary/GetLibraryEndpointTests.cs
+++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/Management/GetLibrary/GetLibraryEndpointTests.cs
@@ -1,6 +1,6 @@
#region ========================================================================= USING =====================================================================================
-using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
+using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
using Lumina.Contracts.Responses.MediaLibrary.Management;
using Lumina.DataAccess.Core.UoW;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
@@ -35,6 +35,7 @@ public class GetLibraryEndpointTests : IClassFixture
/// Initializes a new instance of the class.
@@ -109,17 +110,7 @@ public class GetLibraryEndpointTests : IClassFixture();
- dbContext.Libraries.Add(new LibraryEntity
- {
- Id = libraryId,
- UserId = userId,
- Title = title,
- LibraryType = LibraryType.EBook,
- ContentLocations = [],
- CreatedBy = userId,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedBy = null
- });
+ dbContext.Libraries.Add(_libraryEntityFixture.Create(id: libraryId, userId: userId, title: title, libraryType: LibraryType.EBook, contentLocations: []));
await dbContext.SaveChangesAsync();
}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/Management/GetLibraryScanProgress/GetLibraryScanProgressEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/Management/GetLibraryScanProgress/GetLibraryScanProgressEndpointTests.cs
index e30564f1..aad96bac 100644
--- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/Management/GetLibraryScanProgress/GetLibraryScanProgressEndpointTests.cs
+++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/Management/GetLibraryScanProgress/GetLibraryScanProgressEndpointTests.cs
@@ -1,6 +1,6 @@
#region ========================================================================= USING =====================================================================================
-using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
+using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
using Lumina.DataAccess.Core.UoW;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using Lumina.Presentation.Api.Core.Endpoints.Library.Management.GetLibraryScanProgress;
@@ -33,6 +33,7 @@ public class GetLibraryScanProgressEndpointTests : IClassFixture
/// Initializes a new instance of the class.
@@ -114,17 +115,7 @@ public class GetLibraryScanProgressEndpointTests : IClassFixture();
- dbContext.Libraries.Add(new LibraryEntity
- {
- Id = libraryId,
- UserId = userId,
- Title = "Test Library",
- LibraryType = LibraryType.EBook,
- ContentLocations = [],
- CreatedBy = userId,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedBy = null
- });
+ dbContext.Libraries.Add(_libraryEntityFixture.Create(id: libraryId, userId: userId, title: "Test Library", libraryType: LibraryType.EBook, contentLocations: []));
await dbContext.SaveChangesAsync();
}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/Management/ScanLibraries/ScanLibrariesEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/Management/ScanLibraries/ScanLibrariesEndpointTests.cs
index 39016988..a9a13112 100644
--- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/Management/ScanLibraries/ScanLibrariesEndpointTests.cs
+++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/Management/ScanLibraries/ScanLibrariesEndpointTests.cs
@@ -1,6 +1,6 @@
#region ========================================================================= USING =====================================================================================
-using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
+using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
using Lumina.Contracts.Responses.MediaLibrary.Management;
using Lumina.DataAccess.Core.UoW;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
@@ -34,6 +34,7 @@ public class ScanLibrariesEndpointTests : IClassFixture
/// Initializes a new instance of the class.
@@ -96,19 +97,7 @@ public class ScanLibrariesEndpointTests : IClassFixture();
- dbContext.Libraries.Add(new LibraryEntity
- {
- Id = libraryId,
- UserId = userId,
- Title = "Test Library",
- LibraryType = LibraryType.EBook,
- ContentLocations = [],
- IsEnabled = true,
- IsLocked = false,
- CreatedBy = userId,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedBy = null
- });
+ dbContext.Libraries.Add(_libraryEntityFixture.Create(id: libraryId, userId: userId, title: "Test Library", libraryType: LibraryType.EBook, contentLocations: []));
await dbContext.SaveChangesAsync();
}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/Management/ScanLibrary/ScanLibraryEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/Management/ScanLibrary/ScanLibraryEndpointTests.cs
index 965459d7..093909ae 100644
--- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/Management/ScanLibrary/ScanLibraryEndpointTests.cs
+++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/Management/ScanLibrary/ScanLibraryEndpointTests.cs
@@ -1,6 +1,6 @@
#region ========================================================================= USING =====================================================================================
-using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
+using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
using Lumina.Contracts.Responses.MediaLibrary.Management;
using Lumina.DataAccess.Core.UoW;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
@@ -35,6 +35,7 @@ public class ScanLibraryEndpointTests : IClassFixture
/// Initializes a new instance of the class.
@@ -136,19 +137,7 @@ public class ScanLibraryEndpointTests : IClassFixture();
- dbContext.Libraries.Add(new LibraryEntity
- {
- Id = libraryId,
- UserId = userId,
- Title = "Test Library",
- LibraryType = LibraryType.EBook,
- ContentLocations = [],
- IsEnabled = isEnabled,
- IsLocked = isLocked,
- CreatedBy = userId,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedBy = null
- });
+ dbContext.Libraries.Add(_libraryEntityFixture.Create(id: libraryId, userId: userId, title: "Test Library", libraryType: LibraryType.EBook, contentLocations: [], isEnabled: isEnabled, isLocked: isLocked));
await dbContext.SaveChangesAsync();
}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/Management/UpdateLibrary/UpdateLibraryEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/Management/UpdateLibrary/UpdateLibraryEndpointTests.cs
index 8f7ab5ed..529a48f9 100644
--- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/Management/UpdateLibrary/UpdateLibraryEndpointTests.cs
+++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/Management/UpdateLibrary/UpdateLibraryEndpointTests.cs
@@ -1,6 +1,8 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
+using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
+using Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.Management;
using Lumina.Contracts.Requests.MediaLibrary.Management;
using Lumina.Contracts.Responses.MediaLibrary.Management;
using Lumina.DataAccess.Core.UoW;
@@ -37,6 +39,8 @@ public class UpdateLibraryEndpointTests : IClassFixture
/// Initializes a new instance of the class.
@@ -63,18 +67,18 @@ public class UpdateLibraryEndpointTests : IClassFixture();
- dbContext.Libraries.Add(new LibraryEntity
- {
- Id = libraryId,
- UserId = userId,
- Title = title,
- LibraryType = LibraryType.EBook,
- ContentLocations = [],
- CreatedBy = userId,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedBy = null
- });
+ dbContext.Libraries.Add(_libraryEntityFixture.Create(id: libraryId, userId: userId, title: title, libraryType: LibraryType.EBook, contentLocations: []));
await dbContext.SaveChangesAsync();
}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/GetBooks/GetBooksEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/GetBooks/GetBooksEndpointTests.cs
index 9db061e1..b774a3fc 100644
--- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/GetBooks/GetBooksEndpointTests.cs
+++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/GetBooks/GetBooksEndpointTests.cs
@@ -1,8 +1,10 @@
#region ========================================================================= USING =====================================================================================
-using Lumina.Application.Common.DataAccess.Entities.Common;
-using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
+using Lumina.Application.Fixtures.Common.DataAccess.Entities.Common;
+using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
+using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
+using Lumina.Application.Fixtures.Common.DataAccess.Entities.UsersManagement;
using Lumina.Contracts.Responses.Common;
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
using Lumina.DataAccess.Core.UoW;
@@ -38,6 +40,13 @@ public class GetBooksEndpointTests : IClassFixture
/// Initializes a new instance of the class.
@@ -270,25 +279,44 @@ public class GetBooksEndpointTests : IClassFixture();
- BookEntity book = new()
- {
- Id = Guid.NewGuid(),
- LibraryId = libraryId,
- Path = $"/books/{Guid.NewGuid()}.epub",
- Title = title,
- Tags = [new TagEntity($"Tag-{Guid.NewGuid()}")],
- Genres = [new GenreEntity($"Genre-{Guid.NewGuid()}")],
- ISBNs = [new IsbnEntity("9780395272237", IsbnFormat.Isbn13)],
- Ratings = [new BookRatingEntity(4.5M, 5, BookRatingSource.Goodreads, 100)],
- CreatedBy = Guid.NewGuid(),
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedBy = null
- };
+ BookEntity book = _bookEntityFixture.Create(libraryId: libraryId, title: title, path: $"/books/{Guid.NewGuid()}.epub", includeMetadata: false);
+ book.Tags = [_tagEntityFixture.Create(name: $"Tag-{Guid.NewGuid()}")];
+ book.Genres = [_genreEntityFixture.Create(name: $"Genre-{Guid.NewGuid()}")];
+ book.ISBNs = [_isbnEntityFixture.Create(value: "9780395272237", format: IsbnFormat.Isbn13)];
+ book.Ratings = [_bookRatingEntityFixture.Create(value: 4.5M, maxValue: 5, source: BookRatingSource.Goodreads, voteCount: 100)];
dbContext.Books.Add(book);
await dbContext.SaveChangesAsync();
return book;
}
+ ///
+ /// Seeds a owned by .
+ ///
+ /// The Id of the library to seed.
+ /// The Id of the user that owns the library.
+ /// A task representing the asynchronous operation.
+ private async Task SeedLibraryAsync(Guid libraryId, Guid userId)
+ {
+ using IServiceScope scope = _apiFactory.Services.CreateScope();
+ LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService();
+ dbContext.Libraries.Add(_libraryEntityFixture.Create(id: libraryId, userId: userId, title: "Test Library", libraryType: LibraryType.EBook, contentLocations: []));
+ await dbContext.SaveChangesAsync();
+ }
+
+ ///
+ /// Seeds a and returns its Id.
+ ///
+ /// The Id of the seeded user.
+ private async Task SeedUserAsync()
+ {
+ using IServiceScope scope = _apiFactory.Services.CreateScope();
+ LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService();
+ Guid userId = Guid.NewGuid();
+ dbContext.Users.Add(_userEntityFixture.Create(id: userId, username: $"otheruser_{Guid.NewGuid()}", password: "TestPass123!"));
+ await dbContext.SaveChangesAsync();
+ return userId;
+ }
+
///
/// Gets the Id of the currently authenticated test user.
///
@@ -301,54 +329,6 @@ public class GetBooksEndpointTests : IClassFixture
- /// Seeds a owned by .
- ///
- /// The Id of the library to seed.
- /// The Id of the user that owns the library.
- /// A task representing the asynchronous operation.
- private async Task SeedLibraryAsync(Guid libraryId, Guid userId)
- {
- using IServiceScope scope = _apiFactory.Services.CreateScope();
- LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService();
- dbContext.Libraries.Add(new LibraryEntity
- {
- Id = libraryId,
- UserId = userId,
- Title = "Test Library",
- LibraryType = LibraryType.EBook,
- ContentLocations = [],
- CreatedBy = userId,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedBy = null
- });
- await dbContext.SaveChangesAsync();
- }
-
- ///
- /// Seeds a and returns its Id.
- ///
- /// The Id of the seeded user.
- private async Task SeedUserAsync()
- {
- using IServiceScope scope = _apiFactory.Services.CreateScope();
- LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService();
- Guid userId = Guid.NewGuid();
- dbContext.Users.Add(new UserEntity
- {
- Id = userId,
- Username = $"otheruser_{Guid.NewGuid()}",
- Password = "TestPass123!",
- Libraries = [],
- UserPermissions = [],
- UserRole = null,
- CreatedBy = userId,
- CreatedOnUtc = DateTime.UtcNow
- });
- await dbContext.SaveChangesAsync();
- return userId;
- }
-
///
/// Disposes API factory resources.
///
diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/GetBooksLite/GetBooksLiteEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/GetBooksLite/GetBooksLiteEndpointTests.cs
index cc092581..9fad8b58 100644
--- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/GetBooksLite/GetBooksLiteEndpointTests.cs
+++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/GetBooksLite/GetBooksLiteEndpointTests.cs
@@ -1,10 +1,12 @@
#region ========================================================================= USING =====================================================================================
-using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
-using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
+using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
+using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
+using Lumina.Application.Fixtures.Common.DataAccess.Entities.UsersManagement;
using Lumina.Contracts.Responses.Common;
using Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
using Lumina.DataAccess.Core.UoW;
+using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using Lumina.Presentation.Api.IntegrationTests.Common.Setup;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
@@ -16,9 +18,7 @@ using System.Net.Http;
using System.Net.Http.Json;
using System.Text.Json;
using System.Text.Json.Serialization;
-using System.Threading;
using System.Threading.Tasks;
-using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
#endregion
namespace Lumina.Presentation.Api.IntegrationTests.Core.Endpoints.Library.WrittenContentLibrary.BookLibrary.Books.GetBooksLite;
@@ -36,6 +36,9 @@ public class GetBooksLiteEndpointTests : IClassFixture
/// Initializes a new instance of the class.
@@ -117,7 +120,7 @@ public class GetBooksLiteEndpointTests : IClassFixture();
- dbContext.Books.Add(new BookEntity
- {
- Id = Guid.NewGuid(),
- LibraryId = libraryId,
- Path = $"/books/{Guid.NewGuid()}.epub",
- Title = title,
- OriginalTitle = originalTitle,
- CreatedBy = Guid.NewGuid(),
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedBy = null
- });
+ dbContext.Books.Add(_bookEntityFixture.Create(libraryId: libraryId, title: title, originalTitle: originalTitle, path: $"/books/{Guid.NewGuid()}.epub", includeMetadata: false));
await dbContext.SaveChangesAsync();
}
+ ///
+ /// Seeds a owned by .
+ ///
+ /// The Id of the library to seed.
+ /// The Id of the user that owns the library.
+ /// A task representing the asynchronous operation.
+ private async Task SeedLibraryAsync(Guid libraryId, Guid userId)
+ {
+ using IServiceScope scope = _apiFactory.Services.CreateScope();
+ LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService();
+ dbContext.Libraries.Add(_libraryEntityFixture.Create(id: libraryId, userId: userId, title: "Test Library", libraryType: LibraryType.EBook, contentLocations: []));
+ await dbContext.SaveChangesAsync();
+ }
+
+ ///
+ /// Seeds a and returns its Id.
+ ///
+ /// The Id of the seeded user.
+ private async Task SeedUserAsync()
+ {
+ using IServiceScope scope = _apiFactory.Services.CreateScope();
+ LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService();
+ Guid userId = Guid.NewGuid();
+ dbContext.Users.Add(_userEntityFixture.Create(id: userId, username: $"otheruser_{Guid.NewGuid()}", password: "TestPass123!"));
+ await dbContext.SaveChangesAsync();
+ return userId;
+ }
+
///
/// Gets the Id of the currently authenticated test user.
///
@@ -351,54 +372,6 @@ public class GetBooksLiteEndpointTests : IClassFixture
- /// Seeds a owned by .
- ///
- /// The Id of the library to seed.
- /// The Id of the user that owns the library.
- /// A task representing the asynchronous operation.
- private async Task SeedLibraryAsync(Guid libraryId, Guid userId)
- {
- using IServiceScope scope = _apiFactory.Services.CreateScope();
- LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService();
- dbContext.Libraries.Add(new LibraryEntity
- {
- Id = libraryId,
- UserId = userId,
- Title = "Test Library",
- LibraryType = LibraryType.EBook,
- ContentLocations = [],
- CreatedBy = userId,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedBy = null
- });
- await dbContext.SaveChangesAsync();
- }
-
- ///
- /// Seeds a and returns its Id.
- ///
- /// The Id of the seeded user.
- private async Task SeedUserAsync()
- {
- using IServiceScope scope = _apiFactory.Services.CreateScope();
- LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService();
- Guid userId = Guid.NewGuid();
- dbContext.Users.Add(new UserEntity
- {
- Id = userId,
- Username = $"otheruser_{Guid.NewGuid()}",
- Password = "TestPass123!",
- Libraries = [],
- UserPermissions = [],
- UserRole = null,
- CreatedBy = userId,
- CreatedOnUtc = DateTime.UtcNow
- });
- await dbContext.SaveChangesAsync();
- return userId;
- }
-
///
/// Disposes API factory resources.
///
diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Maintenance/ApplicationSetup/CheckInitializationEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Maintenance/ApplicationSetup/CheckInitializationEndpointTests.cs
index 9a34d748..8fb18606 100644
--- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Maintenance/ApplicationSetup/CheckInitializationEndpointTests.cs
+++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Maintenance/ApplicationSetup/CheckInitializationEndpointTests.cs
@@ -1,5 +1,6 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
+using Lumina.Application.Fixtures.Common.DataAccess.Entities.UsersManagement;
using Lumina.Contracts.Responses.UsersManagement;
using Lumina.DataAccess.Core.UoW;
using Lumina.Infrastructure.Core.Security;
@@ -25,6 +26,7 @@ public class CheckInitializationEndpointTests : IClassFixture();
- UserEntity user = new()
- {
- Id = Guid.NewGuid(),
- Username = _testUsername,
- Password = new PasswordHashService().HashString("TestPass123!"),
- Libraries = [],
- UserPermissions = [],
- UserRole = null,
- CreatedBy = Guid.NewGuid(),
- CreatedOnUtc = DateTime.UtcNow
- };
+ UserEntity user = _userEntityFixture.Create(username: _testUsername, password: new PasswordHashService().HashString("TestPass123!"));
+ user.TotpSecret = null;
dbContext.Users.Add(user);
await dbContext.SaveChangesAsync();
diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Maintenance/ApplicationSetup/SetupApplicationEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Maintenance/ApplicationSetup/SetupApplicationEndpointTests.cs
index 73b9de47..b01b5441 100644
--- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Maintenance/ApplicationSetup/SetupApplicationEndpointTests.cs
+++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Maintenance/ApplicationSetup/SetupApplicationEndpointTests.cs
@@ -1,6 +1,8 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.Authorization;
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
+using Lumina.Application.Fixtures.Common.DataAccess.Entities.UsersManagement;
+using Lumina.Contracts.Fixtures.Core.Requests.Authentication;
using Lumina.Contracts.Requests.Authentication;
using Lumina.Contracts.Responses.Authentication;
using Lumina.DataAccess.Core.UoW;
@@ -32,6 +34,8 @@ public class SetupApplicationEndpointTests : IClassFixture();
- UserEntity user = new()
- {
- Id = Guid.NewGuid(),
- Username = _testUsername,
- Password = new PasswordHashService().HashString("TestPass123!"),
- Libraries = [],
- UserPermissions = [],
- UserRole = null, // TODO: test default role and permissions?
- CreatedBy = Guid.NewGuid(),
- CreatedOnUtc = DateTime.UtcNow
- };
+ // TODO: test default role and permissions?
+ UserEntity user = _userEntityFixture.Create(username: _testUsername, password: new PasswordHashService().HashString("TestPass123!"));
+ user.TotpSecret = null;
dbContext.Users.Add(user);
await dbContext.SaveChangesAsync();
diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Plugins/GetPlugins/GetPluginsEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Plugins/GetPlugins/GetPluginsEndpointTests.cs
index 7975eba1..a1118b53 100644
--- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Plugins/GetPlugins/GetPluginsEndpointTests.cs
+++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Plugins/GetPlugins/GetPluginsEndpointTests.cs
@@ -1,6 +1,6 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.Plugins;
-using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
+using Lumina.Application.Fixtures.Common.DataAccess.Entities.Plugins;
using Lumina.DataAccess.Core.UoW;
using Lumina.Domain.SharedKernel.Common.Enums.Plugins;
using Lumina.Presentation.Api.Core.Endpoints.Plugins.GetPlugins;
@@ -9,7 +9,6 @@ using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
-using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Json;
@@ -34,6 +33,7 @@ public class GetPluginsEndpointTests : IClassFixture _seededPluginIds = [];
+ private readonly PluginEntityFixture _pluginEntityFixture = new();
///
/// Initializes a new instance of the class.
@@ -95,37 +95,11 @@ public class GetPluginsEndpointTests : IClassFixture();
- Guid userId = GetCurrentUserId();
- dbContext.Plugins.Add(new PluginEntity
- {
- Id = pluginId,
- Name = name,
- Author = "Test Author",
- Version = "1.0.0",
- Description = "A test plugin.",
- LoadStatus = PluginLoadStatus.Loaded,
- LoadError = null,
- SettingsJson = null,
- CreatedBy = userId,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedBy = null
- });
+ dbContext.Plugins.Add(_pluginEntityFixture.Create(id: pluginId, name: name, loadStatus: PluginLoadStatus.Loaded, includeSettingsJson: false));
await dbContext.SaveChangesAsync();
_seededPluginIds.Add(pluginId);
}
- ///
- /// Gets the Id of the currently authenticated test user.
- ///
- /// The Id of the authenticated test user.
- private Guid GetCurrentUserId()
- {
- using IServiceScope scope = _apiFactory.Services.CreateScope();
- LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService();
- UserEntity user = dbContext.Users.First(user => user.Username == _apiFactory.TestUsername);
- return user.Id;
- }
-
///
/// Removes the seeded plugins and disposes API factory resources.
///
diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/ChangePasswordEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/ChangePasswordEndpointTests.cs
index 35c5ba2f..9925e8b0 100644
--- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/ChangePasswordEndpointTests.cs
+++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/ChangePasswordEndpointTests.cs
@@ -1,5 +1,6 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
+using Lumina.Contracts.Fixtures.Core.Requests.Authentication;
using Lumina.Contracts.Requests.Authentication;
using Lumina.Contracts.Responses.Authentication;
using Lumina.DataAccess.Core.UoW;
@@ -29,6 +30,7 @@ public class ChangePasswordEndpointTests : IClassFixture,
private HttpClient _client;
private readonly AuthenticatedLuminaApiFactory _apiFactory;
private readonly PasswordHashService _hashService = new();
+ private readonly UserEntityFixture _userEntityFixture = new();
+ private readonly LoginRequestFixture _loginRequestFixture = new();
private readonly ICryptographyService _cryptographyService;
private readonly TotpTokenGenerator _totpTokenGenerator = new();
private readonly JsonSerializerOptions _jsonOptions = new()
@@ -70,9 +74,9 @@ public class LoginEndpointTests : IClassFixture,
{
// Arrange
UserEntity user = await CreateTestUser();
- LoginRequest request = new(
- Username: user.Username,
- Password: "TestPass123!"
+ LoginRequest request = _loginRequestFixture.Create(
+ username: user.Username,
+ password: "TestPass123!"
);
// Act
@@ -101,10 +105,10 @@ public class LoginEndpointTests : IClassFixture,
Totp totp = new(totpSecret);
string validTotpCode = totp.ComputeTotp(DateTime.UtcNow);
- LoginRequest request = new(
- Username: user.Username,
- Password: "TestPass123!",
- TotpCode: validTotpCode
+ LoginRequest request = _loginRequestFixture.Create(
+ username: user.Username,
+ password: "TestPass123!",
+ totpCode: validTotpCode
);
// Act
@@ -129,9 +133,9 @@ public class LoginEndpointTests : IClassFixture,
{
// Arrange
UserEntity user = await CreateTestUserWithTempPassword();
- LoginRequest request = new(
- Username: user.Username,
- Password: "TempPass123!"
+ LoginRequest request = _loginRequestFixture.Create(
+ username: user.Username,
+ password: "TempPass123!"
);
// Act
@@ -155,9 +159,9 @@ public class LoginEndpointTests : IClassFixture,
{
// Arrange
UserEntity user = await CreateTestUserWithExpiredTempPassword();
- LoginRequest request = new(
- Username: user.Username,
- Password: "TempPass123!"
+ LoginRequest request = _loginRequestFixture.Create(
+ username: user.Username,
+ password: "TempPass123!"
);
// Act
@@ -183,9 +187,9 @@ public class LoginEndpointTests : IClassFixture,
{
// Arrange
UserEntity user = await CreateTestUser();
- LoginRequest request = new(
- Username: user.Username,
- Password: "WrongPass123!"
+ LoginRequest request = _loginRequestFixture.Create(
+ username: user.Username,
+ password: "WrongPass123!"
);
// Act
@@ -211,10 +215,10 @@ public class LoginEndpointTests : IClassFixture,
{
// Arrange
UserEntity user = await CreateTestUserWithTotp();
- LoginRequest request = new(
- Username: user.Username,
- Password: "TestPass123!",
- TotpCode: "000000"
+ LoginRequest request = _loginRequestFixture.Create(
+ username: user.Username,
+ password: "TestPass123!",
+ totpCode: "000000"
);
// Act
@@ -240,94 +244,73 @@ public class LoginEndpointTests : IClassFixture,
Assert.Contains("InvalidTotpCode", errors["General.Validation"]);
}
+ ///
+ /// Creates a test user without a TOTP secret in the database and returns it.
+ ///
+ /// The created user entity.
private async Task CreateTestUser()
{
using IServiceScope scope = _apiFactory.Services.CreateScope();
LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService();
- UserEntity user = new()
- {
- Id = Guid.NewGuid(),
- Username = _testUsername,
- Password = _hashService.HashString("TestPass123!"),
- Libraries = [],
- UserPermissions = [],
- UserRole = null,
- CreatedBy = Guid.NewGuid(),
- CreatedOnUtc = DateTime.UtcNow
- };
+ UserEntity user = _userEntityFixture.Create(username: _testUsername, password: _hashService.HashString("TestPass123!"));
+ user.TotpSecret = null;
dbContext.Users.Add(user);
await dbContext.SaveChangesAsync();
return user;
}
+ ///
+ /// Creates a test user with a TOTP secret in the database and returns it.
+ ///
+ /// The created user entity.
private async Task CreateTestUserWithTotp()
{
using IServiceScope scope = _apiFactory.Services.CreateScope();
LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService();
byte[] totpSecret = _totpTokenGenerator.GenerateSecret();
- UserEntity user = new()
- {
- Id = Guid.NewGuid(),
- Username = _testUsername,
- Password = _hashService.HashString("TestPass123!"),
- TotpSecret = _cryptographyService.Encrypt(Convert.ToBase64String(totpSecret)),
- Libraries = [],
- UserPermissions = [],
- UserRole = null,
- CreatedBy = Guid.NewGuid(),
- CreatedOnUtc = DateTime.UtcNow
- };
+ UserEntity user = _userEntityFixture.Create(username: _testUsername, password: _hashService.HashString("TestPass123!"));
+ user.TotpSecret = _cryptographyService.Encrypt(Convert.ToBase64String(totpSecret));
dbContext.Users.Add(user);
await dbContext.SaveChangesAsync();
return user;
}
+ ///
+ /// Creates a test user with a temporary password in the database and returns it.
+ ///
+ /// The created user entity.
private async Task CreateTestUserWithTempPassword()
{
using IServiceScope scope = _apiFactory.Services.CreateScope();
LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService();
- UserEntity user = new()
- {
- Id = Guid.NewGuid(),
- Username = _testUsername,
- Password = _hashService.HashString("TestPass123!"),
- TempPassword = Uri.EscapeDataString(_hashService.HashString("TempPass123!")),
- TempPasswordCreated = DateTime.UtcNow,
- Libraries = [],
- UserPermissions = [],
- UserRole = null,
- CreatedBy = Guid.NewGuid(),
- CreatedOnUtc = DateTime.UtcNow
- };
+ UserEntity user = _userEntityFixture.Create(username: _testUsername, password: _hashService.HashString("TestPass123!"));
+ user.TotpSecret = null;
+ user.TempPassword = Uri.EscapeDataString(_hashService.HashString("TempPass123!"));
+ user.TempPasswordCreated = DateTime.UtcNow;
dbContext.Users.Add(user);
await dbContext.SaveChangesAsync();
return user;
}
+ ///
+ /// Creates a test user with an expired temporary password in the database and returns it.
+ ///
+ /// The created user entity.
private async Task CreateTestUserWithExpiredTempPassword()
{
using IServiceScope scope = _apiFactory.Services.CreateScope();
LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService();
- UserEntity user = new()
- {
- Id = Guid.NewGuid(),
- Username = _testUsername,
- Password = _hashService.HashString("TestPass123!"),
- TempPassword = Uri.EscapeDataString(_hashService.HashString("TempPass123!")),
- TempPasswordCreated = DateTime.UtcNow.AddMinutes(-16), // expired (> 15 minutes old)
- Libraries = [],
- UserPermissions = [],
- UserRole = null,
- CreatedBy = Guid.NewGuid(),
- CreatedOnUtc = DateTime.UtcNow
- };
+ UserEntity user = _userEntityFixture.Create(username: _testUsername, password: _hashService.HashString("TestPass123!"));
+ user.TotpSecret = null;
+ user.TempPassword = Uri.EscapeDataString(_hashService.HashString("TempPass123!"));
+ user.TempPasswordCreated = DateTime.UtcNow.AddMinutes(-16); // expired (> 15 minutes old)
dbContext.Users.Add(user);
await dbContext.SaveChangesAsync();
diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/RecoverPasswordEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/RecoverPasswordEndpointTests.cs
index 1e9e1c9f..f0f554c4 100644
--- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/RecoverPasswordEndpointTests.cs
+++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/RecoverPasswordEndpointTests.cs
@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
using Lumina.Application.Common.Infrastructure.Security;
+using Lumina.Application.Fixtures.Common.DataAccess.Entities.UsersManagement;
using Lumina.Contracts.Requests.Authentication;
using Lumina.Contracts.Responses.Authentication;
using Lumina.DataAccess.Core.UoW;
@@ -35,6 +36,7 @@ public class RecoverPasswordEndpointTests : IClassFixture();
- UserEntity userWithoutTotp = new()
- {
- Id = Guid.NewGuid(),
- Username = "userwithoutotp2",
- Password = _hashService.HashString("OldPass123!"),
- TotpSecret = null, // No TOTP configured
- Libraries = [],
- UserPermissions = [],
- UserRole = null,
- CreatedBy = Guid.NewGuid(),
- CreatedOnUtc = DateTime.UtcNow
- };
+ UserEntity userWithoutTotp = _userEntityFixture.Create(username: "userwithoutotp2", password: _hashService.HashString("OldPass123!"));
+ userWithoutTotp.TotpSecret = null; // No TOTP configured
dbContext.Users.Add(userWithoutTotp);
await dbContext.SaveChangesAsync();
}
@@ -307,47 +299,35 @@ public class RecoverPasswordEndpointTests : IClassFixture(exception);
}
+ ///
+ /// Creates a test user with a TOTP secret in the database and returns it.
+ ///
+ /// The created user entity.
private async Task CreateUserWithTotp()
{
using IServiceScope scope = _apiFactory.Services.CreateScope();
LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService();
byte[] totpSecret = _totpTokenGenerator.GenerateSecret();
- UserEntity user = new()
- {
- Id = Guid.NewGuid(),
- Username = _testUsername,
- Password = _hashService.HashString("OldPass123!"),
- TotpSecret = _cryptographyService.Encrypt(Convert.ToBase64String(totpSecret)),
- Libraries = [],
- UserPermissions = [],
- UserRole = null,
- CreatedBy = Guid.NewGuid(),
- CreatedOnUtc = DateTime.UtcNow
- };
+ UserEntity user = _userEntityFixture.Create(username: _testUsername, password: _hashService.HashString("OldPass123!"));
+ user.TotpSecret = _cryptographyService.Encrypt(Convert.ToBase64String(totpSecret));
dbContext.Users.Add(user);
await dbContext.SaveChangesAsync();
return user;
}
+ ///
+ /// Creates a test user without a TOTP secret in the database and returns it.
+ ///
+ /// The created user entity.
private async Task CreateUserWithoutTotp()
{
using IServiceScope scope = _apiFactory.Services.CreateScope();
LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService();
- UserEntity user = new()
- {
- Id = Guid.NewGuid(),
- Username = _testUsername,
- Password = _hashService.HashString("OldPass123!"),
- TotpSecret = null,
- Libraries = [],
- UserPermissions = [],
- UserRole = null,
- CreatedBy = Guid.NewGuid(),
- CreatedOnUtc = DateTime.UtcNow
- };
+ UserEntity user = _userEntityFixture.Create(username: _testUsername, password: _hashService.HashString("OldPass123!"));
+ user.TotpSecret = null;
dbContext.Users.Add(user);
await dbContext.SaveChangesAsync();
diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/RegisterEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/RegisterEndpointTests.cs
index 2a9d9bfd..58917bf5 100644
--- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/RegisterEndpointTests.cs
+++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/RegisterEndpointTests.cs
@@ -1,5 +1,7 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
+using Lumina.Application.Fixtures.Common.DataAccess.Entities.UsersManagement;
+using Lumina.Contracts.Fixtures.Core.Requests.Authentication;
using Lumina.Contracts.Requests.Authentication;
using Lumina.Contracts.Responses.Authentication;
using Lumina.DataAccess.Core.UoW;
@@ -29,6 +31,8 @@ public class RegisterEndpointTests : IClassFixture
+ /// Creates a test user in the database and returns it.
+ ///
+ /// The created user entity.
private async Task CreateTestUser()
{
using IServiceScope scope = _apiFactory.Services.CreateScope();
LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService();
- UserEntity user = new()
- {
- Id = Guid.NewGuid(),
- Username = _testUsername,
- Password = new PasswordHashService().HashString("TestPass123!"),
- Libraries = [],
- UserPermissions = [],
- UserRole = null,
- CreatedBy = Guid.NewGuid(),
- CreatedOnUtc = DateTime.UtcNow
- };
+ UserEntity user = _userEntityFixture.Create(username: _testUsername, password: new PasswordHashService().HashString("TestPass123!"));
+ user.TotpSecret = null;
dbContext.Users.Add(user);
await dbContext.SaveChangesAsync();
diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/UsersManagement/Authorization/GetAuthorizationEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/UsersManagement/Authorization/GetAuthorizationEndpointTests.cs
index cea07a3b..6064c214 100644
--- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/UsersManagement/Authorization/GetAuthorizationEndpointTests.cs
+++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/UsersManagement/Authorization/GetAuthorizationEndpointTests.cs
@@ -1,6 +1,8 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.Authorization;
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
+using Lumina.Application.Fixtures.Common.DataAccess.Entities.Authorization;
+using Lumina.Contracts.Fixtures.Core.Requests.Authorization;
using Lumina.Contracts.Requests.Authorization;
using Lumina.Contracts.Responses.Authorization;
using Lumina.DataAccess.Core.UoW;
@@ -34,6 +36,11 @@ public class GetAuthorizationEndpointTests : IClassFixture
/// Initializes a new instance of the class.
@@ -78,7 +85,7 @@ public class GetAuthorizationEndpointTests : IClassFixture userPermission.Permission)
.FirstAsync(user => user.Username == _apiFactory.TestUsername);
await AddRolesAndPermissionsToUser(user, dbContext);
- GetAuthorizationRequest request = new(user.Id);
+ GetAuthorizationRequest request = _getAuthorizationRequestFixture.Create(userId: user.Id);
// Act
HttpResponseMessage response = await _client.GetAsync($"/api/v1/auth/get-authorization?userId={request.UserId}");
@@ -100,7 +107,7 @@ public class GetAuthorizationEndpointTests : IClassFixture(exception);
}
- private static async Task AddRolesAndPermissionsToUser(UserEntity existingUser, LuminaDbContext dbContext)
+ private async Task AddRolesAndPermissionsToUser(UserEntity existingUser, LuminaDbContext dbContext)
{
// create and save role and permission first
- RoleEntity adminRole = new()
- {
- Id = Guid.NewGuid(),
- RoleName = "Admin",
- CreatedOnUtc = DateTime.UtcNow,
- CreatedBy = Guid.NewGuid()
- };
-
- PermissionEntity viewUsersPermission = new()
- {
- Id = Guid.NewGuid(),
- PermissionName = AuthorizationPermission.CanViewUsers,
- CreatedOnUtc = DateTime.UtcNow,
- CreatedBy = Guid.NewGuid()
- };
+ RoleEntity adminRole = _roleEntityFixture.Create(roleName: "Admin");
+ PermissionEntity viewUsersPermission = _permissionEntityFixture.Create(permissionName: AuthorizationPermission.CanViewUsers);
await dbContext.Roles.AddAsync(adminRole);
await dbContext.Permissions.AddAsync(viewUsersPermission);
await dbContext.SaveChangesAsync();
// create role permission
- RolePermissionEntity rolePermission = new()
- {
- Id = Guid.NewGuid(),
- Permission = viewUsersPermission,
- PermissionId = viewUsersPermission.Id,
- Role = adminRole,
- RoleId = adminRole.Id,
- CreatedBy = existingUser.Id,
- CreatedOnUtc = DateTime.UtcNow
- };
+ RolePermissionEntity rolePermission = _rolePermissionEntityFixture.Create(role: adminRole, permission: viewUsersPermission);
await dbContext.RolePermissions.AddAsync(rolePermission);
await dbContext.SaveChangesAsync();
@@ -207,16 +192,7 @@ public class GetAuthorizationEndpointTests : IClassFixture();
// create a non-admin role first
- RoleEntity editorRole = new()
- {
- Id = Guid.NewGuid(),
- RoleName = "Editor",
- CreatedBy = Guid.NewGuid(),
- CreatedOnUtc = DateTime.UtcNow
- };
+ RoleEntity editorRole = _roleEntityFixture.Create(roleName: "Editor");
dbContext.Roles.Add(editorRole);
await dbContext.SaveChangesAsync();
// create test user
- UserEntity user = new()
- {
- Id = Guid.NewGuid(),
- Username = "TestUser",
- Password = "HashedPassword",
- UserRole = null,
- UserPermissions = [],
- Libraries = [],
- CreatedBy = Guid.NewGuid(),
- CreatedOnUtc = DateTime.UtcNow
- };
+ UserEntity user = _userEntityFixture.Create(username: "TestUser", password: "HashedPassword");
+ user.TotpSecret = null;
dbContext.Users.Add(user);
await dbContext.SaveChangesAsync();
PermissionEntity[] permissions = [.. dbContext.Permissions.Take(2)];
- UpdateUserRoleAndPermissionsRequest request = new(
- UserId: user.Id,
- RoleId: editorRole.Id,
- Permissions: permissions.Select(p => p.Id).ToList()
+ UpdateUserRoleAndPermissionsRequest request = _updateUserRoleAndPermissionsRequestFixture.Create(
+ userId: user.Id,
+ roleId: editorRole.Id,
+ permissions: permissions.Select(p => p.Id).ToList()
);
// Act
@@ -118,10 +109,10 @@ public class UpdateUserRoleAndPermissionsEndpointTests : IClassFixture();
// create Editor role
- RoleEntity editorRole = new()
- {
- Id = Guid.NewGuid(),
- RoleName = "Editor",
- CreatedBy = Guid.NewGuid(),
- CreatedOnUtc = DateTime.UtcNow
- };
+ RoleEntity editorRole = _roleEntityFixture.Create(roleName: "Editor");
dbContext.Roles.Add(editorRole);
await dbContext.SaveChangesAsync();
// get the admin user that was created by CreateAuthenticatedAdminClientAsync
UserEntity? adminUser = dbContext.Users.FirstOrDefault(u => u.UserRole!.Role.RoleName == "Admin");
Assert.NotNull(adminUser);
- UpdateUserRoleAndPermissionsRequest request = new(
- UserId: adminUser!.Id,
- RoleId: editorRole.Id,
- Permissions: []
+ UpdateUserRoleAndPermissionsRequest request = _updateUserRoleAndPermissionsRequestFixture.Create(
+ userId: adminUser!.Id,
+ roleId: editorRole.Id,
+ permissions: []
);
// Act
@@ -192,10 +177,10 @@ public class UpdateUserRoleAndPermissionsEndpointTests : IClassFixture
+/// Contains integration tests for the /{culture}/admin/api-create-role route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class AddRoleEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly AddRoleRequestFixture _addRoleRequestFixture = new();
+ private readonly GetAuthorizationResponseFixture _getAuthorizationResponseFixture = new();
+ private readonly RolePermissionsDtoFixture _rolePermissionsDtoFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public AddRoleEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task AddRole_WhenCalledByAuthenticatedAdminWithAntiforgeryToken_ShouldForwardRoleAndReturnSuccess()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ _apiFactory.ApiClientStub.AuthorizationResponse = _getAuthorizationResponseFixture.Create(userId: Guid.NewGuid(), role: "Admin", permissions: []);
+ AddRoleRequest request = _addRoleRequestFixture.Create();
+ _apiFactory.ApiClientStub.RegisterPostResponse("auth/roles", _rolePermissionsDtoFixture.Create());
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage createRequest = new(HttpMethod.Post, "/en-us/admin/api-create-role")
+ {
+ Content = JsonContent.Create(request)
+ };
+ createRequest.Content!.Headers.ContentType = new MediaTypeHeaderValue("application/json");
+ createRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+ createRequest.Headers.Add("RequestVerificationToken", webClient.AntiforgeryToken);
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(createRequest);
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ using JsonDocument json = JsonDocument.Parse(content);
+ Assert.True(json.RootElement.GetProperty("success").GetBoolean());
+ Assert.Contains(_apiFactory.ApiClientStub.PostRequests, postRequest => postRequest.Endpoint == "auth/roles");
+ }
+
+ [Fact]
+ public async Task AddRole_WhenCalledByNonAdminUser_ShouldRedirectToAccessDenied()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ _apiFactory.ApiClientStub.AuthorizationResponse = _getAuthorizationResponseFixture.Create(userId: Guid.NewGuid(), role: "User", permissions: []);
+ AddRoleRequest request = _addRoleRequestFixture.Create();
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage createRequest = new(HttpMethod.Post, "/en-us/admin/api-create-role")
+ {
+ Content = JsonContent.Create(request)
+ };
+ createRequest.Content!.Headers.ContentType = new MediaTypeHeaderValue("application/json");
+ createRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+ createRequest.Headers.Add("RequestVerificationToken", webClient.AntiforgeryToken);
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(createRequest);
+
+ // Assert
+ Assert.Equal(HttpStatusCode.Redirect, response.StatusCode);
+ Assert.Contains("access-denied", response.Headers.Location!.ToString());
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/Authorization/Roles/DeleteRole/DeleteRoleEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/Authorization/Roles/DeleteRole/DeleteRoleEndpointTests.cs
new file mode 100644
index 00000000..963ad8f2
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/Authorization/Roles/DeleteRole/DeleteRoleEndpointTests.cs
@@ -0,0 +1,89 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Core.Endpoints.Admin.Authorization.Roles.DeleteRole;
+using Lumina.Presentation.Web.Fixtures.Common.Responses.Authorization;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text;
+using System.Text.Json;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Admin.Authorization.Roles.DeleteRole;
+
+///
+/// Contains integration tests for the /{culture}/admin/api-delete-role/{roleId} route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class DeleteRoleEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly GetAuthorizationResponseFixture _getAuthorizationResponseFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public DeleteRoleEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task DeleteRole_WhenCalledByAuthenticatedAdminWithAntiforgeryToken_ShouldForwardDeleteAndReturnSuccess()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ _apiFactory.ApiClientStub.AuthorizationResponse = _getAuthorizationResponseFixture.Create(userId: Guid.NewGuid(), role: "Admin", permissions: []);
+ Guid roleId = Guid.NewGuid();
+ string expectedEndpoint = $"auth/roles/{roleId}";
+ _apiFactory.ApiClientStub.RegisterDeleteSuccess(expectedEndpoint);
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage deleteRequest = new(HttpMethod.Delete, $"/en-us/admin/api-delete-role/{roleId}")
+ {
+ Content = new StringContent("{}", Encoding.UTF8, "application/json")
+ };
+ deleteRequest.Content!.Headers.ContentType = new MediaTypeHeaderValue("application/json");
+ deleteRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+ deleteRequest.Headers.Add("RequestVerificationToken", webClient.AntiforgeryToken);
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(deleteRequest);
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ using JsonDocument json = JsonDocument.Parse(content);
+ Assert.True(json.RootElement.GetProperty("success").GetBoolean());
+ Assert.Contains(_apiFactory.ApiClientStub.DeleteEndpointsCalled, endpoint => endpoint == expectedEndpoint);
+ }
+
+ [Fact]
+ public async Task DeleteRole_WhenCalledByNonAdminUser_ShouldRedirectToAccessDenied()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ _apiFactory.ApiClientStub.AuthorizationResponse = _getAuthorizationResponseFixture.Create(userId: Guid.NewGuid(), role: "User", permissions: []);
+ Guid roleId = Guid.NewGuid();
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage deleteRequest = new(HttpMethod.Delete, $"/en-us/admin/api-delete-role/{roleId}")
+ {
+ Content = new StringContent("{}", Encoding.UTF8, "application/json")
+ };
+ deleteRequest.Content!.Headers.ContentType = new MediaTypeHeaderValue("application/json");
+ deleteRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+ deleteRequest.Headers.Add("RequestVerificationToken", webClient.AntiforgeryToken);
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(deleteRequest);
+
+ // Assert
+ Assert.Equal(HttpStatusCode.Redirect, response.StatusCode);
+ Assert.Contains("access-denied", response.Headers.Location!.ToString());
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/Authorization/Roles/GetRolePermissions/GetRolePermissionsEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/Authorization/Roles/GetRolePermissions/GetRolePermissionsEndpointTests.cs
new file mode 100644
index 00000000..50c497e1
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/Authorization/Roles/GetRolePermissions/GetRolePermissionsEndpointTests.cs
@@ -0,0 +1,78 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.DTO.Authorization;
+using Lumina.Presentation.Web.Core.Endpoints.Admin.Authorization.Roles.GetRolePermissions;
+using Lumina.Presentation.Web.Fixtures.Common.DTO.Authorization;
+using Lumina.Presentation.Web.Fixtures.Common.Responses.Authorization;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text.Json;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Admin.Authorization.Roles.GetRolePermissions;
+
+///
+/// Contains integration tests for the /{culture}/admin/api-get-permissions-by-role-id/{roleId} route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class GetRolePermissionsEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly GetAuthorizationResponseFixture _getAuthorizationResponseFixture = new();
+ private readonly RolePermissionsDtoFixture _rolePermissionsDtoFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public GetRolePermissionsEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task GetRolePermissions_WhenCalledByAuthenticatedAdmin_ShouldReturnRolePermissionsJson()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ _apiFactory.ApiClientStub.AuthorizationResponse = _getAuthorizationResponseFixture.Create(userId: Guid.NewGuid(), role: "Admin", permissions: []);
+ Guid roleId = Guid.NewGuid();
+ RolePermissionsDto expectedResponse = _rolePermissionsDtoFixture.Create();
+ _apiFactory.ApiClientStub.RegisterGetResponse($"auth/roles/{roleId}/permissions", expectedResponse);
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage getRequest = new(HttpMethod.Get, $"/en-us/admin/api-get-permissions-by-role-id/{roleId}");
+ getRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(getRequest);
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ using JsonDocument json = JsonDocument.Parse(content);
+ Assert.True(json.RootElement.GetProperty("success").GetBoolean());
+ Assert.Equal(expectedResponse.Permissions.Length, json.RootElement.GetProperty("data").GetProperty("permissions").GetArrayLength());
+ }
+
+ [Fact]
+ public async Task GetRolePermissions_WhenCalledByNonAdminUser_ShouldRedirectToAccessDenied()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ _apiFactory.ApiClientStub.AuthorizationResponse = _getAuthorizationResponseFixture.Create(userId: Guid.NewGuid(), role: "User", permissions: []);
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.GetAsync("/en-us/admin/api-get-permissions-by-role-id/" + Guid.NewGuid());
+
+ // Assert
+ Assert.Equal(HttpStatusCode.Redirect, response.StatusCode);
+ Assert.Contains("access-denied", response.Headers.Location!.ToString());
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/Authorization/Roles/GetRoles/GetRolesEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/Authorization/Roles/GetRoles/GetRolesEndpointTests.cs
index 6ed6f97b..9a47f7bf 100644
--- a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/Authorization/Roles/GetRoles/GetRolesEndpointTests.cs
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/Authorization/Roles/GetRoles/GetRolesEndpointTests.cs
@@ -1,7 +1,8 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.DTO.Authorization;
-using Lumina.Presentation.Web.Common.Responses.Authorization;
using Lumina.Presentation.Web.Core.Endpoints.Admin.Authorization.Roles.GetRoles;
+using Lumina.Presentation.Web.Fixtures.Common.DTO.Authorization;
+using Lumina.Presentation.Web.Fixtures.Common.Responses.Authorization;
using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
using System;
@@ -21,6 +22,8 @@ namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Admin.Authoriz
public class GetRolesEndpointTests : IClassFixture
{
private readonly LuminaWebFactory _apiFactory;
+ private readonly GetAuthorizationResponseFixture _getAuthorizationResponseFixture = new();
+ private readonly RoleDtoFixture _roleDtoFixture = new();
///
/// Initializes a new instance of the class.
@@ -36,8 +39,8 @@ public class GetRolesEndpointTests : IClassFixture
{
// Arrange
_apiFactory.ApiClientStub.Reset();
- _apiFactory.ApiClientStub.AuthorizationResponse = new GetAuthorizationResponse(Guid.NewGuid(), "Admin", []);
- RoleDto[] expectedRoles = [new RoleDto(Guid.NewGuid(), "Admin"), new RoleDto(Guid.NewGuid(), "User")];
+ _apiFactory.ApiClientStub.AuthorizationResponse = _getAuthorizationResponseFixture.Create(userId: Guid.NewGuid(), role: "Admin", permissions: []);
+ RoleDto[] expectedRoles = [_roleDtoFixture.Create(id: Guid.NewGuid(), roleName: "Admin"), _roleDtoFixture.Create(id: Guid.NewGuid(), roleName: "User")];
_apiFactory.ApiClientStub.RegisterGetResponse("auth/roles", expectedRoles);
AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
@@ -57,7 +60,7 @@ public class GetRolesEndpointTests : IClassFixture
{
// Arrange
_apiFactory.ApiClientStub.Reset();
- _apiFactory.ApiClientStub.AuthorizationResponse = new GetAuthorizationResponse(Guid.NewGuid(), "User", []);
+ _apiFactory.ApiClientStub.AuthorizationResponse = _getAuthorizationResponseFixture.Create(userId: Guid.NewGuid(), role: "User", permissions: []);
AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
// Act
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/Authorization/Roles/UpdateRole/UpdateRoleEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/Authorization/Roles/UpdateRole/UpdateRoleEndpointTests.cs
new file mode 100644
index 00000000..34b80bc2
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/Authorization/Roles/UpdateRole/UpdateRoleEndpointTests.cs
@@ -0,0 +1,93 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.Requests.Authorization;
+using Lumina.Presentation.Web.Core.Endpoints.Admin.Authorization.Roles.UpdateRole;
+using Lumina.Presentation.Web.Fixtures.Common.DTO.Authorization;
+using Lumina.Presentation.Web.Fixtures.Common.Requests.Authorization;
+using Lumina.Presentation.Web.Fixtures.Common.Responses.Authorization;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Net.Http.Json;
+using System.Text.Json;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Admin.Authorization.Roles.UpdateRole;
+
+///
+/// Contains integration tests for the /{culture}/admin/api-update-role route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class UpdateRoleEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly GetAuthorizationResponseFixture _getAuthorizationResponseFixture = new();
+ private readonly RolePermissionsDtoFixture _rolePermissionsDtoFixture = new();
+ private readonly UpdateRoleRequestFixture _updateRoleRequestFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public UpdateRoleEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task UpdateRole_WhenCalledByAuthenticatedAdminWithAntiforgeryToken_ShouldForwardUpdateAndReturnSuccess()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ _apiFactory.ApiClientStub.AuthorizationResponse = _getAuthorizationResponseFixture.Create(userId: Guid.NewGuid(), role: "Admin", permissions: []);
+ UpdateRoleRequest request = _updateRoleRequestFixture.Create();
+ _apiFactory.ApiClientStub.RegisterPutResponse("auth/roles", _rolePermissionsDtoFixture.Create());
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage updateRequest = new(HttpMethod.Put, "/en-us/admin/api-update-role")
+ {
+ Content = JsonContent.Create(request)
+ };
+ updateRequest.Content!.Headers.ContentType = new MediaTypeHeaderValue("application/json");
+ updateRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+ updateRequest.Headers.Add("RequestVerificationToken", webClient.AntiforgeryToken);
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(updateRequest);
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ using JsonDocument json = JsonDocument.Parse(content);
+ Assert.True(json.RootElement.GetProperty("success").GetBoolean());
+ Assert.Contains(_apiFactory.ApiClientStub.PutRequests, putRequest => putRequest.Endpoint == "auth/roles");
+ }
+
+ [Fact]
+ public async Task UpdateRole_WhenCalledByNonAdminUser_ShouldRedirectToAccessDenied()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ _apiFactory.ApiClientStub.AuthorizationResponse = _getAuthorizationResponseFixture.Create(userId: Guid.NewGuid(), role: "User", permissions: []);
+ UpdateRoleRequest request = _updateRoleRequestFixture.Create();
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage updateRequest = new(HttpMethod.Put, "/en-us/admin/api-update-role")
+ {
+ Content = JsonContent.Create(request)
+ };
+ updateRequest.Content!.Headers.ContentType = new MediaTypeHeaderValue("application/json");
+ updateRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+ updateRequest.Headers.Add("RequestVerificationToken", webClient.AntiforgeryToken);
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(updateRequest);
+
+ // Assert
+ Assert.Equal(HttpStatusCode.Redirect, response.StatusCode);
+ Assert.Contains("access-denied", response.Headers.Location!.ToString());
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/ManagePermissions/ManagePermissionsViewEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/ManagePermissions/ManagePermissionsViewEndpointTests.cs
new file mode 100644
index 00000000..def9fd02
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/ManagePermissions/ManagePermissionsViewEndpointTests.cs
@@ -0,0 +1,78 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.DTO.Authorization;
+using Lumina.Presentation.Web.Common.DTO.UsersManagement;
+using Lumina.Presentation.Web.Core.Endpoints.Admin.ManagePermissions;
+using Lumina.Presentation.Web.Fixtures.Common.DTO.Authorization;
+using Lumina.Presentation.Web.Fixtures.Common.DTO.UsersManagement;
+using Lumina.Presentation.Web.Fixtures.Common.Responses.Authorization;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Admin.ManagePermissions;
+
+///
+/// Contains integration tests for the /{culture}/admin/manage-permissions route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class ManagePermissionsViewEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly GetAuthorizationResponseFixture _getAuthorizationResponseFixture = new();
+ private readonly PermissionDtoFixture _permissionDtoFixture = new();
+ private readonly RoleDtoFixture _roleDtoFixture = new();
+ private readonly UserDtoFixture _userDtoFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public ManagePermissionsViewEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task ManagePermissions_WhenCalledByAuthenticatedAdmin_ShouldRenderPermissionsManagementPage()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ _apiFactory.ApiClientStub.AuthorizationResponse = _getAuthorizationResponseFixture.Create(userId: Guid.NewGuid(), role: "Admin", permissions: []);
+ UserDto[] expectedUsers = [.. _userDtoFixture.CreateMany()];
+ RoleDto[] expectedRoles = [.. _roleDtoFixture.CreateMany()];
+ PermissionDto[] expectedPermissions = [.. _permissionDtoFixture.CreateMany()];
+ _apiFactory.ApiClientStub.RegisterGetResponse("auth/users", expectedUsers);
+ _apiFactory.ApiClientStub.RegisterGetResponse("auth/roles", expectedRoles);
+ _apiFactory.ApiClientStub.RegisterGetResponse("auth/permissions", expectedPermissions);
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.GetAsync("/en-us/admin/manage-permissions");
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ Assert.Equal("text/html", response.Content.Headers.ContentType!.MediaType);
+ }
+
+ [Fact]
+ public async Task ManagePermissions_WhenCalledByNonAdminUser_ShouldRedirectToAccessDenied()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ _apiFactory.ApiClientStub.AuthorizationResponse = _getAuthorizationResponseFixture.Create(userId: Guid.NewGuid(), role: "User", permissions: []);
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.GetAsync("/en-us/admin/manage-permissions");
+
+ // Assert
+ Assert.Equal(HttpStatusCode.Redirect, response.StatusCode);
+ Assert.Contains("access-denied", response.Headers.Location!.ToString());
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/ManageRoles/ManageRolesViewEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/ManageRoles/ManageRolesViewEndpointTests.cs
new file mode 100644
index 00000000..53bf006b
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/ManageRoles/ManageRolesViewEndpointTests.cs
@@ -0,0 +1,73 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.DTO.Authorization;
+using Lumina.Presentation.Web.Core.Endpoints.Admin.ManageRoles;
+using Lumina.Presentation.Web.Fixtures.Common.DTO.Authorization;
+using Lumina.Presentation.Web.Fixtures.Common.Responses.Authorization;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Admin.ManageRoles;
+
+///
+/// Contains integration tests for the /{culture}/admin/manage-roles route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class ManageRolesViewEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly GetAuthorizationResponseFixture _getAuthorizationResponseFixture = new();
+ private readonly PermissionDtoFixture _permissionDtoFixture = new();
+ private readonly RoleDtoFixture _roleDtoFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public ManageRolesViewEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task ManageRoles_WhenCalledByAuthenticatedAdmin_ShouldRenderRolesManagementPage()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ _apiFactory.ApiClientStub.AuthorizationResponse = _getAuthorizationResponseFixture.Create(userId: Guid.NewGuid(), role: "Admin", permissions: []);
+ RoleDto[] expectedRoles = [.. _roleDtoFixture.CreateMany()];
+ PermissionDto[] expectedPermissions = [.. _permissionDtoFixture.CreateMany()];
+ _apiFactory.ApiClientStub.RegisterGetResponse("auth/roles", expectedRoles);
+ _apiFactory.ApiClientStub.RegisterGetResponse("auth/permissions", expectedPermissions);
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.GetAsync("/en-us/admin/manage-roles");
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ Assert.Equal("text/html", response.Content.Headers.ContentType!.MediaType);
+ }
+
+ [Fact]
+ public async Task ManageRoles_WhenCalledByNonAdminUser_ShouldRedirectToAccessDenied()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ _apiFactory.ApiClientStub.AuthorizationResponse = _getAuthorizationResponseFixture.Create(userId: Guid.NewGuid(), role: "User", permissions: []);
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.GetAsync("/en-us/admin/manage-roles");
+
+ // Assert
+ Assert.Equal(HttpStatusCode.Redirect, response.StatusCode);
+ Assert.Contains("access-denied", response.Headers.Location!.ToString());
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/Themes/DeleteTheme/DeleteThemeEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/Themes/DeleteTheme/DeleteThemeEndpointTests.cs
new file mode 100644
index 00000000..1078a03c
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/Themes/DeleteTheme/DeleteThemeEndpointTests.cs
@@ -0,0 +1,82 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Core.Endpoints.Admin.Themes.DeleteTheme;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text;
+using System.Text.Json;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Admin.Themes.DeleteTheme;
+
+///
+/// Contains integration tests for the /{culture}/admin/themes/api-delete-theme/{themeId} route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class DeleteThemeEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public DeleteThemeEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task DeleteTheme_WhenCalledByAuthenticatedAdminWithAntiforgeryToken_ShouldDeleteThemeAndReturnSuccess()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ const string THEME_ID = "test-theme";
+ _apiFactory.ApiClientStub.RegisterDeleteSuccess($"themes/{THEME_ID}");
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage deleteRequest = new(HttpMethod.Delete, $"/en-us/admin/themes/api-delete-theme/{THEME_ID}")
+ {
+ Content = new StringContent("{}", Encoding.UTF8, "application/json")
+ };
+ deleteRequest.Content!.Headers.ContentType = new MediaTypeHeaderValue("application/json");
+ deleteRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+ deleteRequest.Headers.Add("RequestVerificationToken", webClient.AntiforgeryToken);
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(deleteRequest);
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ using JsonDocument json = JsonDocument.Parse(content);
+ Assert.True(json.RootElement.GetProperty("success").GetBoolean());
+ Assert.Contains(_apiFactory.ApiClientStub.DeleteEndpointsCalled, endpoint => endpoint == $"themes/{THEME_ID}");
+ }
+
+ [Fact]
+ public async Task DeleteTheme_WhenCalledWithEmptyThemeId_ShouldReturnBadRequest()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage deleteRequest = new(HttpMethod.Delete, "/en-us/admin/themes/api-delete-theme/%20")
+ {
+ Content = new StringContent("{}", Encoding.UTF8, "application/json")
+ };
+ deleteRequest.Content!.Headers.ContentType = new MediaTypeHeaderValue("application/json");
+ deleteRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+ deleteRequest.Headers.Add("RequestVerificationToken", webClient.AntiforgeryToken);
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(deleteRequest);
+
+ // Assert
+ Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
+ Assert.Empty(_apiFactory.ApiClientStub.DeleteEndpointsCalled);
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/Themes/DownloadTheme/DownloadThemeEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/Themes/DownloadTheme/DownloadThemeEndpointTests.cs
new file mode 100644
index 00000000..a4f93086
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/Themes/DownloadTheme/DownloadThemeEndpointTests.cs
@@ -0,0 +1,70 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Core.Endpoints.Admin.Themes.DownloadTheme;
+using Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Admin.Themes.DownloadTheme;
+
+///
+/// Contains integration tests for the /{culture}/admin/themes/api-download-theme/{themeId} route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class DownloadThemeEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly BlobDataDtoFixture _blobDataDtoFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public DownloadThemeEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task DownloadTheme_WhenCalledByAuthenticatedAdmin_ShouldReturnThemeArchive()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ byte[] expectedBytes = [0x50, 0x4B, 0x03, 0x04, 0x01, 0x02];
+ _apiFactory.ApiClientStub.RegisterBlobResponse(_blobDataDtoFixture.Create(data: expectedBytes, contentType: "application/zip"));
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage downloadRequest = new(HttpMethod.Get, "/en-us/admin/themes/api-download-theme/test-theme");
+ downloadRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(downloadRequest);
+ byte[] content = await response.Content.ReadAsByteArrayAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ Assert.Equal("application/zip", response.Content.Headers.ContentType!.MediaType);
+ Assert.Equal(expectedBytes, content);
+ }
+
+ [Fact]
+ public async Task DownloadTheme_WhenCalledWithEmptyThemeId_ShouldReturnBadRequest()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage downloadRequest = new(HttpMethod.Get, "/en-us/admin/themes/api-download-theme/%20");
+ downloadRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(downloadRequest);
+
+ // Assert
+ Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/Themes/GetThemes/GetThemesEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/Themes/GetThemes/GetThemesEndpointTests.cs
new file mode 100644
index 00000000..38c8b797
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/Themes/GetThemes/GetThemesEndpointTests.cs
@@ -0,0 +1,69 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.DTO.Themes;
+using Lumina.Presentation.Web.Core.Endpoints.Admin.Themes.GetThemes;
+using Lumina.Presentation.Web.Fixtures.Common.DTO.Themes;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text.Json;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Admin.Themes.GetThemes;
+
+///
+/// Contains integration tests for the /{culture}/admin/themes/api-get-themes route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class GetThemesEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly ThemeResponseDtoFixture _themeResponseDtoFixture = new();
+ private readonly ThemeSettingsResponseDtoFixture _themeSettingsResponseDtoFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public GetThemesEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task GetThemes_WhenCalledByAuthenticatedAdmin_ShouldReturnThemesFromApi()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ ThemeResponseDto[] expectedThemes = [.. _themeResponseDtoFixture.CreateMany()];
+ ThemeResponseDto currentTheme = _themeResponseDtoFixture.Create(themeId: "current-theme");
+ ThemeSettingsResponseDto expectedSettings = _themeSettingsResponseDtoFixture.Create();
+ _apiFactory.ApiClientStub.RegisterGetResponse("themes", expectedThemes);
+ _apiFactory.ApiClientStub.RegisterGetResponse("themes/current", currentTheme);
+ _apiFactory.ApiClientStub.RegisterGetResponse("themes/settings", expectedSettings);
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage getRequest = new(HttpMethod.Get, "/en-us/admin/themes/api-get-themes");
+ getRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(getRequest);
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ using JsonDocument json = JsonDocument.Parse(content);
+ Assert.True(json.RootElement.GetProperty("success").GetBoolean());
+ JsonElement data = json.RootElement.GetProperty("data");
+ Assert.Equal(expectedThemes.Length, data.GetProperty("themes").GetArrayLength());
+ Assert.Equal("current-theme", data.GetProperty("currentThemeId").GetString());
+ Assert.Equal(expectedSettings.MaxArchiveBytes, data.GetProperty("maxArchiveBytes").GetInt64());
+ Assert.Contains(_apiFactory.ApiClientStub.GetEndpointsCalled, endpoint => endpoint == "themes");
+ Assert.Contains(_apiFactory.ApiClientStub.GetEndpointsCalled, endpoint => endpoint == "themes/current");
+ Assert.Contains(_apiFactory.ApiClientStub.GetEndpointsCalled, endpoint => endpoint == "themes/settings");
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/Themes/InstallTheme/InstallThemeEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/Themes/InstallTheme/InstallThemeEndpointTests.cs
new file mode 100644
index 00000000..ea838726
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/Themes/InstallTheme/InstallThemeEndpointTests.cs
@@ -0,0 +1,96 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.DTO.Themes;
+using Lumina.Presentation.Web.Core.Endpoints.Admin.Themes.InstallTheme;
+using Lumina.Presentation.Web.Fixtures.Common.DTO.Themes;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text.Json;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Admin.Themes.InstallTheme;
+
+///
+/// Contains integration tests for the /{culture}/admin/themes/api-install-theme route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class InstallThemeEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly ThemeResponseDtoFixture _themeResponseDtoFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public InstallThemeEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task InstallTheme_WhenCalledByAuthenticatedAdminWithAntiforgeryToken_ShouldForwardUploadAndReturnSuccess()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ string fileName = "theme.zip";
+ _apiFactory.ApiClientStub.RegisterPostResponse("themes", _themeResponseDtoFixture.Create());
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage installRequest = new(HttpMethod.Post, "/en-us/admin/themes/api-install-theme")
+ {
+ Content = CreateMultipartContent(fileName)
+ };
+ installRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+ installRequest.Headers.Add("RequestVerificationToken", webClient.AntiforgeryToken);
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(installRequest);
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ using JsonDocument json = JsonDocument.Parse(content);
+ Assert.True(json.RootElement.GetProperty("success").GetBoolean());
+ Assert.Contains(_apiFactory.ApiClientStub.PostRequests, postRequest => postRequest.Endpoint == "themes" && postRequest.Data as string == fileName);
+ }
+
+ [Fact]
+ public async Task InstallTheme_WhenCalledWithoutAntiforgeryToken_ShouldRejectRequest()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage installRequest = new(HttpMethod.Post, "/en-us/admin/themes/api-install-theme")
+ {
+ Content = CreateMultipartContent("theme.zip")
+ };
+ installRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(installRequest);
+
+ // Assert
+ Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
+ Assert.DoesNotContain(_apiFactory.ApiClientStub.PostRequests, postRequest => postRequest.Endpoint == "themes");
+ }
+
+ ///
+ /// Builds a multipart form content carrying a single file part.
+ ///
+ /// The name of the uploaded file.
+ /// The multipart form content.
+ private static MultipartFormDataContent CreateMultipartContent(string fileName)
+ {
+ MultipartFormDataContent form = [];
+ ByteArrayContent fileContent = new([0x50, 0x4B, 0x03, 0x04]);
+ fileContent.Headers.ContentType = new MediaTypeHeaderValue("application/zip");
+ form.Add(fileContent, "archive", fileName);
+ return form;
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/Themes/RestoreTheme/RestoreThemeEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/Themes/RestoreTheme/RestoreThemeEndpointTests.cs
new file mode 100644
index 00000000..37b2a082
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/Themes/RestoreTheme/RestoreThemeEndpointTests.cs
@@ -0,0 +1,64 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.DTO.Themes;
+using Lumina.Presentation.Web.Core.Endpoints.Admin.Themes.RestoreTheme;
+using Lumina.Presentation.Web.Fixtures.Common.DTO.Themes;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text;
+using System.Text.Json;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Admin.Themes.RestoreTheme;
+
+///
+/// Contains integration tests for the /{culture}/admin/themes/api-restore-theme/{themeId} route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class RestoreThemeEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly ThemeResponseDtoFixture _themeResponseDtoFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public RestoreThemeEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task RestoreTheme_WhenCalledByAuthenticatedAdminWithAntiforgeryToken_ShouldRestoreThemeAndReturnSuccess()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ const string THEME_ID = "test-theme";
+ _apiFactory.ApiClientStub.RegisterPostResponse($"themes/{THEME_ID}/restore", _themeResponseDtoFixture.Create());
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage restoreRequest = new(HttpMethod.Post, $"/en-us/admin/themes/api-restore-theme/{THEME_ID}")
+ {
+ Content = new StringContent("{}", Encoding.UTF8, "application/json")
+ };
+ restoreRequest.Content!.Headers.ContentType = new MediaTypeHeaderValue("application/json");
+ restoreRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+ restoreRequest.Headers.Add("RequestVerificationToken", webClient.AntiforgeryToken);
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(restoreRequest);
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ using JsonDocument json = JsonDocument.Parse(content);
+ Assert.True(json.RootElement.GetProperty("success").GetBoolean());
+ Assert.Contains(_apiFactory.ApiClientStub.PostRequests, postRequest => postRequest.Endpoint == $"themes/{THEME_ID}/restore");
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/Themes/SetCurrentTheme/SetCurrentThemeEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/Themes/SetCurrentTheme/SetCurrentThemeEndpointTests.cs
new file mode 100644
index 00000000..ec36ed94
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/Themes/SetCurrentTheme/SetCurrentThemeEndpointTests.cs
@@ -0,0 +1,65 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.DTO.Themes;
+using Lumina.Presentation.Web.Common.Requests.Themes;
+using Lumina.Presentation.Web.Core.Endpoints.Admin.Themes.SetCurrentTheme;
+using Lumina.Presentation.Web.Fixtures.Common.DTO.Themes;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Net.Http.Json;
+using System.Text.Json;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Admin.Themes.SetCurrentTheme;
+
+///
+/// Contains integration tests for the /{culture}/admin/themes/api-set-current-theme route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class SetCurrentThemeEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly ThemeResponseDtoFixture _themeResponseDtoFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public SetCurrentThemeEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task SetCurrentTheme_WhenCalledByAuthenticatedAdminWithAntiforgeryToken_ShouldSetCurrentThemeAndReturnSuccess()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ const string THEME_ID = "test-theme";
+ _apiFactory.ApiClientStub.RegisterPutResponse("themes/current", _themeResponseDtoFixture.Create());
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage setCurrentThemeRequest = new(HttpMethod.Put, "/en-us/admin/themes/api-set-current-theme")
+ {
+ Content = JsonContent.Create(new SetCurrentThemeRequest(THEME_ID))
+ };
+ setCurrentThemeRequest.Content!.Headers.ContentType = new MediaTypeHeaderValue("application/json");
+ setCurrentThemeRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+ setCurrentThemeRequest.Headers.Add("RequestVerificationToken", webClient.AntiforgeryToken);
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(setCurrentThemeRequest);
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ using JsonDocument json = JsonDocument.Parse(content);
+ Assert.True(json.RootElement.GetProperty("success").GetBoolean());
+ Assert.Contains(_apiFactory.ApiClientStub.PutRequests, putRequest => putRequest.Endpoint == "themes/current");
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/Themes/ThemesIndexViewEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/Themes/ThemesIndexViewEndpointTests.cs
new file mode 100644
index 00000000..f9ab2759
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/Themes/ThemesIndexViewEndpointTests.cs
@@ -0,0 +1,54 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.DTO.Themes;
+using Lumina.Presentation.Web.Core.Endpoints.Admin.Themes;
+using Lumina.Presentation.Web.Fixtures.Common.DTO.Themes;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Admin.Themes;
+
+///
+/// Contains integration tests for the /{culture}/admin/manage-themes route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class ThemesIndexViewEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly ThemeResponseDtoFixture _themeResponseDtoFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public ThemesIndexViewEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task ThemesIndex_WhenCalledByAuthenticatedAdmin_ShouldRenderThemesManagementPage()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ ThemeResponseDto[] expectedThemes = [.. _themeResponseDtoFixture.CreateMany()];
+ ThemeResponseDto currentTheme = _themeResponseDtoFixture.Create(themeId: "current-theme");
+ _apiFactory.ApiClientStub.RegisterGetResponse("themes", expectedThemes);
+ _apiFactory.ApiClientStub.RegisterGetResponse("themes/current", currentTheme);
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.GetAsync("/en-us/admin/manage-themes");
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ Assert.Equal("text/html", response.Content.Headers.ContentType!.MediaType);
+ Assert.Contains(_apiFactory.ApiClientStub.GetEndpointsCalled, endpoint => endpoint == "themes");
+ Assert.Contains(_apiFactory.ApiClientStub.GetEndpointsCalled, endpoint => endpoint == "themes/current");
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/UsersManagement/Authorization/GetUserPermissions/GetUserPermissionsEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/UsersManagement/Authorization/GetUserPermissions/GetUserPermissionsEndpointTests.cs
new file mode 100644
index 00000000..781e3dd4
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/UsersManagement/Authorization/GetUserPermissions/GetUserPermissionsEndpointTests.cs
@@ -0,0 +1,78 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.DTO.Authorization;
+using Lumina.Presentation.Web.Core.Endpoints.Admin.UsersManagement.Authorization.GetUserPermissions;
+using Lumina.Presentation.Web.Fixtures.Common.DTO.Authorization;
+using Lumina.Presentation.Web.Fixtures.Common.Responses.Authorization;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text.Json;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Admin.UsersManagement.Authorization.GetUserPermissions;
+
+///
+/// Contains integration tests for the /{culture}/admin/api-get-permissions-by-user-id/{userId} route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class GetUserPermissionsEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly GetAuthorizationResponseFixture _getAuthorizationResponseFixture = new();
+ private readonly PermissionDtoFixture _permissionDtoFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public GetUserPermissionsEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task GetUserPermissions_WhenCalledByAuthenticatedAdmin_ShouldReturnUserPermissionsJson()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ _apiFactory.ApiClientStub.AuthorizationResponse = _getAuthorizationResponseFixture.Create(userId: Guid.NewGuid(), role: "Admin", permissions: []);
+ Guid userId = Guid.NewGuid();
+ PermissionDto[] expectedPermissions = [.. _permissionDtoFixture.CreateMany()];
+ _apiFactory.ApiClientStub.RegisterGetResponse($"auth/users/{userId}/permissions", expectedPermissions);
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage getRequest = new(HttpMethod.Get, $"/en-us/admin/api-get-permissions-by-user-id/{userId}");
+ getRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(getRequest);
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ using JsonDocument json = JsonDocument.Parse(content);
+ Assert.True(json.RootElement.GetProperty("success").GetBoolean());
+ Assert.Equal(expectedPermissions.Length, json.RootElement.GetProperty("data").GetArrayLength());
+ }
+
+ [Fact]
+ public async Task GetUserPermissions_WhenCalledByNonAdminUser_ShouldRedirectToAccessDenied()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ _apiFactory.ApiClientStub.AuthorizationResponse = _getAuthorizationResponseFixture.Create(userId: Guid.NewGuid(), role: "User", permissions: []);
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.GetAsync("/en-us/admin/api-get-permissions-by-user-id/" + Guid.NewGuid());
+
+ // Assert
+ Assert.Equal(HttpStatusCode.Redirect, response.StatusCode);
+ Assert.Contains("access-denied", response.Headers.Location!.ToString());
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/UsersManagement/Authorization/GetUserRole/GetUserRoleEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/UsersManagement/Authorization/GetUserRole/GetUserRoleEndpointTests.cs
new file mode 100644
index 00000000..d2dab495
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/UsersManagement/Authorization/GetUserRole/GetUserRoleEndpointTests.cs
@@ -0,0 +1,78 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.DTO.Authorization;
+using Lumina.Presentation.Web.Core.Endpoints.Admin.UsersManagement.Authorization.GetUserRole;
+using Lumina.Presentation.Web.Fixtures.Common.DTO.Authorization;
+using Lumina.Presentation.Web.Fixtures.Common.Responses.Authorization;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text.Json;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Admin.UsersManagement.Authorization.GetUserRole;
+
+///
+/// Contains integration tests for the /{culture}/admin/api-get-role-by-user-id/{userId} route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class GetUserRoleEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly GetAuthorizationResponseFixture _getAuthorizationResponseFixture = new();
+ private readonly RoleDtoFixture _roleDtoFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public GetUserRoleEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task GetUserRole_WhenCalledByAuthenticatedAdmin_ShouldReturnUserRoleJson()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ _apiFactory.ApiClientStub.AuthorizationResponse = _getAuthorizationResponseFixture.Create(userId: Guid.NewGuid(), role: "Admin", permissions: []);
+ Guid userId = Guid.NewGuid();
+ RoleDto expectedRole = _roleDtoFixture.Create();
+ _apiFactory.ApiClientStub.RegisterGetResponse($"auth/users/{userId}/role", expectedRole);
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage getRequest = new(HttpMethod.Get, $"/en-us/admin/api-get-role-by-user-id/{userId}");
+ getRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(getRequest);
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ using JsonDocument json = JsonDocument.Parse(content);
+ Assert.True(json.RootElement.GetProperty("success").GetBoolean());
+ Assert.Equal(expectedRole.RoleName, json.RootElement.GetProperty("data").GetProperty("roleName").GetString());
+ }
+
+ [Fact]
+ public async Task GetUserRole_WhenCalledByNonAdminUser_ShouldRedirectToAccessDenied()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ _apiFactory.ApiClientStub.AuthorizationResponse = _getAuthorizationResponseFixture.Create(userId: Guid.NewGuid(), role: "User", permissions: []);
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.GetAsync("/en-us/admin/api-get-role-by-user-id/" + Guid.NewGuid());
+
+ // Assert
+ Assert.Equal(HttpStatusCode.Redirect, response.StatusCode);
+ Assert.Contains("access-denied", response.Headers.Location!.ToString());
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/UsersManagement/Authorization/UpdateUserRoleAndPermissions/UpdateUserRoleAndPermissionsEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/UsersManagement/Authorization/UpdateUserRoleAndPermissions/UpdateUserRoleAndPermissionsEndpointTests.cs
new file mode 100644
index 00000000..90843ed4
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Admin/UsersManagement/Authorization/UpdateUserRoleAndPermissions/UpdateUserRoleAndPermissionsEndpointTests.cs
@@ -0,0 +1,94 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.Requests.Authorization;
+using Lumina.Presentation.Web.Common.Responses.Authorization;
+using Lumina.Presentation.Web.Core.Endpoints.Admin.UsersManagement.Authorization.UpdateUserRoleAndPermissions;
+using Lumina.Presentation.Web.Fixtures.Common.Requests.Authorization;
+using Lumina.Presentation.Web.Fixtures.Common.Responses.Authorization;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Net.Http.Json;
+using System.Text.Json;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Admin.UsersManagement.Authorization.UpdateUserRoleAndPermissions;
+
+///
+/// Contains integration tests for the /{culture}/admin/api-update-user-authorization route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class UpdateUserRoleAndPermissionsEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly GetAuthorizationResponseFixture _getAuthorizationResponseFixture = new();
+ private readonly UpdateUserRoleAndPermissionsRequestFixture _updateUserRoleAndPermissionsRequestFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public UpdateUserRoleAndPermissionsEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task UpdateUserRoleAndPermissions_WhenCalledByAuthenticatedAdminWithAntiforgeryToken_ShouldForwardUpdateAndReturnSuccess()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ _apiFactory.ApiClientStub.AuthorizationResponse = _getAuthorizationResponseFixture.Create(userId: Guid.NewGuid(), role: "Admin", permissions: []);
+ UpdateUserRoleAndPermissionsRequest request = _updateUserRoleAndPermissionsRequestFixture.Create();
+ string expectedEndpoint = $"auth/users/{request.UserId}/role-and-permissions";
+ GetAuthorizationResponse expectedResponse = _getAuthorizationResponseFixture.Create(userId: request.UserId);
+ _apiFactory.ApiClientStub.RegisterPutResponse(expectedEndpoint, expectedResponse);
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage updateRequest = new(HttpMethod.Put, "/en-us/admin/api-update-user-authorization")
+ {
+ Content = JsonContent.Create(request)
+ };
+ updateRequest.Content!.Headers.ContentType = new MediaTypeHeaderValue("application/json");
+ updateRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+ updateRequest.Headers.Add("RequestVerificationToken", webClient.AntiforgeryToken);
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(updateRequest);
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ using JsonDocument json = JsonDocument.Parse(content);
+ Assert.True(json.RootElement.GetProperty("success").GetBoolean());
+ Assert.Contains(_apiFactory.ApiClientStub.PutRequests, putRequest => putRequest.Endpoint == expectedEndpoint);
+ }
+
+ [Fact]
+ public async Task UpdateUserRoleAndPermissions_WhenCalledByNonAdminUser_ShouldRedirectToAccessDenied()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ _apiFactory.ApiClientStub.AuthorizationResponse = _getAuthorizationResponseFixture.Create(userId: Guid.NewGuid(), role: "User", permissions: []);
+ UpdateUserRoleAndPermissionsRequest request = _updateUserRoleAndPermissionsRequestFixture.Create();
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage updateRequest = new(HttpMethod.Put, "/en-us/admin/api-update-user-authorization")
+ {
+ Content = JsonContent.Create(request)
+ };
+ updateRequest.Content!.Headers.ContentType = new MediaTypeHeaderValue("application/json");
+ updateRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+ updateRequest.Headers.Add("RequestVerificationToken", webClient.AntiforgeryToken);
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(updateRequest);
+
+ // Assert
+ Assert.Equal(HttpStatusCode.Redirect, response.StatusCode);
+ Assert.Contains("access-denied", response.Headers.Location!.ToString());
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/FileSystemManagement/Directories/GetDirectories/GetDirectoriesEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/FileSystemManagement/Directories/GetDirectories/GetDirectoriesEndpointTests.cs
new file mode 100644
index 00000000..c1ff40b9
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/FileSystemManagement/Directories/GetDirectories/GetDirectoriesEndpointTests.cs
@@ -0,0 +1,61 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
+using Lumina.Presentation.Web.Core.Endpoints.FileSystemManagement.Directories.GetDirectories;
+using Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text.Json;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.FileSystemManagement.Directories.GetDirectories;
+
+///
+/// Contains integration tests for the /directories/api-get-directories route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class GetDirectoriesEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly DirectoryDtoFixture _directoryDtoFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public GetDirectoriesEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task GetDirectories_WhenCalledByAuthenticatedUser_ShouldReturnDirectoriesFromApi()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ string path = @"C:\Users\test";
+ DirectoryDto[] expectedDirectories = [_directoryDtoFixture.Create(path: path, name: "test")];
+ string expectedEndpoint = $"directories/get-directories?path={Uri.EscapeDataString(path)}&includeHiddenElements=True";
+ _apiFactory.ApiClientStub.RegisterGetResponse(expectedEndpoint, expectedDirectories);
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage getRequest = new(HttpMethod.Get, $"/directories/api-get-directories?path={Uri.EscapeDataString(path)}&includeHiddenElements=true");
+ getRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(getRequest);
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ using JsonDocument json = JsonDocument.Parse(content);
+ Assert.True(json.RootElement.GetProperty("success").GetBoolean());
+ Assert.Equal(expectedDirectories.Length, json.RootElement.GetProperty("data").GetArrayLength());
+ Assert.Contains(expectedEndpoint, _apiFactory.ApiClientStub.GetEndpointsCalled);
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/FileSystemManagement/Drives/GetDrives/GetDrivesEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/FileSystemManagement/Drives/GetDrives/GetDrivesEndpointTests.cs
new file mode 100644
index 00000000..07c7e66c
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/FileSystemManagement/Drives/GetDrives/GetDrivesEndpointTests.cs
@@ -0,0 +1,58 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
+using Lumina.Presentation.Web.Core.Endpoints.FileSystemManagement.Drives.GetDrives;
+using Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text.Json;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.FileSystemManagement.Drives.GetDrives;
+
+///
+/// Contains integration tests for the /drives/api-get-drives route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class GetDrivesEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly FileSystemTreeNodeDtoFixture _fileSystemTreeNodeDtoFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public GetDrivesEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task GetDrives_WhenCalledByAuthenticatedUser_ShouldReturnDrivesFromApi()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ FileSystemTreeNodeDto[] expectedDrives = [_fileSystemTreeNodeDtoFixture.Create(path: "C:\\", name: "C:")];
+ _apiFactory.ApiClientStub.RegisterGetResponse("drives/get-drives", expectedDrives);
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage getRequest = new(HttpMethod.Get, "/drives/api-get-drives");
+ getRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(getRequest);
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ using JsonDocument json = JsonDocument.Parse(content);
+ Assert.True(json.RootElement.GetProperty("success").GetBoolean());
+ Assert.Equal(expectedDrives.Length, json.RootElement.GetProperty("data").GetProperty("drives").GetArrayLength());
+ Assert.Contains("drives/get-drives", _apiFactory.ApiClientStub.GetEndpointsCalled);
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/FileSystemManagement/FileSystem/GetType/GetTypeEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/FileSystemManagement/FileSystem/GetType/GetTypeEndpointTests.cs
new file mode 100644
index 00000000..f2153bc0
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/FileSystemManagement/FileSystem/GetType/GetTypeEndpointTests.cs
@@ -0,0 +1,57 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.Enums.FileSystem;
+using Lumina.Presentation.Web.Core.Endpoints.FileSystemManagement.FileSystem.GetType;
+using Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text.Json;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.FileSystemManagement.FileSystem.GetType;
+
+///
+/// Contains integration tests for the /file-system/api-get-type route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class GetTypeEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly FileSystemTypeDtoFixture _fileSystemTypeDtoFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public GetTypeEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task GetType_WhenCalledByAuthenticatedUser_ShouldReturnFileSystemTypeFromApi()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ _apiFactory.ApiClientStub.RegisterGetResponse("file-system/get-type", _fileSystemTypeDtoFixture.Create(platformType: PlatformType.Windows));
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage getRequest = new(HttpMethod.Get, "/file-system/api-get-type");
+ getRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(getRequest);
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ using JsonDocument json = JsonDocument.Parse(content);
+ Assert.True(json.RootElement.GetProperty("success").GetBoolean());
+ Assert.Equal(nameof(PlatformType.Windows), json.RootElement.GetProperty("data").GetProperty("platformType").GetString());
+ Assert.Contains("file-system/get-type", _apiFactory.ApiClientStub.GetEndpointsCalled);
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/FileSystemManagement/Files/GetFiles/GetFilesEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/FileSystemManagement/Files/GetFiles/GetFilesEndpointTests.cs
new file mode 100644
index 00000000..cc2ccee9
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/FileSystemManagement/Files/GetFiles/GetFilesEndpointTests.cs
@@ -0,0 +1,61 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
+using Lumina.Presentation.Web.Core.Endpoints.FileSystemManagement.Files.GetFiles;
+using Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text.Json;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.FileSystemManagement.Files.GetFiles;
+
+///
+/// Contains integration tests for the /files/api-get-files route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class GetFilesEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly FileDtoFixture _fileDtoFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public GetFilesEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task GetFiles_WhenCalledByAuthenticatedUser_ShouldReturnFilesFromApi()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ string path = @"C:\Users\test";
+ FileDto[] expectedFiles = [_fileDtoFixture.Create(path: path, name: "book.pdf")];
+ string expectedEndpoint = $"files/get-files?path={Uri.EscapeDataString(path)}&includeHiddenElements=True";
+ _apiFactory.ApiClientStub.RegisterGetResponse(expectedEndpoint, expectedFiles);
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage getRequest = new(HttpMethod.Get, $"/files/api-get-files?path={Uri.EscapeDataString(path)}&includeHiddenElements=true");
+ getRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(getRequest);
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ using JsonDocument json = JsonDocument.Parse(content);
+ Assert.True(json.RootElement.GetProperty("success").GetBoolean());
+ Assert.Equal(expectedFiles.Length, json.RootElement.GetProperty("data").GetArrayLength());
+ Assert.Contains(expectedEndpoint, _apiFactory.ApiClientStub.GetEndpointsCalled);
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/FileSystemManagement/Files/GetTreeFiles/GetTreeFilesEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/FileSystemManagement/Files/GetTreeFiles/GetTreeFilesEndpointTests.cs
new file mode 100644
index 00000000..b391ad50
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/FileSystemManagement/Files/GetTreeFiles/GetTreeFilesEndpointTests.cs
@@ -0,0 +1,61 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
+using Lumina.Presentation.Web.Core.Endpoints.FileSystemManagement.Files.GetTreeFiles;
+using Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text.Json;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.FileSystemManagement.Files.GetTreeFiles;
+
+///
+/// Contains integration tests for the /files/api-get-tree-files route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class GetTreeFilesEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly FileSystemTreeNodeDtoFixture _fileSystemTreeNodeDtoFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public GetTreeFilesEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task GetTreeFiles_WhenCalledByAuthenticatedUser_ShouldReturnFileSystemTreeFromApi()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ string path = @"C:\Users\test";
+ FileSystemTreeNodeDto[] expectedNodes = [_fileSystemTreeNodeDtoFixture.Create(path: path, name: "test")];
+ string expectedEndpoint = $"files/get-tree-files?path={Uri.EscapeDataString(path)}&includeHiddenElements=True";
+ _apiFactory.ApiClientStub.RegisterGetResponse(expectedEndpoint, expectedNodes);
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage getRequest = new(HttpMethod.Get, $"/files/api-get-tree-files?path={Uri.EscapeDataString(path)}&includeHiddenElements=true");
+ getRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(getRequest);
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ using JsonDocument json = JsonDocument.Parse(content);
+ Assert.True(json.RootElement.GetProperty("success").GetBoolean());
+ Assert.Equal(expectedNodes.Length, json.RootElement.GetProperty("data").GetArrayLength());
+ Assert.Contains(expectedEndpoint, _apiFactory.ApiClientStub.GetEndpointsCalled);
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/FileSystemManagement/Path/CheckPathExists/CheckPathExistsEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/FileSystemManagement/Path/CheckPathExists/CheckPathExistsEndpointTests.cs
new file mode 100644
index 00000000..835e0471
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/FileSystemManagement/Path/CheckPathExists/CheckPathExistsEndpointTests.cs
@@ -0,0 +1,59 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Core.Endpoints.FileSystemManagement.Path.CheckPathExists;
+using Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text.Json;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.FileSystemManagement.Path.CheckPathExists;
+
+///
+/// Contains integration tests for the /path/api-check-path-exists route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class CheckPathExistsEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly PathExistsDtoFixture _pathExistsDtoFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public CheckPathExistsEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task CheckPathExists_WhenCalledByAuthenticatedUser_ShouldReturnExistenceFromApi()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ string path = @"C:\Users\test";
+ string expectedEndpoint = $"path/check-path-exists?path={Uri.EscapeDataString(path)}&includeHiddenElements=True";
+ _apiFactory.ApiClientStub.RegisterGetResponse(expectedEndpoint, _pathExistsDtoFixture.Create(exists: true));
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage getRequest = new(HttpMethod.Get, $"/path/api-check-path-exists?path={Uri.EscapeDataString(path)}&includeHiddenElements=true");
+ getRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(getRequest);
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ using JsonDocument json = JsonDocument.Parse(content);
+ Assert.True(json.RootElement.GetProperty("success").GetBoolean());
+ Assert.True(json.RootElement.GetProperty("data").GetProperty("exists").GetBoolean());
+ Assert.Contains(expectedEndpoint, _apiFactory.ApiClientStub.GetEndpointsCalled);
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/FileSystemManagement/Path/GetPathParent/GetPathParentEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/FileSystemManagement/Path/GetPathParent/GetPathParentEndpointTests.cs
new file mode 100644
index 00000000..f3c3d81e
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/FileSystemManagement/Path/GetPathParent/GetPathParentEndpointTests.cs
@@ -0,0 +1,61 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
+using Lumina.Presentation.Web.Core.Endpoints.FileSystemManagement.Path.GetPathParent;
+using Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text.Json;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.FileSystemManagement.Path.GetPathParent;
+
+///
+/// Contains integration tests for the /path/api-get-path-parent route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class GetPathParentEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly PathSegmentDtoFixture _pathSegmentDtoFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public GetPathParentEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task GetPathParent_WhenCalledByAuthenticatedUser_ShouldReturnPathSegmentsFromApi()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ string path = @"C:\Users\test";
+ PathSegmentDto[] expectedSegments = [_pathSegmentDtoFixture.Create(path: @"C:\Users")];
+ string expectedEndpoint = $"path/get-path-parent?path={Uri.EscapeDataString(path)}";
+ _apiFactory.ApiClientStub.RegisterGetResponse(expectedEndpoint, expectedSegments);
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage getRequest = new(HttpMethod.Get, $"/path/api-get-path-parent?path={Uri.EscapeDataString(path)}");
+ getRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(getRequest);
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ using JsonDocument json = JsonDocument.Parse(content);
+ Assert.True(json.RootElement.GetProperty("success").GetBoolean());
+ Assert.Equal(expectedSegments.Length, json.RootElement.GetProperty("data").GetProperty("pathSegments").GetArrayLength());
+ Assert.Contains(expectedEndpoint, _apiFactory.ApiClientStub.GetEndpointsCalled);
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/FileSystemManagement/Path/GetPathRoot/GetPathRootEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/FileSystemManagement/Path/GetPathRoot/GetPathRootEndpointTests.cs
new file mode 100644
index 00000000..5aa67b41
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/FileSystemManagement/Path/GetPathRoot/GetPathRootEndpointTests.cs
@@ -0,0 +1,59 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Core.Endpoints.FileSystemManagement.Path.GetPathRoot;
+using Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text.Json;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.FileSystemManagement.Path.GetPathRoot;
+
+///
+/// Contains integration tests for the /path/api-get-path-root route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class GetPathRootEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly PathSegmentDtoFixture _pathSegmentDtoFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public GetPathRootEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task GetPathRoot_WhenCalledByAuthenticatedUser_ShouldReturnPathRootFromApi()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ string path = @"C:\Users\test";
+ string expectedEndpoint = $"path/get-path-root?path={Uri.EscapeDataString(path)}";
+ _apiFactory.ApiClientStub.RegisterGetResponse(expectedEndpoint, _pathSegmentDtoFixture.Create(path: @"C:\"));
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage getRequest = new(HttpMethod.Get, $"/path/api-get-path-root?path={Uri.EscapeDataString(path)}");
+ getRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(getRequest);
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ using JsonDocument json = JsonDocument.Parse(content);
+ Assert.True(json.RootElement.GetProperty("success").GetBoolean());
+ Assert.Equal(@"C:\", json.RootElement.GetProperty("data").GetProperty("root").GetProperty("path").GetString());
+ Assert.Contains(expectedEndpoint, _apiFactory.ApiClientStub.GetEndpointsCalled);
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/FileSystemManagement/Path/GetPathSeparator/GetPathSeparatorEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/FileSystemManagement/Path/GetPathSeparator/GetPathSeparatorEndpointTests.cs
new file mode 100644
index 00000000..c3d971da
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/FileSystemManagement/Path/GetPathSeparator/GetPathSeparatorEndpointTests.cs
@@ -0,0 +1,57 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Core.Endpoints.FileSystemManagement.Path.GetPathSeparator;
+using Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text.Json;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.FileSystemManagement.Path.GetPathSeparator;
+
+///
+/// Contains integration tests for the /path/api-get-path-separator route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class GetPathSeparatorEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly PathSeparatorDtoFixture _pathSeparatorDtoFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public GetPathSeparatorEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task GetPathSeparator_WhenCalledByAuthenticatedUser_ShouldReturnPathSeparatorFromApi()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ string expectedSeparator = "\\";
+ _apiFactory.ApiClientStub.RegisterGetResponse("path/get-path-separator", _pathSeparatorDtoFixture.Create(separator: expectedSeparator));
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage getRequest = new(HttpMethod.Get, "/path/api-get-path-separator");
+ getRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(getRequest);
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ using JsonDocument json = JsonDocument.Parse(content);
+ Assert.True(json.RootElement.GetProperty("success").GetBoolean());
+ Assert.Equal(expectedSeparator, json.RootElement.GetProperty("data").GetProperty("pathSeparator").GetString());
+ Assert.Contains("path/get-path-separator", _apiFactory.ApiClientStub.GetEndpointsCalled);
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/FileSystemManagement/Path/SplitPath/SplitPathEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/FileSystemManagement/Path/SplitPath/SplitPathEndpointTests.cs
new file mode 100644
index 00000000..9099673a
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/FileSystemManagement/Path/SplitPath/SplitPathEndpointTests.cs
@@ -0,0 +1,66 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
+using Lumina.Presentation.Web.Core.Endpoints.FileSystemManagement.Path.SplitPath;
+using Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text.Json;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.FileSystemManagement.Path.SplitPath;
+
+///
+/// Contains integration tests for the /path/api-split route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class SplitPathEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly PathSegmentDtoFixture _pathSegmentDtoFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public SplitPathEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task SplitPath_WhenCalledByAuthenticatedUser_ShouldReturnPathSegmentsFromApi()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ string path = @"C:\Users\test";
+ PathSegmentDto[] expectedSegments =
+ [
+ _pathSegmentDtoFixture.Create(path: @"C:\"),
+ _pathSegmentDtoFixture.Create(path: "Users"),
+ _pathSegmentDtoFixture.Create(path: "test")
+ ];
+ string expectedEndpoint = $"path/split?path={Uri.EscapeDataString(path)}";
+ _apiFactory.ApiClientStub.RegisterGetResponse(expectedEndpoint, expectedSegments);
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage getRequest = new(HttpMethod.Get, $"/path/api-split?path={Uri.EscapeDataString(path)}");
+ getRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(getRequest);
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ using JsonDocument json = JsonDocument.Parse(content);
+ Assert.True(json.RootElement.GetProperty("success").GetBoolean());
+ Assert.Equal(expectedSegments.Length, json.RootElement.GetProperty("data").GetProperty("pathSegments").GetArrayLength());
+ Assert.Contains(expectedEndpoint, _apiFactory.ApiClientStub.GetEndpointsCalled);
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/FileSystemManagement/Path/ValidatePath/ValidatePathEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/FileSystemManagement/Path/ValidatePath/ValidatePathEndpointTests.cs
new file mode 100644
index 00000000..01313cdc
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/FileSystemManagement/Path/ValidatePath/ValidatePathEndpointTests.cs
@@ -0,0 +1,59 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Core.Endpoints.FileSystemManagement.Path.ValidatePath;
+using Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text.Json;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.FileSystemManagement.Path.ValidatePath;
+
+///
+/// Contains integration tests for the /path/api-validate route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class ValidatePathEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly PathValidDtoFixture _pathValidDtoFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public ValidatePathEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task ValidatePath_WhenCalledByAuthenticatedUser_ShouldReturnValidityFromApi()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ string path = @"C:\Users\test";
+ string expectedEndpoint = $"path/validate?path={Uri.EscapeDataString(path)}";
+ _apiFactory.ApiClientStub.RegisterGetResponse(expectedEndpoint, _pathValidDtoFixture.Create(isValid: true));
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage getRequest = new(HttpMethod.Get, $"/path/api-validate?path={Uri.EscapeDataString(path)}");
+ getRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(getRequest);
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ using JsonDocument json = JsonDocument.Parse(content);
+ Assert.True(json.RootElement.GetProperty("success").GetBoolean());
+ Assert.True(json.RootElement.GetProperty("data").GetProperty("isValid").GetBoolean());
+ Assert.Contains(expectedEndpoint, _apiFactory.ApiClientStub.GetEndpointsCalled);
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Home/HomeErrorEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Home/HomeErrorEndpointTests.cs
new file mode 100644
index 00000000..60fab458
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Home/HomeErrorEndpointTests.cs
@@ -0,0 +1,46 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Core.Endpoints.Home;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Home;
+
+///
+/// Contains integration tests for the /{culture}/error route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class HomeErrorEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public HomeErrorEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task HomeError_WhenCalledByAuthenticatedUser_ShouldRenderErrorPage()
+ {
+ // Arrange
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.GetAsync("/en-us/error");
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ Assert.Equal("text/html", response.Content.Headers.ContentType!.MediaType);
+ string content = await response.Content.ReadAsStringAsync();
+ Assert.Contains("text-danger", content);
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Home/HomeNotFoundViewEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Home/HomeNotFoundViewEndpointTests.cs
new file mode 100644
index 00000000..09b1028f
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Home/HomeNotFoundViewEndpointTests.cs
@@ -0,0 +1,44 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Core.Endpoints.Home;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Home;
+
+///
+/// Contains integration tests for the /{culture}/not-found route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class HomeNotFoundViewEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public HomeNotFoundViewEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task HomeNotFoundView_WhenCalledByAuthenticatedUser_ShouldRenderNotFoundPage()
+ {
+ // Arrange
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.GetAsync("/en-us/not-found");
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ Assert.Equal("text/html", response.Content.Headers.ContentType!.MediaType);
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Home/HomePrivacyEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Home/HomePrivacyEndpointTests.cs
new file mode 100644
index 00000000..86ca4fb6
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Home/HomePrivacyEndpointTests.cs
@@ -0,0 +1,46 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Core.Endpoints.Home;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Home;
+
+///
+/// Contains integration tests for the /{culture}/privacy route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class HomePrivacyEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public HomePrivacyEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task HomePrivacy_WhenCalledByAuthenticatedUser_ShouldRenderPrivacyPage()
+ {
+ // Arrange
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.GetAsync("/en-us/privacy");
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ Assert.Equal("text/html", response.Content.Headers.ContentType!.MediaType);
+ string content = await response.Content.ReadAsStringAsync();
+ Assert.Contains("Privacy Policy", content);
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/AddLibrary/AddLibraryViewEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/AddLibrary/AddLibraryViewEndpointTests.cs
new file mode 100644
index 00000000..63ef8b49
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/AddLibrary/AddLibraryViewEndpointTests.cs
@@ -0,0 +1,45 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Core.Endpoints.Library.Management.AddLibrary;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Library.Management.AddLibrary;
+
+///
+/// Contains integration tests for the /{culture}/libraries/manage/item route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class AddLibraryViewEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public AddLibraryViewEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task AddLibraryView_WhenCalledByAuthenticatedUser_ShouldRenderLibraryAddingView()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.GetAsync("/en-us/libraries/manage/item");
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ Assert.Equal("text/html", response.Content.Headers.ContentType!.MediaType);
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/CancelLibrariesScan/CancelLibrariesScanEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/CancelLibrariesScan/CancelLibrariesScanEndpointTests.cs
new file mode 100644
index 00000000..7e85cdb0
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/CancelLibrariesScan/CancelLibrariesScanEndpointTests.cs
@@ -0,0 +1,71 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Core.Endpoints.Library.Management.CancelLibrariesScan;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text;
+using System.Text.Json;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Library.Management.CancelLibrariesScan;
+
+///
+/// Contains integration tests for the /{culture}/libraries/manage/api-cancel-libraries-scan route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class CancelLibrariesScanEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public CancelLibrariesScanEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task CancelLibrariesScan_WhenCalledByAuthenticatedUserWithAntiforgeryToken_ShouldCancelScansAndReturnSuccess()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ _apiFactory.ApiClientStub.RegisterPostResponseFactory("libraries/scans/cancel", _ => new Lumina.Presentation.Web.Common.Requests.Common.EmptyRequest());
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage cancelRequest = CreateCancelRequest("/en-us/libraries/manage/api-cancel-libraries-scan");
+ cancelRequest.Headers.Add("RequestVerificationToken", webClient.AntiforgeryToken);
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(cancelRequest);
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ using JsonDocument json = JsonDocument.Parse(content);
+ Assert.True(json.RootElement.GetProperty("success").GetBoolean());
+ Assert.Contains(_apiFactory.ApiClientStub.PostRequests, postRequest => postRequest.Endpoint == "libraries/scans/cancel");
+ }
+
+ ///
+ /// Builds the cancel request that posts an empty JSON body to the given .
+ ///
+ /// The URL of the cancel endpoint.
+ /// The configured cancel request.
+ private static HttpRequestMessage CreateCancelRequest(string url)
+ {
+ HttpRequestMessage cancelRequest = new(HttpMethod.Post, url)
+ {
+ Content = new StringContent("{}", Encoding.UTF8, "application/json")
+ };
+ // the antiforgery middleware matches the content type exactly, so the charset suffix must be omitted
+ cancelRequest.Content!.Headers.ContentType = new MediaTypeHeaderValue("application/json");
+ cancelRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+ return cancelRequest;
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/CancelLibraryScan/CancelLibraryScanEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/CancelLibraryScan/CancelLibraryScanEndpointTests.cs
new file mode 100644
index 00000000..93b3b4aa
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/CancelLibraryScan/CancelLibraryScanEndpointTests.cs
@@ -0,0 +1,74 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Core.Endpoints.Library.Management.CancelLibraryScan;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text;
+using System.Text.Json;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Library.Management.CancelLibraryScan;
+
+///
+/// Contains integration tests for the /{culture}/libraries/manage/{{libraryId}}/api-cancel-library-scan/{{scanId}} route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class CancelLibraryScanEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public CancelLibraryScanEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task CancelLibraryScan_WhenCalledByAuthenticatedUserWithAntiforgeryToken_ShouldCancelScanAndReturnSuccess()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ Guid libraryId = Guid.NewGuid();
+ Guid scanId = Guid.NewGuid();
+ _apiFactory.ApiClientStub.RegisterPostResponseFactory($"libraries/{libraryId}/scans/{scanId}/cancel", _ => new Lumina.Presentation.Web.Common.Requests.Common.EmptyRequest());
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage cancelRequest = CreateCancelRequest($"/en-us/libraries/manage/{libraryId}/api-cancel-library-scan/{scanId}");
+ cancelRequest.Headers.Add("RequestVerificationToken", webClient.AntiforgeryToken);
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(cancelRequest);
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ using JsonDocument json = JsonDocument.Parse(content);
+ Assert.True(json.RootElement.GetProperty("success").GetBoolean());
+ Assert.Contains(_apiFactory.ApiClientStub.PostRequests, postRequest => postRequest.Endpoint == $"libraries/{libraryId}/scans/{scanId}/cancel");
+ }
+
+ ///
+ /// Builds the cancel request that posts an empty JSON body to the given .
+ ///
+ /// The URL of the cancel endpoint.
+ /// The configured cancel request.
+ private static HttpRequestMessage CreateCancelRequest(string url)
+ {
+ HttpRequestMessage cancelRequest = new(HttpMethod.Post, url)
+ {
+ Content = new StringContent("{}", Encoding.UTF8, "application/json")
+ };
+ // the antiforgery middleware matches the content type exactly, so the charset suffix must be omitted
+ cancelRequest.Content!.Headers.ContentType = new MediaTypeHeaderValue("application/json");
+ cancelRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+ return cancelRequest;
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/DeleteLibrary/DeleteLibraryEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/DeleteLibrary/DeleteLibraryEndpointTests.cs
new file mode 100644
index 00000000..16c5b86f
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/DeleteLibrary/DeleteLibraryEndpointTests.cs
@@ -0,0 +1,74 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Core.Endpoints.Library.Management.DeleteLibrary;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text;
+using System.Text.Json;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Library.Management.DeleteLibrary;
+
+///
+/// Contains integration tests for the /{culture}/libraries/manage/api-item/{{id}} route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class DeleteLibraryEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public DeleteLibraryEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task DeleteLibrary_WhenCalledByAuthenticatedUserWithAntiforgeryToken_ShouldDeleteLibraryAndReturnSuccess()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ Guid libraryId = Guid.NewGuid();
+ _apiFactory.ApiClientStub.RegisterDeleteSuccess($"libraries/{libraryId}");
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage deleteRequest = CreateDeleteRequest(libraryId);
+ deleteRequest.Headers.Add("RequestVerificationToken", webClient.AntiforgeryToken);
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(deleteRequest);
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ using JsonDocument json = JsonDocument.Parse(content);
+ Assert.True(json.RootElement.GetProperty("success").GetBoolean());
+ Assert.Contains(_apiFactory.ApiClientStub.DeleteEndpointsCalled, endpoint => endpoint == $"libraries/{libraryId}");
+ }
+
+ ///
+ /// Builds the delete request for the library identified by .
+ ///
+ /// The Id of the library to delete.
+ /// The configured delete request.
+ private static HttpRequestMessage CreateDeleteRequest(Guid libraryId)
+ {
+ HttpRequestMessage deleteRequest = new(HttpMethod.Delete, $"/en-us/libraries/manage/api-item/{libraryId}")
+ {
+ // the front-end sends the JSON content type even for DELETE requests, which triggers the antiforgery validation
+ Content = new StringContent("{}", Encoding.UTF8, "application/json")
+ };
+ // the antiforgery middleware matches the content type exactly, so the charset suffix must be omitted
+ deleteRequest.Content!.Headers.ContentType = new MediaTypeHeaderValue("application/json");
+ deleteRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+ return deleteRequest;
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/EditLibrary/EditLibraryViewEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/EditLibrary/EditLibraryViewEndpointTests.cs
new file mode 100644
index 00000000..08ea87d2
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/EditLibrary/EditLibraryViewEndpointTests.cs
@@ -0,0 +1,53 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.DTO.Libraries;
+using Lumina.Presentation.Web.Core.Endpoints.Library.Management.EditLibrary;
+using Lumina.Presentation.Web.Fixtures.Common.DTO.Libraries;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Library.Management.EditLibrary;
+
+///
+/// Contains integration tests for the /{culture}/libraries/manage/item/{{id}} route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class EditLibraryViewEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly LibraryDtoFixture _libraryDtoFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public EditLibraryViewEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task EditLibraryView_WhenCalledByAuthenticatedUser_ShouldRenderLibraryEditingView()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ Guid libraryId = Guid.NewGuid();
+ LibraryDto expectedLibrary = _libraryDtoFixture.Create(id: libraryId, title: "Books", libraryType: "Book");
+ _apiFactory.ApiClientStub.RegisterGetResponse($"libraries/{libraryId}", expectedLibrary);
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.GetAsync($"/en-us/libraries/manage/item/{libraryId}");
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ Assert.Equal("text/html", response.Content.Headers.ContentType!.MediaType);
+ Assert.Contains($"libraries/{libraryId}", _apiFactory.ApiClientStub.GetEndpointsCalled);
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/GetEnabledLibraries/GetEnabledLibrariesEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/GetEnabledLibraries/GetEnabledLibrariesEndpointTests.cs
new file mode 100644
index 00000000..028e6e65
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/GetEnabledLibraries/GetEnabledLibrariesEndpointTests.cs
@@ -0,0 +1,82 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.DTO.Libraries;
+using Lumina.Presentation.Web.Core.Endpoints.Library.Management.GetEnabledLibraries;
+using Lumina.Presentation.Web.Fixtures.Common.DTO.Libraries;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text.Json;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Library.Management.GetEnabledLibraries;
+
+///
+/// Contains integration tests for the /{culture}/libraries/manage/api-get-enabled-libraries route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class GetEnabledLibrariesEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly LibraryDtoFixture _libraryDtoFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public GetEnabledLibrariesEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task GetEnabledLibraries_WhenCalledByAuthenticatedUser_ShouldReturnEnabledLibrariesJson()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ LibraryDto[] expectedLibraries =
+ [
+ _libraryDtoFixture.Create(id: Guid.NewGuid(), title: "Books", libraryType: "Book"),
+ _libraryDtoFixture.Create(id: Guid.NewGuid(), title: "Movies", libraryType: "Video")
+ ];
+ _apiFactory.ApiClientStub.RegisterGetResponse("libraries/enabled", expectedLibraries);
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage getRequest = new(HttpMethod.Get, "/en-us/libraries/manage/api-get-enabled-libraries");
+ getRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(getRequest);
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ using JsonDocument json = JsonDocument.Parse(content);
+ Assert.True(json.RootElement.GetProperty("success").GetBoolean());
+ JsonElement data = json.RootElement.GetProperty("data");
+ Assert.Equal(2, data.GetArrayLength());
+ Assert.Equal("Books", data[0].GetProperty("title").GetString());
+ }
+
+ [Fact]
+ public async Task GetEnabledLibraries_WhenCalled_ShouldRequestEnabledLibrariesFromApi()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ _apiFactory.ApiClientStub.RegisterGetResponse("libraries/enabled", Array.Empty());
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage getRequest = new(HttpMethod.Get, "/en-us/libraries/manage/api-get-enabled-libraries");
+ getRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(getRequest);
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Contains("libraries/enabled", _apiFactory.ApiClientStub.GetEndpointsCalled);
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/GetLibraries/GetLibrariesEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/GetLibraries/GetLibrariesEndpointTests.cs
index 5f793a82..d032e6cd 100644
--- a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/GetLibraries/GetLibrariesEndpointTests.cs
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/GetLibraries/GetLibrariesEndpointTests.cs
@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.DTO.Libraries;
using Lumina.Presentation.Web.Core.Endpoints.Library.Management.GetLibraries;
+using Lumina.Presentation.Web.Fixtures.Common.DTO.Libraries;
using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
using System;
@@ -20,6 +21,7 @@ namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Library.Manage
public class GetLibrariesEndpointTests : IClassFixture
{
private readonly LuminaWebFactory _apiFactory;
+ private readonly LibraryDtoFixture _libraryDtoFixture = new();
///
/// Initializes a new instance of the class.
@@ -37,8 +39,8 @@ public class GetLibrariesEndpointTests : IClassFixture
_apiFactory.ApiClientStub.Reset();
LibraryDto[] expectedLibraries =
[
- new LibraryDto { Id = Guid.NewGuid(), Title = "Books", LibraryType = "Book" },
- new LibraryDto { Id = Guid.NewGuid(), Title = "Movies", LibraryType = "Video" }
+ _libraryDtoFixture.Create(id: Guid.NewGuid(), title: "Books", libraryType: "Book"),
+ _libraryDtoFixture.Create(id: Guid.NewGuid(), title: "Movies", libraryType: "Video")
];
_apiFactory.ApiClientStub.RegisterGetResponse("libraries", expectedLibraries);
AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/GetMetadataProviders/GetMetadataProvidersEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/GetMetadataProviders/GetMetadataProvidersEndpointTests.cs
new file mode 100644
index 00000000..7ff6e394
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/GetMetadataProviders/GetMetadataProvidersEndpointTests.cs
@@ -0,0 +1,84 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.DTO.Plugins;
+using Lumina.Presentation.Web.Core.Endpoints.Library.Management.GetMetadataProviders;
+using Lumina.Presentation.Web.Fixtures.Common.DTO.Plugins;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text.Json;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Library.Management.GetMetadataProviders;
+
+///
+/// Contains integration tests for the /{culture}/libraries/manage/api-get-metadata-providers/{{libraryId}} route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class GetMetadataProvidersEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly LibraryMetadataProviderDtoFixture _libraryMetadataProviderDtoFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public GetMetadataProvidersEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task GetMetadataProviders_WhenCalledByAuthenticatedUser_ShouldReturnMetadataProvidersJson()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ Guid libraryId = Guid.NewGuid();
+ LibraryMetadataProviderDto[] expectedProviders =
+ [
+ _libraryMetadataProviderDtoFixture.Create(name: "Metadata Provider One", isEnabled: true, rank: 1),
+ _libraryMetadataProviderDtoFixture.Create(name: "Metadata Provider Two", isEnabled: false, rank: 2)
+ ];
+ _apiFactory.ApiClientStub.RegisterGetResponse($"libraries/{libraryId}/metadata-providers", expectedProviders);
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage getRequest = new(HttpMethod.Get, $"/en-us/libraries/manage/api-get-metadata-providers/{libraryId}");
+ getRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(getRequest);
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ using JsonDocument json = JsonDocument.Parse(content);
+ Assert.True(json.RootElement.GetProperty("success").GetBoolean());
+ JsonElement data = json.RootElement.GetProperty("data");
+ Assert.Equal(2, data.GetArrayLength());
+ Assert.Equal("Metadata Provider One", data[0].GetProperty("name").GetString());
+ }
+
+ [Fact]
+ public async Task GetMetadataProviders_WhenCalled_ShouldRequestMetadataProvidersFromApi()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ Guid libraryId = Guid.NewGuid();
+ _apiFactory.ApiClientStub.RegisterGetResponse($"libraries/{libraryId}/metadata-providers", Array.Empty());
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage getRequest = new(HttpMethod.Get, $"/en-us/libraries/manage/api-get-metadata-providers/{libraryId}");
+ getRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(getRequest);
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Contains($"libraries/{libraryId}/metadata-providers", _apiFactory.ApiClientStub.GetEndpointsCalled);
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/GetRunningLibraryScans/GetRunningLibraryScansEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/GetRunningLibraryScans/GetRunningLibraryScansEndpointTests.cs
new file mode 100644
index 00000000..4d1fcea0
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/GetRunningLibraryScans/GetRunningLibraryScansEndpointTests.cs
@@ -0,0 +1,82 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.DTO.Libraries;
+using Lumina.Presentation.Web.Core.Endpoints.Library.Management.GetRunningLibraryScans;
+using Lumina.Presentation.Web.Fixtures.Common.DTO.Libraries;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text.Json;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Library.Management.GetRunningLibraryScans;
+
+///
+/// Contains integration tests for the /{culture}/libraries/manage/api-get-running-library-scans route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class GetRunningLibraryScansEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly LibraryScanProgressDtoFixture _libraryScanProgressDtoFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public GetRunningLibraryScansEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task GetRunningLibraryScans_WhenCalledByAuthenticatedUser_ShouldReturnRunningLibraryScansJson()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ LibraryScanProgressDto[] expectedScans =
+ [
+ _libraryScanProgressDtoFixture.Create(includeCurrentJobProgress: true),
+ _libraryScanProgressDtoFixture.Create()
+ ];
+ _apiFactory.ApiClientStub.RegisterGetResponse("libraries/scans/running", expectedScans);
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage getRequest = new(HttpMethod.Get, "/en-us/libraries/manage/api-get-running-library-scans");
+ getRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(getRequest);
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ using JsonDocument json = JsonDocument.Parse(content);
+ Assert.True(json.RootElement.GetProperty("success").GetBoolean());
+ JsonElement data = json.RootElement.GetProperty("data");
+ Assert.Equal(2, data.GetArrayLength());
+ Assert.Equal(JsonValueKind.Object, data[0].GetProperty("currentJobProgress").ValueKind);
+ }
+
+ [Fact]
+ public async Task GetRunningLibraryScans_WhenCalled_ShouldRequestRunningLibraryScansFromApi()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ _apiFactory.ApiClientStub.RegisterGetResponse("libraries/scans/running", Array.Empty());
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage getRequest = new(HttpMethod.Get, "/en-us/libraries/manage/api-get-running-library-scans");
+ getRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(getRequest);
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Contains("libraries/scans/running", _apiFactory.ApiClientStub.GetEndpointsCalled);
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/Index/LibrariesIndexViewEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/Index/LibrariesIndexViewEndpointTests.cs
new file mode 100644
index 00000000..e36f0c3d
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/Index/LibrariesIndexViewEndpointTests.cs
@@ -0,0 +1,45 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Core.Endpoints.Library.Management.Index;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Library.Management.Index;
+
+///
+/// Contains integration tests for the /{culture}/libraries/manage route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class LibrariesIndexViewEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public LibrariesIndexViewEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task LibrariesIndexView_WhenCalledByAuthenticatedUser_ShouldRenderLibrariesManagementView()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.GetAsync("/en-us/libraries/manage");
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ Assert.Equal("text/html", response.Content.Headers.ContentType!.MediaType);
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/ReorderMetadataProviders/ReorderMetadataProvidersEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/ReorderMetadataProviders/ReorderMetadataProvidersEndpointTests.cs
new file mode 100644
index 00000000..6765f340
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/ReorderMetadataProviders/ReorderMetadataProvidersEndpointTests.cs
@@ -0,0 +1,71 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.Requests.Plugins;
+using Lumina.Presentation.Web.Core.Endpoints.Library.Management.ReorderMetadataProviders;
+using Lumina.Presentation.Web.Fixtures.Common.Requests.Plugins;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Net.Http.Json;
+using System.Text.Json;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Library.Management.ReorderMetadataProviders;
+
+///
+/// Contains integration tests for the /{culture}/libraries/manage/api-reorder-metadata-providers route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class ReorderMetadataProvidersEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly ReorderLibraryMetadataProvidersRequestFixture _reorderLibraryMetadataProvidersRequestFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public ReorderMetadataProvidersEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task ReorderMetadataProviders_WhenCalledByAuthenticatedUserWithAntiforgeryToken_ShouldReorderProvidersAndReturnSuccess()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ Guid libraryId = Guid.NewGuid();
+ Guid firstPluginId = Guid.NewGuid();
+ Guid secondPluginId = Guid.NewGuid();
+ ReorderLibraryMetadataProvidersRequest request = _reorderLibraryMetadataProvidersRequestFixture.Create(
+ libraryId: libraryId,
+ pluginIds: [firstPluginId, secondPluginId]
+ );
+ string expectedEndpoint = $"libraries/{libraryId}/metadata-providers/reorder";
+ _apiFactory.ApiClientStub.RegisterPutResponseFactory(expectedEndpoint, _ => new Lumina.Presentation.Web.Common.Requests.Common.EmptyRequest());
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage updateRequest = new(HttpMethod.Put, "/en-us/libraries/manage/api-reorder-metadata-providers")
+ {
+ Content = JsonContent.Create(request)
+ };
+ updateRequest.Content!.Headers.ContentType = new MediaTypeHeaderValue("application/json");
+ updateRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+ updateRequest.Headers.Add("RequestVerificationToken", webClient.AntiforgeryToken);
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(updateRequest);
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ using JsonDocument json = JsonDocument.Parse(content);
+ Assert.True(json.RootElement.GetProperty("success").GetBoolean());
+ Assert.Contains(_apiFactory.ApiClientStub.PutRequests, putRequest => putRequest.Endpoint == expectedEndpoint);
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/SaveLibrary/SaveLibraryEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/SaveLibrary/SaveLibraryEndpointTests.cs
index ceea2a3c..3d8485d6 100644
--- a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/SaveLibrary/SaveLibraryEndpointTests.cs
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/SaveLibrary/SaveLibraryEndpointTests.cs
@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.DTO.Libraries;
using Lumina.Presentation.Web.Core.Endpoints.Library.Management.SaveLibrary;
+using Lumina.Presentation.Web.Fixtures.Common.DTO.Libraries;
using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
using System;
@@ -22,6 +23,7 @@ namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Library.Manage
public class SaveLibraryEndpointTests : IClassFixture
{
private readonly LuminaWebFactory _apiFactory;
+ private readonly LibraryDtoFixture _libraryDtoFixture = new();
///
/// Initializes a new instance of the class.
@@ -37,8 +39,9 @@ public class SaveLibraryEndpointTests : IClassFixture
{
// Arrange
_apiFactory.ApiClientStub.Reset();
- LibraryDto request = new() { Title = "New Books Library", LibraryType = "Book" };
- LibraryDto expectedResponse = new() { Id = Guid.NewGuid(), Title = request.Title, LibraryType = request.LibraryType };
+ LibraryDto request = _libraryDtoFixture.Create(title: "New Books Library", libraryType: "Book");
+ request.Id = null;
+ LibraryDto expectedResponse = _libraryDtoFixture.Create(id: Guid.NewGuid(), title: request.Title, libraryType: request.LibraryType);
_apiFactory.ApiClientStub.RegisterPostResponse("libraries", expectedResponse);
AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
HttpRequestMessage saveRequest = new(HttpMethod.Post, "/en-us/libraries/manage/api-item")
@@ -69,7 +72,7 @@ public class SaveLibraryEndpointTests : IClassFixture
AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
HttpRequestMessage saveRequest = new(HttpMethod.Post, "/en-us/libraries/manage/api-item")
{
- Content = JsonContent.Create(new LibraryDto { Title = "New Books Library", LibraryType = "Book" })
+ Content = JsonContent.Create(_libraryDtoFixture.Create(title: "New Books Library", libraryType: "Book"))
};
saveRequest.Content!.Headers.ContentType = new MediaTypeHeaderValue("application/json");
saveRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/ScanLibraries/ScanLibrariesEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/ScanLibraries/ScanLibrariesEndpointTests.cs
new file mode 100644
index 00000000..f9dda266
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/ScanLibraries/ScanLibrariesEndpointTests.cs
@@ -0,0 +1,81 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.DTO.Libraries;
+using Lumina.Presentation.Web.Core.Endpoints.Library.Management.ScanLibraries;
+using Lumina.Presentation.Web.Fixtures.Common.DTO.Libraries;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text;
+using System.Text.Json;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Library.Management.ScanLibraries;
+
+///
+/// Contains integration tests for the /{culture}/libraries/manage/api-scan-libraries route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class ScanLibrariesEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly ScanLibraryDtoFixture _scanLibraryDtoFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public ScanLibrariesEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task ScanLibraries_WhenCalledByAuthenticatedUserWithAntiforgeryToken_ShouldInitiateScanAndReturnSuccess()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ Guid libraryId = Guid.NewGuid();
+ ScanLibraryDto[] expectedScans =
+ [
+ _scanLibraryDtoFixture.Create(libraryId: libraryId)
+ ];
+ _apiFactory.ApiClientStub.RegisterPostResponse("libraries/scans", expectedScans);
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage scanRequest = CreateScanRequest("/en-us/libraries/manage/api-scan-libraries");
+ scanRequest.Headers.Add("RequestVerificationToken", webClient.AntiforgeryToken);
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(scanRequest);
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ using JsonDocument json = JsonDocument.Parse(content);
+ Assert.True(json.RootElement.GetProperty("success").GetBoolean());
+ Assert.Equal(1, json.RootElement.GetProperty("data").GetArrayLength());
+ Assert.Contains(_apiFactory.ApiClientStub.PostRequests, postRequest => postRequest.Endpoint == "libraries/scans");
+ }
+
+ ///
+ /// Builds the scan request that posts an empty JSON body to the given .
+ ///
+ /// The URL of the scan endpoint.
+ /// The configured scan request.
+ private static HttpRequestMessage CreateScanRequest(string url)
+ {
+ HttpRequestMessage scanRequest = new(HttpMethod.Post, url)
+ {
+ Content = new StringContent("{}", Encoding.UTF8, "application/json")
+ };
+ // the antiforgery middleware matches the content type exactly, so the charset suffix must be omitted
+ scanRequest.Content!.Headers.ContentType = new MediaTypeHeaderValue("application/json");
+ scanRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+ return scanRequest;
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/ScanLibrary/ScanLibraryEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/ScanLibrary/ScanLibraryEndpointTests.cs
new file mode 100644
index 00000000..e615d08e
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/ScanLibrary/ScanLibraryEndpointTests.cs
@@ -0,0 +1,78 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.DTO.Libraries;
+using Lumina.Presentation.Web.Core.Endpoints.Library.Management.ScanLibrary;
+using Lumina.Presentation.Web.Fixtures.Common.DTO.Libraries;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text;
+using System.Text.Json;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Library.Management.ScanLibrary;
+
+///
+/// Contains integration tests for the /{culture}/libraries/manage/api-scan-library/{{id}} route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class ScanLibraryEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly ScanLibraryDtoFixture _scanLibraryDtoFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public ScanLibraryEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task ScanLibrary_WhenCalledByAuthenticatedUserWithAntiforgeryToken_ShouldInitiateScanAndReturnSuccess()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ Guid libraryId = Guid.NewGuid();
+ ScanLibraryDto expectedScan = _scanLibraryDtoFixture.Create(libraryId: libraryId);
+ _apiFactory.ApiClientStub.RegisterPostResponse($"libraries/{libraryId}/scans", expectedScan);
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage scanRequest = CreateScanRequest($"/en-us/libraries/manage/api-scan-library/{libraryId}");
+ scanRequest.Headers.Add("RequestVerificationToken", webClient.AntiforgeryToken);
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(scanRequest);
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ using JsonDocument json = JsonDocument.Parse(content);
+ Assert.True(json.RootElement.GetProperty("success").GetBoolean());
+ Assert.Equal(libraryId, json.RootElement.GetProperty("data").GetProperty("libraryId").GetGuid());
+ Assert.Contains(_apiFactory.ApiClientStub.PostRequests, postRequest => postRequest.Endpoint == $"libraries/{libraryId}/scans");
+ }
+
+ ///
+ /// Builds the scan request that posts an empty JSON body to the given .
+ ///
+ /// The URL of the scan endpoint.
+ /// The configured scan request.
+ private static HttpRequestMessage CreateScanRequest(string url)
+ {
+ HttpRequestMessage scanRequest = new(HttpMethod.Post, url)
+ {
+ Content = new StringContent("{}", Encoding.UTF8, "application/json")
+ };
+ // the antiforgery middleware matches the content type exactly, so the charset suffix must be omitted
+ scanRequest.Content!.Headers.ContentType = new MediaTypeHeaderValue("application/json");
+ scanRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+ return scanRequest;
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/SetMetadataProviderEnabled/SetMetadataProviderEnabledEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/SetMetadataProviderEnabled/SetMetadataProviderEnabledEndpointTests.cs
new file mode 100644
index 00000000..093e89a2
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/Management/SetMetadataProviderEnabled/SetMetadataProviderEnabledEndpointTests.cs
@@ -0,0 +1,71 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.Requests.Plugins;
+using Lumina.Presentation.Web.Core.Endpoints.Library.Management.SetMetadataProviderEnabled;
+using Lumina.Presentation.Web.Fixtures.Common.Requests.Plugins;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Net.Http.Json;
+using System.Text.Json;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Library.Management.SetMetadataProviderEnabled;
+
+///
+/// Contains integration tests for the /{culture}/libraries/manage/api-set-metadata-provider-enabled route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class SetMetadataProviderEnabledEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly SetLibraryMetadataProviderEnabledRequestFixture _setLibraryMetadataProviderEnabledRequestFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public SetMetadataProviderEnabledEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task SetMetadataProviderEnabled_WhenCalledByAuthenticatedUserWithAntiforgeryToken_ShouldEnableProviderAndReturnSuccess()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ Guid libraryId = Guid.NewGuid();
+ Guid pluginId = Guid.NewGuid();
+ SetLibraryMetadataProviderEnabledRequest request = _setLibraryMetadataProviderEnabledRequestFixture.Create(
+ libraryId: libraryId,
+ pluginId: pluginId,
+ isEnabled: true
+ );
+ string expectedEndpoint = $"libraries/{libraryId}/metadata-providers/{pluginId}/enabled";
+ _apiFactory.ApiClientStub.RegisterPutResponseFactory(expectedEndpoint, _ => new Lumina.Presentation.Web.Common.Requests.Common.EmptyRequest());
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage updateRequest = new(HttpMethod.Put, "/en-us/libraries/manage/api-set-metadata-provider-enabled")
+ {
+ Content = JsonContent.Create(request)
+ };
+ updateRequest.Content!.Headers.ContentType = new MediaTypeHeaderValue("application/json");
+ updateRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+ updateRequest.Headers.Add("RequestVerificationToken", webClient.AntiforgeryToken);
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(updateRequest);
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ using JsonDocument json = JsonDocument.Parse(content);
+ Assert.True(json.RootElement.GetProperty("success").GetBoolean());
+ Assert.Contains(_apiFactory.ApiClientStub.PutRequests, putRequest => putRequest.Endpoint == expectedEndpoint);
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/EditBook/EditBookViewEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/EditBook/EditBookViewEndpointTests.cs
new file mode 100644
index 00000000..6d694754
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/EditBook/EditBookViewEndpointTests.cs
@@ -0,0 +1,48 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Core.Endpoints.Library.WrittenContentLibrary.BookLibrary.Books.EditBook;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Library.WrittenContentLibrary.BookLibrary.Books.EditBook;
+
+///
+/// Contains integration tests for the /{culture}/library/written-content-library/books-library/books/{{id}} route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class EditBookViewEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public EditBookViewEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task EditBook_WhenCalledByAuthenticatedUser_ShouldRenderEditBookPage()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.GetAsync($"/en-us/library/written-content-library/books-library/books/{Guid.NewGuid()}");
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ Assert.Equal("text/html", response.Content.Headers.ContentType!.MediaType);
+ Assert.Contains("A book", content);
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/GetLibraryItems/GetLibraryItemsEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/GetLibraryItems/GetLibraryItemsEndpointTests.cs
new file mode 100644
index 00000000..3e3ac35e
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/GetLibraryItems/GetLibraryItemsEndpointTests.cs
@@ -0,0 +1,63 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.DTO.Libraries;
+using Lumina.Presentation.Web.Core.Endpoints.Library.WrittenContentLibrary.BookLibrary.Books.GetLibraryItems;
+using Lumina.Presentation.Web.Fixtures.Common.DTO.Libraries;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text.Json;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Library.WrittenContentLibrary.BookLibrary.Books.GetLibraryItems;
+
+///
+/// Contains integration tests for the /{culture}/library/written-content-library/books-library/books/api-get-library-items route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class GetLibraryItemsEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly PaginatedBookLiteDtoFixture _paginatedBookLiteDtoFixture = new();
+ private readonly BookLiteDtoFixture _bookLiteDtoFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public GetLibraryItemsEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task GetLibraryItems_WhenCalledByAuthenticatedUser_ShouldReturnBooksFromApi()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ Guid libraryId = Guid.NewGuid();
+ string searchTerm = "Harry";
+ PaginatedBookLiteDto expectedResponse = _paginatedBookLiteDtoFixture.Create(data: [_bookLiteDtoFixture.Create(title: "Harry Potter")]);
+ string expectedEndpoint = $"books/lite?libraryId={libraryId}¤tPage=1&perPage=20&searchTerm={searchTerm}&shouldIgnoreThePrefixForAlphaPicker=True";
+ _apiFactory.ApiClientStub.RegisterGetResponse(expectedEndpoint, expectedResponse);
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage getRequest = new(HttpMethod.Get, $"/en-us/library/written-content-library/books-library/books/api-get-library-items?libraryId={libraryId}¤tPage=1&perPage=20&searchTerm={searchTerm}&shouldIgnoreThePrefixForAlphaPicker=true");
+ getRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(getRequest);
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ using JsonDocument json = JsonDocument.Parse(content);
+ Assert.True(json.RootElement.GetProperty("success").GetBoolean());
+ Assert.Equal(expectedResponse.Data.Count, json.RootElement.GetProperty("data").GetProperty("data").GetArrayLength());
+ Assert.Contains(expectedEndpoint, _apiFactory.ApiClientStub.GetEndpointsCalled);
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/Index/BooksIndexViewEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/Index/BooksIndexViewEndpointTests.cs
new file mode 100644
index 00000000..2661e493
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Library/WrittenContentLibrary/BookLibrary/Books/Index/BooksIndexViewEndpointTests.cs
@@ -0,0 +1,70 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.DTO.Libraries;
+using Lumina.Presentation.Web.Core.Endpoints.Library.WrittenContentLibrary.BookLibrary.Books.Index;
+using Lumina.Presentation.Web.Fixtures.Common.DTO.Libraries;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Library.WrittenContentLibrary.BookLibrary.Books.Index;
+
+///
+/// Contains integration tests for the /{culture}/library/written-content-library/books-library/books route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class BooksIndexViewEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly LibraryDtoFixture _libraryDtoFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public BooksIndexViewEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task BooksIndex_WhenCalledByAuthenticatedUserWithLibraryId_ShouldRenderBooksPage()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ Guid libraryId = Guid.NewGuid();
+ LibraryDto expectedLibrary = _libraryDtoFixture.Create(id: libraryId, title: "Books");
+ _apiFactory.ApiClientStub.RegisterGetResponse($"libraries/{libraryId}", expectedLibrary);
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.GetAsync($"/en-us/library/written-content-library/books-library/books?libraryId={libraryId}");
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ Assert.Equal("text/html", response.Content.Headers.ContentType!.MediaType);
+ Assert.Contains("search-input", content);
+ Assert.Contains($"libraries/{libraryId}", _apiFactory.ApiClientStub.GetEndpointsCalled);
+ }
+
+ [Fact]
+ public async Task BooksIndex_WhenCalledByAuthenticatedUserWithoutLibraryId_ShouldRedirectToHome()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.GetAsync("/en-us/library/written-content-library/books-library/books");
+
+ // Assert
+ Assert.Equal(HttpStatusCode.Redirect, response.StatusCode);
+ Assert.Contains("/en-us", response.Headers.Location!.ToString());
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Plugins/GetPluginSettings/GetPluginSettingsEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Plugins/GetPluginSettings/GetPluginSettingsEndpointTests.cs
new file mode 100644
index 00000000..65bcc2b6
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Plugins/GetPluginSettings/GetPluginSettingsEndpointTests.cs
@@ -0,0 +1,61 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.DTO.Plugins;
+using Lumina.Presentation.Web.Core.Endpoints.Plugins.GetPluginSettings;
+using Lumina.Presentation.Web.Fixtures.Common.DTO.Plugins;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text.Json;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Plugins.GetPluginSettings;
+
+///
+/// Contains integration tests for the /{culture}/admin/manage-plugins/api-get-plugin-settings/{pluginId} route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class GetPluginSettingsEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly PluginSettingsDtoFixture _pluginSettingsDtoFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public GetPluginSettingsEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task GetPluginSettings_WhenCalledByAuthenticatedAdmin_ShouldReturnPluginSettingsFromApi()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ Guid pluginId = Guid.NewGuid();
+ PluginSettingsDto expectedSettings = _pluginSettingsDtoFixture.Create(pluginId: pluginId);
+ string expectedEndpoint = $"plugins/{pluginId}/settings";
+ _apiFactory.ApiClientStub.RegisterGetResponse(expectedEndpoint, expectedSettings);
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ HttpRequestMessage getRequest = new(HttpMethod.Get, $"/en-us/admin/manage-plugins/api-get-plugin-settings/{pluginId}");
+ getRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(getRequest);
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ using JsonDocument json = JsonDocument.Parse(content);
+ Assert.True(json.RootElement.GetProperty("success").GetBoolean());
+ Assert.Equal(pluginId, json.RootElement.GetProperty("data").GetProperty("pluginId").GetGuid());
+ Assert.Contains(_apiFactory.ApiClientStub.GetEndpointsCalled, endpoint => endpoint == expectedEndpoint);
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Plugins/Index/PluginsIndexViewEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Plugins/Index/PluginsIndexViewEndpointTests.cs
new file mode 100644
index 00000000..01346b29
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Plugins/Index/PluginsIndexViewEndpointTests.cs
@@ -0,0 +1,55 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.DTO.Plugins;
+using Lumina.Presentation.Web.Core.Endpoints.Plugins.Index;
+using Lumina.Presentation.Web.Fixtures.Common.DTO.Plugins;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Plugins.Index;
+
+///
+/// Contains integration tests for the /{culture}/admin/manage-plugins route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class PluginsIndexViewEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly PluginDtoFixture _pluginDtoFixture = new();
+ private readonly PluginSettingsDtoFixture _pluginSettingsDtoFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public PluginsIndexViewEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task PluginsIndex_WhenCalledByAuthenticatedAdmin_ShouldRenderPluginsManagementPage()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ PluginDto[] expectedPlugins = [_pluginDtoFixture.Create(name: "OpenLibrary")];
+ string settingsEndpoint = $"plugins/{expectedPlugins[0].Id}/settings";
+ _apiFactory.ApiClientStub.RegisterGetResponse("plugins", expectedPlugins);
+ _apiFactory.ApiClientStub.RegisterGetResponse(settingsEndpoint, _pluginSettingsDtoFixture.Create(pluginId: expectedPlugins[0].Id));
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.GetAsync("/en-us/admin/manage-plugins");
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ Assert.Equal("text/html", response.Content.Headers.ContentType!.MediaType);
+ Assert.Contains(_apiFactory.ApiClientStub.GetEndpointsCalled, endpoint => endpoint == "plugins");
+ Assert.Contains(_apiFactory.ApiClientStub.GetEndpointsCalled, endpoint => endpoint == settingsEndpoint);
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Themes/ThemeAssets/ThemeAssetsEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Themes/ThemeAssets/ThemeAssetsEndpointTests.cs
new file mode 100644
index 00000000..f5801bd9
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/Themes/ThemeAssets/ThemeAssetsEndpointTests.cs
@@ -0,0 +1,68 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Core.Endpoints.Themes.ThemeAssets;
+using Lumina.Presentation.Web.Fixtures.Common.DTO.FileSystemManagement;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.Themes.ThemeAssets;
+
+///
+/// Contains integration tests for the /theme-assets/{themeId}/{path} route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class ThemeAssetsEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly BlobDataDtoFixture _blobDataDtoFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public ThemeAssetsEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task ThemeAssets_WhenCalledWithValidThemeAndPath_ShouldReturnAsset()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ byte[] expectedBytes = [0x89, 0x50, 0x4E, 0x47];
+ _apiFactory.ApiClientStub.RegisterBlobResponse(_blobDataDtoFixture.Create(data: expectedBytes, contentType: "image/png"));
+ HttpClient client = WebTestHelpers.CreateAnonymousClient(_apiFactory);
+ HttpRequestMessage assetRequest = new(HttpMethod.Get, "/theme-assets/test-theme/assets/logo.png");
+ assetRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+
+ // Act
+ HttpResponseMessage response = await client.SendAsync(assetRequest);
+ byte[] content = await response.Content.ReadAsByteArrayAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ Assert.Equal("image/png", response.Content.Headers.ContentType!.MediaType);
+ Assert.Equal(expectedBytes, content);
+ }
+
+ [Fact]
+ public async Task ThemeAssets_WhenCalledWithEmptyPath_ShouldReturnBadRequest()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ HttpClient client = WebTestHelpers.CreateAnonymousClient(_apiFactory);
+
+ // Act
+ HttpResponseMessage response = await client.GetAsync("/theme-assets/test-theme/");
+
+ // Assert
+ Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/AccessDenied/AccessDeniedViewEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/AccessDenied/AccessDeniedViewEndpointTests.cs
new file mode 100644
index 00000000..751b5e03
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/AccessDenied/AccessDeniedViewEndpointTests.cs
@@ -0,0 +1,44 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Core.Endpoints.UsersManagement.Authentication.AccessDenied;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.UsersManagement.Authentication.AccessDenied;
+
+///
+/// Contains integration tests for the /{culture}/auth/access-denied route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class AccessDeniedViewEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public AccessDeniedViewEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task AccessDeniedView_WhenCalled_ShouldRenderAccessDeniedPage()
+ {
+ // Arrange
+ HttpClient client = WebTestHelpers.CreateAnonymousClient(_apiFactory);
+
+ // Act
+ HttpResponseMessage response = await client.GetAsync("/en-us/auth/access-denied");
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ Assert.Equal("text/html", response.Content.Headers.ContentType!.MediaType);
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/ChangePassword/ChangePasswordEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/ChangePassword/ChangePasswordEndpointTests.cs
new file mode 100644
index 00000000..88dea4da
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/ChangePassword/ChangePasswordEndpointTests.cs
@@ -0,0 +1,81 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.Requests.UsersManagement;
+using Lumina.Presentation.Web.Common.Responses.UsersManagement;
+using Lumina.Presentation.Web.Core.Endpoints.UsersManagement.Authentication.ChangePassword;
+using Lumina.Presentation.Web.Fixtures.Common.Requests.UsersManagement;
+using Lumina.Presentation.Web.Fixtures.Common.Responses.UsersManagement;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Net.Http.Json;
+using System.Text.Json;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.UsersManagement.Authentication.ChangePassword;
+
+///
+/// Contains integration tests for the /{culture}/auth/api-change-password route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class ChangePasswordEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly ChangePasswordRequestFixture _changePasswordRequestFixture = new();
+ private readonly ChangePasswordResponseFixture _changePasswordResponseFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public ChangePasswordEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task ChangePassword_WhenCalledByAuthenticatedUser_ShouldChangePasswordForCurrentUser()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ ChangePasswordResponse expectedResponse = _changePasswordResponseFixture.Create(isPasswordChanged: true);
+ _apiFactory.ApiClientStub.RegisterPostResponse("auth/change-password", expectedResponse);
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+ ChangePasswordRequest request = _changePasswordRequestFixture.Create(currentPassword: "OldPass123!", newPassword: "NewPass123!", newPasswordConfirm: "NewPass123!");
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.SendAsync(CreateChangePasswordRequest(request, webClient.AntiforgeryToken));
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ using JsonDocument json = JsonDocument.Parse(content);
+ Assert.True(json.RootElement.GetProperty("success").GetBoolean());
+ (string Endpoint, object? Data) postRequest = _apiFactory.ApiClientStub.PostRequests.Single(postRequest => postRequest.Endpoint == "auth/change-password");
+ ChangePasswordRequest sentRequest = Assert.IsType(postRequest.Data);
+ Assert.Equal("testuser", sentRequest.Username);
+ }
+
+ ///
+ /// Builds the change password request that sends the given to the change password endpoint.
+ ///
+ /// The change password request to send.
+ /// The antiforgery token to include in the request.
+ /// The configured change password request.
+ private static HttpRequestMessage CreateChangePasswordRequest(ChangePasswordRequest request, string antiforgeryToken)
+ {
+ HttpRequestMessage changePasswordRequest = new(HttpMethod.Post, "/en-us/auth/api-change-password")
+ {
+ Content = JsonContent.Create(request)
+ };
+ changePasswordRequest.Content!.Headers.ContentType = new MediaTypeHeaderValue("application/json");
+ changePasswordRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+ changePasswordRequest.Headers.Add("RequestVerificationToken", antiforgeryToken);
+ return changePasswordRequest;
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/ChangePassword/ChangePasswordViewEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/ChangePassword/ChangePasswordViewEndpointTests.cs
new file mode 100644
index 00000000..c82a4497
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/ChangePassword/ChangePasswordViewEndpointTests.cs
@@ -0,0 +1,46 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Core.Endpoints.UsersManagement.Authentication.ChangePassword;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.UsersManagement.Authentication.ChangePassword;
+
+///
+/// Contains integration tests for the /{culture}/auth/change-password route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class ChangePasswordViewEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public ChangePasswordViewEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task ChangePasswordView_WhenCalledByAuthenticatedUser_ShouldRenderChangePasswordPage()
+ {
+ // Arrange
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.GetAsync("/en-us/auth/change-password");
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ Assert.Equal("text/html", response.Content.Headers.ContentType!.MediaType);
+ string content = await response.Content.ReadAsStringAsync();
+ Assert.Contains("change-password-form", content);
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/Login/LoginEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/Login/LoginEndpointTests.cs
index 2195b24c..4b522b15 100644
--- a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/Login/LoginEndpointTests.cs
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/Login/LoginEndpointTests.cs
@@ -3,13 +3,13 @@ using Lumina.Presentation.Web.Common.DTO.Common;
using Lumina.Presentation.Web.Common.Exceptions;
using Lumina.Presentation.Web.Common.Requests.UsersManagement;
using Lumina.Presentation.Web.Core.Endpoints.UsersManagement.Authentication.Login;
+using Lumina.Presentation.Web.Fixtures.Common.DTO.Common;
+using Lumina.Presentation.Web.Fixtures.Common.Requests.UsersManagement;
using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
-using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
-using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
@@ -27,6 +27,8 @@ namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.UsersManagemen
public class LoginEndpointTests : IClassFixture
{
private readonly LuminaWebFactory _apiFactory;
+ private readonly LoginRequestFixture _loginRequestFixture = new();
+ private readonly ProblemDetailsDtoFixture _problemDetailsDtoFixture = new();
///
/// Initializes a new instance of the class.
@@ -44,7 +46,7 @@ public class LoginEndpointTests : IClassFixture
_apiFactory.ApiClientStub.Reset();
HttpClient client = WebTestHelpers.CreateAnonymousClient(_apiFactory);
string antiforgeryToken = await WebTestHelpers.GetAntiforgeryTokenAsync(client);
- HttpRequestMessage loginRequest = CreateLoginRequest(new LoginRequest(Username: "testuser", Password: "TestPass123!"), antiforgeryToken);
+ HttpRequestMessage loginRequest = CreateLoginRequest(_loginRequestFixture.Create(username: "testuser", password: "TestPass123!"), antiforgeryToken);
// Act
HttpResponseMessage response = await client.SendAsync(loginRequest);
@@ -65,19 +67,15 @@ public class LoginEndpointTests : IClassFixture
{
// Arrange
_apiFactory.ApiClientStub.Reset();
- ProblemDetailsDto problemDetails = new()
+ ProblemDetailsDto problemDetails = _problemDetailsDtoFixture.Create(title: "General.Validation", detail: "OneOrMoreValidationErrorsOccurred");
+ problemDetails.Extensions = new Dictionary
{
- Title = "General.Validation",
- Detail = "OneOrMoreValidationErrorsOccurred",
- Extensions = new Dictionary
- {
- ["errors"] = CreateErrorsElement(["InvalidTotpCode"])
- }
+ ["errors"] = CreateErrorsElement(["InvalidTotpCode"])
};
_apiFactory.ApiClientStub.RegisterPostException("auth/login", new ApiException(problemDetails, HttpStatusCode.UnprocessableEntity, "auth/login"));
HttpClient client = WebTestHelpers.CreateAnonymousClient(_apiFactory);
string antiforgeryToken = await WebTestHelpers.GetAntiforgeryTokenAsync(client);
- HttpRequestMessage loginRequest = CreateLoginRequest(new LoginRequest(Username: "testuser", Password: "TestPass123!"), antiforgeryToken);
+ HttpRequestMessage loginRequest = CreateLoginRequest(_loginRequestFixture.Create(username: "testuser", password: "TestPass123!"), antiforgeryToken);
// Act
HttpResponseMessage response = await client.SendAsync(loginRequest);
@@ -94,10 +92,10 @@ public class LoginEndpointTests : IClassFixture
{
// Arrange
_apiFactory.ApiClientStub.Reset();
- _apiFactory.ApiClientStub.RegisterPostException("auth/login", new ApiException(new ProblemDetailsDto { Title = "General.Failure", Detail = "InvalidUsernameOrPassword" }, HttpStatusCode.Forbidden, "auth/login"));
+ _apiFactory.ApiClientStub.RegisterPostException("auth/login", new ApiException(_problemDetailsDtoFixture.Create(title: "General.Failure", detail: "InvalidUsernameOrPassword"), HttpStatusCode.Forbidden, "auth/login"));
HttpClient client = WebTestHelpers.CreateAnonymousClient(_apiFactory);
string antiforgeryToken = await WebTestHelpers.GetAntiforgeryTokenAsync(client);
- HttpRequestMessage loginRequest = CreateLoginRequest(new LoginRequest(Username: "testuser", Password: "WrongPass123!"), antiforgeryToken);
+ HttpRequestMessage loginRequest = CreateLoginRequest(_loginRequestFixture.Create(username: "testuser", password: "WrongPass123!"), antiforgeryToken);
// Act
HttpResponseMessage response = await client.SendAsync(loginRequest);
@@ -109,6 +107,12 @@ public class LoginEndpointTests : IClassFixture
Assert.Contains("", json.RootElement.GetProperty("errorMessage").GetString());
}
+ ///
+ /// Builds the login request that sends the given to the login endpoint.
+ ///
+ /// The login request to send.
+ /// The antiforgery token to include in the request.
+ /// The configured login request.
private static HttpRequestMessage CreateLoginRequest(LoginRequest request, string antiforgeryToken)
{
HttpRequestMessage loginRequest = new(HttpMethod.Post, "/en-us/auth/api-login")
@@ -121,6 +125,11 @@ public class LoginEndpointTests : IClassFixture
return loginRequest;
}
+ ///
+ /// Builds a JSON element that contains a validation error collection carrying the given .
+ ///
+ /// The error codes to include in the collection.
+ /// The built JSON element.
private static JsonElement CreateErrorsElement(string[] errorCodes)
{
using MemoryStream stream = new();
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/Logout/LogoutEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/Logout/LogoutEndpointTests.cs
new file mode 100644
index 00000000..b0457f9e
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/Logout/LogoutEndpointTests.cs
@@ -0,0 +1,44 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Core.Endpoints.UsersManagement.Authentication.Logout;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.UsersManagement.Authentication.Logout;
+
+///
+/// Contains integration tests for the /{culture}/auth/logout route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class LogoutEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public LogoutEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task Logout_WhenCalledByAuthenticatedUser_ShouldSignOutAndRedirectToLogin()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ AuthenticatedWebClient webClient = await WebTestHelpers.CreateAuthenticatedClientAsync(_apiFactory);
+
+ // Act
+ HttpResponseMessage response = await webClient.Client.GetAsync("/en-us/auth/logout");
+
+ // Assert
+ Assert.Equal(HttpStatusCode.Redirect, response.StatusCode);
+ Assert.Contains("/en-us/auth/login", response.Headers.Location!.ToString());
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/RecoverPassword/RecoverPasswordEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/RecoverPassword/RecoverPasswordEndpointTests.cs
new file mode 100644
index 00000000..dd0909c4
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/RecoverPassword/RecoverPasswordEndpointTests.cs
@@ -0,0 +1,80 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.Requests.UsersManagement;
+using Lumina.Presentation.Web.Common.Responses.UsersManagement;
+using Lumina.Presentation.Web.Core.Endpoints.UsersManagement.Authentication.RecoverPassword;
+using Lumina.Presentation.Web.Fixtures.Common.Requests.UsersManagement;
+using Lumina.Presentation.Web.Fixtures.Common.Responses.UsersManagement;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Net.Http.Json;
+using System.Text.Json;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.UsersManagement.Authentication.RecoverPassword;
+
+///
+/// Contains integration tests for the /{culture}/auth/api-recover-password route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class RecoverPasswordEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly RecoverPasswordRequestFixture _recoverPasswordRequestFixture = new();
+ private readonly RecoverPasswordResponseFixture _recoverPasswordResponseFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public RecoverPasswordEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task RecoverPassword_WhenCalledWithValidData_ShouldResetPassword()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ RecoverPasswordResponse expectedResponse = _recoverPasswordResponseFixture.Create(isPasswordReset: true);
+ _apiFactory.ApiClientStub.RegisterPostResponse("auth/recover-password", expectedResponse);
+ HttpClient client = WebTestHelpers.CreateAnonymousClient(_apiFactory);
+ string antiforgeryToken = await WebTestHelpers.GetAntiforgeryTokenAsync(client);
+ RecoverPasswordRequest request = _recoverPasswordRequestFixture.Create(username: "testuser", totpCode: "123456");
+
+ // Act
+ HttpResponseMessage response = await client.SendAsync(CreateRecoverPasswordRequest(request, antiforgeryToken));
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ using JsonDocument json = JsonDocument.Parse(content);
+ Assert.True(json.RootElement.GetProperty("success").GetBoolean());
+ Assert.True(json.RootElement.GetProperty("data").GetProperty("isPasswordReset").GetBoolean());
+ Assert.Contains(_apiFactory.ApiClientStub.PostRequests, postRequest => postRequest.Endpoint == "auth/recover-password");
+ }
+
+ ///
+ /// Builds the recover password request that sends the given to the recover password endpoint.
+ ///
+ /// The recover password request to send.
+ /// The antiforgery token to include in the request.
+ /// The configured recover password request.
+ private static HttpRequestMessage CreateRecoverPasswordRequest(RecoverPasswordRequest request, string antiforgeryToken)
+ {
+ HttpRequestMessage recoverPasswordRequest = new(HttpMethod.Post, "/en-us/auth/api-recover-password")
+ {
+ Content = JsonContent.Create(request)
+ };
+ recoverPasswordRequest.Content!.Headers.ContentType = new MediaTypeHeaderValue("application/json");
+ recoverPasswordRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+ recoverPasswordRequest.Headers.Add("RequestVerificationToken", antiforgeryToken);
+ return recoverPasswordRequest;
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/RecoverPassword/RecoverPasswordViewEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/RecoverPassword/RecoverPasswordViewEndpointTests.cs
new file mode 100644
index 00000000..be8a1c62
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/RecoverPassword/RecoverPasswordViewEndpointTests.cs
@@ -0,0 +1,46 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Core.Endpoints.UsersManagement.Authentication.RecoverPassword;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.UsersManagement.Authentication.RecoverPassword;
+
+///
+/// Contains integration tests for the /{culture}/auth/recover-password route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class RecoverPasswordViewEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public RecoverPasswordViewEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task RecoverPasswordView_WhenCalled_ShouldRenderRecoverPasswordPage()
+ {
+ // Arrange
+ HttpClient client = WebTestHelpers.CreateAnonymousClient(_apiFactory);
+
+ // Act
+ HttpResponseMessage response = await client.GetAsync("/en-us/auth/recover-password");
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ Assert.Equal("text/html", response.Content.Headers.ContentType!.MediaType);
+ string content = await response.Content.ReadAsStringAsync();
+ Assert.Contains("recover-password-form", content);
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/Register/RegisterEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/Register/RegisterEndpointTests.cs
new file mode 100644
index 00000000..4a23234f
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/Register/RegisterEndpointTests.cs
@@ -0,0 +1,103 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Common.Requests.UsersManagement;
+using Lumina.Presentation.Web.Common.Responses.UsersManagement;
+using Lumina.Presentation.Web.Core.Endpoints.UsersManagement.Authentication.Register;
+using Lumina.Presentation.Web.Fixtures.Common.Requests.UsersManagement;
+using Lumina.Presentation.Web.Fixtures.Common.Responses.UsersManagement;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Net.Http.Json;
+using System.Text.Json;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.UsersManagement.Authentication.Register;
+
+///
+/// Contains integration tests for the /{culture}/auth/api-register route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class RegisterEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+ private readonly RegisterRequestFixture _registerRequestFixture = new();
+ private readonly RegisterResponseFixture _registerResponseFixture = new();
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public RegisterEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task Register_WhenCalledWithValidData_ShouldRegisterAccount()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ RegisterResponse expectedResponse = _registerResponseFixture.Create(username: "newuser");
+ _apiFactory.ApiClientStub.RegisterPostResponse("auth/register", expectedResponse);
+ HttpClient client = WebTestHelpers.CreateAnonymousClient(_apiFactory);
+ string antiforgeryToken = await WebTestHelpers.GetAntiforgeryTokenAsync(client);
+ RegisterRequest request = _registerRequestFixture.Create(username: "newuser", password: "Abcd123$", passwordConfirm: "Abcd123$");
+
+ // Act
+ HttpResponseMessage response = await client.SendAsync(CreateRegisterRequest(request, antiforgeryToken));
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ using JsonDocument json = JsonDocument.Parse(content);
+ Assert.True(json.RootElement.GetProperty("success").GetBoolean());
+ Assert.Equal("newuser", json.RootElement.GetProperty("data").GetProperty("username").GetString());
+ Assert.Contains(_apiFactory.ApiClientStub.PostRequests, postRequest => postRequest.Endpoint == "auth/register");
+ }
+
+ [Fact]
+ public async Task Register_WhenRegistrationTypeIsAdmin_ShouldCallInitializationEndpoint()
+ {
+ // Arrange
+ _apiFactory.ApiClientStub.Reset();
+ RegisterResponse expectedResponse = _registerResponseFixture.Create(username: "admin");
+ _apiFactory.ApiClientStub.RegisterPostResponse("initialization", expectedResponse);
+ HttpClient client = WebTestHelpers.CreateAnonymousClient(_apiFactory);
+ string antiforgeryToken = await WebTestHelpers.GetAntiforgeryTokenAsync(client);
+ RegisterRequest request = _registerRequestFixture.Create(username: "admin", password: "Abcd123$", passwordConfirm: "Abcd123$", registrationType: "Admin");
+
+ // Act
+ HttpResponseMessage response = await client.SendAsync(CreateRegisterRequest(request, antiforgeryToken));
+ string content = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ using JsonDocument json = JsonDocument.Parse(content);
+ Assert.True(json.RootElement.GetProperty("success").GetBoolean());
+ Assert.Contains(_apiFactory.ApiClientStub.PostRequests, postRequest => postRequest.Endpoint == "initialization");
+ }
+
+ ///
+ /// Builds the register request that sends the given to the register endpoint.
+ ///
+ /// The register request to send.
+ /// The antiforgery token to include in the request.
+ /// The configured register request.
+ private static HttpRequestMessage CreateRegisterRequest(RegisterRequest request, string antiforgeryToken)
+ {
+ HttpRequestMessage registerRequest = new(HttpMethod.Post, "/en-us/auth/api-register")
+ {
+ Content = JsonContent.Create(request)
+ };
+ registerRequest.Content!.Headers.ContentType = new MediaTypeHeaderValue("application/json");
+ registerRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
+ registerRequest.Headers.Add("RequestVerificationToken", antiforgeryToken);
+ return registerRequest;
+ }
+}
diff --git a/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/Register/RegisterViewEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/Register/RegisterViewEndpointTests.cs
new file mode 100644
index 00000000..ccc43887
--- /dev/null
+++ b/tests/IntegrationTests/Lumina.Presentation.Web.IntegrationTests/Core/Endpoints/UsersManagement/Authentication/Register/RegisterViewEndpointTests.cs
@@ -0,0 +1,46 @@
+#region ========================================================================= USING =====================================================================================
+using Lumina.Presentation.Web.Core.Endpoints.UsersManagement.Authentication.Register;
+using Lumina.Presentation.Web.Fixtures.Common.TestHelpers;
+using Lumina.Presentation.Web.IntegrationTests.Common.Setup;
+using System.Diagnostics.CodeAnalysis;
+using System.Net;
+using System.Net.Http;
+using System.Threading.Tasks;
+#endregion
+
+namespace Lumina.Presentation.Web.IntegrationTests.Core.Endpoints.UsersManagement.Authentication.Register;
+
+///
+/// Contains integration tests for the /{culture}/auth/register route served by the class.
+///
+[ExcludeFromCodeCoverage]
+public class RegisterViewEndpointTests : IClassFixture
+{
+ private readonly LuminaWebFactory _apiFactory;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Injected Web application factory.
+ public RegisterViewEndpointTests(LuminaWebFactory apiFactory)
+ {
+ _apiFactory = apiFactory;
+ }
+
+ [Fact]
+ public async Task RegisterView_WhenCalled_ShouldRenderRegisterPage()
+ {
+ // Arrange
+ HttpClient client = WebTestHelpers.CreateAnonymousClient(_apiFactory);
+
+ // Act
+ HttpResponseMessage response = await client.GetAsync("/en-us/auth/register");
+
+ // Assert
+ response.EnsureSuccessStatusCode();
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ Assert.Equal("text/html", response.Content.Headers.ContentType!.MediaType);
+ string content = await response.Content.ReadAsStringAsync();
+ Assert.Contains("register-account-form", content);
+ }
+}
diff --git a/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Common/Setup/LuminaApiFactory.cs b/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Common/Setup/LuminaApiFactory.cs
index 19ef44d1..fa24c6f2 100644
--- a/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Common/Setup/LuminaApiFactory.cs
+++ b/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Common/Setup/LuminaApiFactory.cs
@@ -1,9 +1,11 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.Authorization;
-using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
-using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
-using Lumina.Contracts.Requests.Authentication;
+using Lumina.Application.Fixtures.Common.DataAccess.Entities.Authorization;
+using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
+using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
+using Lumina.Application.Fixtures.Common.DataAccess.Entities.UsersManagement;
+using Lumina.Contracts.Fixtures.Core.Requests.Authentication;
using Lumina.Contracts.Responses.Authentication;
using Lumina.DataAccess.Common.Interceptors;
using Lumina.DataAccess.Core.UoW;
@@ -18,7 +20,6 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.IdentityModel.Tokens;
using System.Diagnostics.CodeAnalysis;
-using System.Net.Http;
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text;
@@ -36,10 +37,16 @@ public class LuminaApiFactory : WebApplicationFactory, IDisposable
private readonly SqliteConnection _connection;
private readonly string _sharedInMemoryConnectionString;
private readonly PasswordHashService _hashService = new();
+ private readonly LoginRequestFixture _loginRequestFixture = new();
private readonly JsonSerializerOptions _jsonOptions = new()
{
PropertyNameCaseInsensitive = true
};
+ private readonly UserEntityFixture _userEntityFixture = new();
+ private readonly RoleEntityFixture _roleEntityFixture = new();
+ private readonly UserRoleEntityFixture _userRoleEntityFixture = new();
+ private readonly LibraryEntityFixture _libraryEntityFixture = new();
+ private readonly BookEntityFixture _bookEntityFixture = new();
private const string TEST_ENCRYPTION_KEY = "MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI=";
private const string SHARED_IN_MEMORY_CONNECTION_STRING_PREFIX = "Data Source=lumina-tests-{0};Mode=Memory;Cache=Shared";
@@ -145,43 +152,19 @@ public class LuminaApiFactory : WebApplicationFactory, IDisposable
Guid userId = Guid.NewGuid();
string username = $"testuser_{Guid.NewGuid()}";
- UserEntity user = new()
- {
- Id = userId,
- Username = username,
- Password = _hashService.HashString("TestPass123!"),
- Libraries = [],
- UserPermissions = [],
- UserRole = null,
- CreatedBy = userId,
- CreatedOnUtc = DateTime.UtcNow
- };
+ UserEntity user = _userEntityFixture.Create(id: userId, username: username, password: _hashService.HashString("TestPass123!"));
+ user.TotpSecret = null;
dbContext.Users.Add(user);
await dbContext.SaveChangesAsync();
// seed a dedicated Admin role for this test user, keeping each test isolated in the shared in-memory database
Guid roleId = Guid.NewGuid();
- RoleEntity role = new()
- {
- Id = roleId,
- RoleName = "Admin",
- CreatedBy = userId,
- CreatedOnUtc = DateTime.UtcNow
- };
+ RoleEntity role = _roleEntityFixture.Create(id: roleId, roleName: "Admin", createdBy: userId, createdOnUtc: DateTime.UtcNow);
dbContext.Roles.Add(role);
- dbContext.UserRoles.Add(new UserRoleEntity
- {
- Id = Guid.NewGuid(),
- UserId = userId,
- User = user,
- RoleId = roleId,
- Role = role,
- CreatedBy = userId,
- CreatedOnUtc = DateTime.UtcNow
- });
+ dbContext.UserRoles.Add(_userRoleEntityFixture.Create(userId: userId, user: user, roleId: roleId, role: role));
await dbContext.SaveChangesAsync();
- HttpResponseMessage loginResponse = await client.PostAsJsonAsync("/api/v1/auth/login", new LoginRequest(username, "TestPass123!"));
+ HttpResponseMessage loginResponse = await client.PostAsJsonAsync("/api/v1/auth/login", _loginRequestFixture.Create(username: username, password: "TestPass123!"));
string content = await loginResponse.Content.ReadAsStringAsync();
LoginResponse? loginResult = JsonSerializer.Deserialize(content, _jsonOptions);
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", loginResult!.Token);
@@ -205,21 +188,12 @@ public class LuminaApiFactory : WebApplicationFactory, IDisposable
Guid userId = Guid.NewGuid();
string username = $"testuser_{Guid.NewGuid()}";
- UserEntity user = new()
- {
- Id = userId,
- Username = username,
- Password = _hashService.HashString("TestPass123!"),
- Libraries = [],
- UserPermissions = [],
- UserRole = null,
- CreatedBy = userId,
- CreatedOnUtc = DateTime.UtcNow
- };
+ UserEntity user = _userEntityFixture.Create(id: userId, username: username, password: _hashService.HashString("TestPass123!"));
+ user.TotpSecret = null;
dbContext.Users.Add(user);
await dbContext.SaveChangesAsync();
- HttpResponseMessage loginResponse = await client.PostAsJsonAsync("/api/v1/auth/login", new LoginRequest(username, "TestPass123!"));
+ HttpResponseMessage loginResponse = await client.PostAsJsonAsync("/api/v1/auth/login", _loginRequestFixture.Create(username: username, password: "TestPass123!"));
string content = await loginResponse.Content.ReadAsStringAsync();
LoginResponse? loginResult = JsonSerializer.Deserialize(content, _jsonOptions);
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", loginResult!.Token);
@@ -277,17 +251,7 @@ public class LuminaApiFactory : WebApplicationFactory, IDisposable
{
using IServiceScope scope = Services.CreateScope();
LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService();
- dbContext.Libraries.Add(new LibraryEntity
- {
- Id = libraryId,
- UserId = userId,
- Title = "Test Library",
- LibraryType = LibraryType.EBook,
- ContentLocations = [],
- CreatedBy = userId,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedBy = null
- });
+ dbContext.Libraries.Add(_libraryEntityFixture.Create(id: libraryId, userId: userId, title: "Test Library", libraryType: LibraryType.EBook, contentLocations: []));
await dbContext.SaveChangesAsync();
}
@@ -300,16 +264,7 @@ public class LuminaApiFactory : WebApplicationFactory, IDisposable
{
using IServiceScope scope = Services.CreateScope();
LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService();
- dbContext.Books.Add(new BookEntity
- {
- Id = Guid.NewGuid(),
- LibraryId = libraryId,
- Path = $"/books/{Guid.NewGuid()}.epub",
- Title = title,
- CreatedBy = Guid.NewGuid(),
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedBy = null
- });
+ dbContext.Books.Add(_bookEntityFixture.Create(libraryId: libraryId, title: title, path: $"/books/{Guid.NewGuid()}.epub", includeMetadata: false));
await dbContext.SaveChangesAsync();
}
diff --git a/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Admin/Authorization/Roles/AddRoleEndpointTests.cs b/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Admin/Authorization/Roles/AddRoleEndpointTests.cs
index 6b340d28..0ddf36fb 100644
--- a/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Admin/Authorization/Roles/AddRoleEndpointTests.cs
+++ b/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Admin/Authorization/Roles/AddRoleEndpointTests.cs
@@ -1,19 +1,16 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.Authorization;
+using Lumina.Application.Fixtures.Common.DataAccess.Entities.Authorization;
using Lumina.DataAccess.Core.UoW;
using Lumina.Domain.SharedKernel.Common.Enums.Authorization;
using Lumina.Presentation.Api.SecurityTests.Common.Setup;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
-using System;
using System.Diagnostics.CodeAnalysis;
-using System.Linq;
using System.Net;
-using System.Net.Http;
using System.Text;
using System.Text.Json;
-using System.Threading.Tasks;
#endregion
namespace Lumina.Presentation.Api.SecurityTests.Core.Endpoints.Admin.Authorization.Roles;
@@ -22,7 +19,7 @@ namespace Lumina.Presentation.Api.SecurityTests.Core.Endpoints.Admin.Authorizati
/// Contains security tests for the /auth/roles route.
///
[ExcludeFromCodeCoverage]
-public class AddRoleEndpointTests : IClassFixture, IDisposable
+public class AddRoleEndpointTests : IClassFixture, IAsyncDisposable
{
private readonly HttpClient _client;
private readonly LuminaApiFactory _apiFactory;
@@ -33,6 +30,7 @@ public class AddRoleEndpointTests : IClassFixture, IDisposable
private Guid _adminUserId;
private Guid _seededPermissionId;
private string _createdRoleName = "";
+ private readonly PermissionEntityFixture _permissionEntityFixture = new();
///
/// Initializes a new instance of the class.
@@ -84,13 +82,7 @@ public class AddRoleEndpointTests : IClassFixture, IDisposable
using (IServiceScope seedScope = _apiFactory.Services.CreateScope())
{
LuminaDbContext seedDbContext = seedScope.ServiceProvider.GetRequiredService();
- seedDbContext.Permissions.Add(new PermissionEntity
- {
- Id = _seededPermissionId,
- PermissionName = AuthorizationPermission.CanDeleteUsers,
- CreatedBy = Guid.NewGuid(),
- CreatedOnUtc = DateTime.UtcNow
- });
+ seedDbContext.Permissions.Add(_permissionEntityFixture.Create(id: _seededPermissionId, permissionName: AuthorizationPermission.CanDeleteUsers));
await seedDbContext.SaveChangesAsync();
}
var requestBody = new
@@ -118,7 +110,7 @@ public class AddRoleEndpointTests : IClassFixture, IDisposable
///
/// Disposes API factory resources.
///
- public void Dispose()
+ public async ValueTask DisposeAsync()
{
using IServiceScope scope = _apiFactory.Services.CreateScope();
LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService();
@@ -137,6 +129,6 @@ public class AddRoleEndpointTests : IClassFixture, IDisposable
}
dbContext.SaveChanges();
if (_adminUserId != Guid.Empty)
- _apiFactory.RemoveAdminUserAsync(_adminUserId).GetAwaiter().GetResult();
+ await _apiFactory.RemoveAdminUserAsync(_adminUserId).ConfigureAwait(false);
}
}
diff --git a/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Admin/Authorization/Roles/UpdateRoleEndpointTests.cs b/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Admin/Authorization/Roles/UpdateRoleEndpointTests.cs
index f8ba0048..e0c082fb 100644
--- a/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Admin/Authorization/Roles/UpdateRoleEndpointTests.cs
+++ b/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Admin/Authorization/Roles/UpdateRoleEndpointTests.cs
@@ -1,5 +1,7 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.Authorization;
+using Lumina.Application.Fixtures.Common.DataAccess.Entities.Authorization;
+using Lumina.Contracts.Fixtures.Core.Requests.Authorization;
using Lumina.Contracts.Requests.Authorization;
using Lumina.DataAccess.Core.UoW;
using Lumina.Domain.SharedKernel.Common.Enums.Authorization;
@@ -7,14 +9,10 @@ using Lumina.Presentation.Api.SecurityTests.Common.Setup;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
-using System;
using System.Diagnostics.CodeAnalysis;
-using System.Linq;
using System.Net;
-using System.Net.Http;
using System.Text;
using System.Text.Json;
-using System.Threading.Tasks;
#endregion
namespace Lumina.Presentation.Api.SecurityTests.Core.Endpoints.Admin.Authorization.Roles;
@@ -23,7 +21,7 @@ namespace Lumina.Presentation.Api.SecurityTests.Core.Endpoints.Admin.Authorizati
/// Contains security tests for the /auth/roles route.
///
[ExcludeFromCodeCoverage]
-public class UpdateRoleEndpointTests : IClassFixture, IDisposable
+public class UpdateRoleEndpointTests : IClassFixture, IAsyncDisposable
{
private readonly HttpClient _client;
private readonly LuminaApiFactory _apiFactory;
@@ -34,6 +32,9 @@ public class UpdateRoleEndpointTests : IClassFixture, IDisposa
private Guid _adminUserId;
private Guid _seededPermissionId;
private Guid _seededRoleId;
+ private readonly RoleEntityFixture _roleEntityFixture = new();
+ private readonly PermissionEntityFixture _permissionEntityFixture = new();
+ private readonly UpdateRoleRequestFixture _updateRoleRequestFixture = new();
///
/// Initializes a new instance of the class.
@@ -49,10 +50,10 @@ public class UpdateRoleEndpointTests : IClassFixture, IDisposa
public async Task UpdateRole_WhenUnauthorized_ShouldReturnUnauthorizedResult()
{
// Arrange
- UpdateRoleRequest requestBody = new(
- RoleId: Guid.NewGuid(),
- RoleName: "Editor",
- Permissions: []
+ UpdateRoleRequest requestBody = _updateRoleRequestFixture.Create(
+ roleId: Guid.NewGuid(),
+ roleName: "Editor",
+ permissions: []
);
StringContent content = new(
@@ -88,30 +89,18 @@ public class UpdateRoleEndpointTests : IClassFixture, IDisposa
_adminUserId = await _apiFactory.CreateAndAuthenticateAdminUserAsync(client);
_seededPermissionId = Guid.NewGuid();
_seededRoleId = Guid.NewGuid();
- RoleEntity seededRole = new()
- {
- Id = _seededRoleId,
- RoleName = "ExistingRole",
- CreatedBy = Guid.NewGuid(),
- CreatedOnUtc = DateTime.UtcNow
- };
+ RoleEntity seededRole = _roleEntityFixture.Create(id: _seededRoleId, roleName: "ExistingRole");
using (IServiceScope seedScope = _apiFactory.Services.CreateScope())
{
LuminaDbContext seedDbContext = seedScope.ServiceProvider.GetRequiredService();
- seedDbContext.Permissions.Add(new PermissionEntity
- {
- Id = _seededPermissionId,
- PermissionName = AuthorizationPermission.CanDeleteUsers,
- CreatedBy = Guid.NewGuid(),
- CreatedOnUtc = DateTime.UtcNow
- });
+ seedDbContext.Permissions.Add(_permissionEntityFixture.Create(id: _seededPermissionId, permissionName: AuthorizationPermission.CanDeleteUsers));
seedDbContext.Roles.Add(seededRole);
await seedDbContext.SaveChangesAsync();
}
- UpdateRoleRequest requestBody = new(
- RoleId: seededRole.Id,
- RoleName: maliciousRoleName,
- Permissions: [_seededPermissionId]
+ UpdateRoleRequest requestBody = _updateRoleRequestFixture.Create(
+ roleId: seededRole.Id,
+ roleName: maliciousRoleName,
+ permissions: [_seededPermissionId]
);
StringContent content = new(JsonSerializer.Serialize(requestBody), Encoding.UTF8, "application/json");
@@ -134,7 +123,7 @@ public class UpdateRoleEndpointTests : IClassFixture, IDisposa
///
/// Disposes API factory resources.
///
- public void Dispose()
+ public async ValueTask DisposeAsync()
{
using IServiceScope scope = _apiFactory.Services.CreateScope();
LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService();
@@ -153,6 +142,6 @@ public class UpdateRoleEndpointTests : IClassFixture, IDisposa
}
dbContext.SaveChanges();
if (_adminUserId != Guid.Empty)
- _apiFactory.RemoveAdminUserAsync(_adminUserId).GetAwaiter().GetResult();
+ await _apiFactory.RemoveAdminUserAsync(_adminUserId).ConfigureAwait(false);
}
}
diff --git a/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Library/Management/AddLibrary/AddLibraryEndpointTests.cs b/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Library/Management/AddLibrary/AddLibraryEndpointTests.cs
index 7e607c93..238c06f5 100644
--- a/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Library/Management/AddLibrary/AddLibraryEndpointTests.cs
+++ b/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Library/Management/AddLibrary/AddLibraryEndpointTests.cs
@@ -1,19 +1,16 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
+using Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.Management;
using Lumina.Contracts.Requests.MediaLibrary.Management;
using Lumina.DataAccess.Core.UoW;
using Lumina.Presentation.Api.SecurityTests.Common.Setup;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
-using System;
-using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Net;
-using System.Net.Http;
using System.Net.Http.Json;
using System.Text.Json;
-using System.Threading.Tasks;
#endregion
namespace Lumina.Presentation.Api.SecurityTests.Core.Endpoints.Library.Management.AddLibrary;
@@ -26,6 +23,7 @@ public class AddLibraryEndpointTests : IClassFixture
{
private readonly HttpClient _client;
private readonly LuminaApiFactory _apiFactory;
+ private readonly AddLibraryRequestFixture _addLibraryRequestFixture = new();
private readonly JsonSerializerOptions _jsonOptions = new()
{
PropertyNameCaseInsensitive = true
@@ -45,16 +43,16 @@ public class AddLibraryEndpointTests : IClassFixture
public async Task AddLibrary_WhenUnauthorized_ShouldReturnUnauthorizedResult()
{
// Arrange
- AddLibraryRequest request = new(
- Title: "New Library",
- LibraryType: "EBook",
- ContentLocations: ["C:/Media"],
- CoverImage: null,
- IsEnabled: true,
- IsLocked: false,
- DownloadMetadataFromWeb: true,
- ShouldSaveMetadataInMediaDirectories: false,
- ShouldSkipUnchangedDirectoriesDuringScan: true
+ AddLibraryRequest request = _addLibraryRequestFixture.Create(
+ title: "New Library",
+ libraryType: "EBook",
+ contentLocations: ["C:/Media"],
+ coverImage: null,
+ isEnabled: true,
+ isLocked: false,
+ canDownloadMetadataFromWeb: true,
+ shouldSaveMetadataInMediaDirectories: false,
+ shouldSkipUnchangedDirectoriesDuringScan: true
);
// Act
@@ -82,16 +80,16 @@ public class AddLibraryEndpointTests : IClassFixture
// Arrange
HttpClient client = _apiFactory.CreateClient();
await _apiFactory.CreateAndAuthenticateAdminUserAsync(client);
- AddLibraryRequest request = new(
- Title: maliciousTitle,
- LibraryType: "EBook",
- ContentLocations: ["C:/Media"],
- CoverImage: null,
- IsEnabled: true,
- IsLocked: false,
- DownloadMetadataFromWeb: true,
- ShouldSaveMetadataInMediaDirectories: false,
- ShouldSkipUnchangedDirectoriesDuringScan: true
+ AddLibraryRequest request = _addLibraryRequestFixture.Create(
+ title: maliciousTitle,
+ libraryType: "EBook",
+ contentLocations: ["C:/Media"],
+ coverImage: null,
+ isEnabled: true,
+ isLocked: false,
+ canDownloadMetadataFromWeb: true,
+ shouldSaveMetadataInMediaDirectories: false,
+ shouldSkipUnchangedDirectoriesDuringScan: true
);
// Act
diff --git a/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Library/Management/CancelLibrariesScan/CancelLibrariesScanEndpointTests.cs b/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Library/Management/CancelLibrariesScan/CancelLibrariesScanEndpointTests.cs
index 2a3e476b..1f9ff1fc 100644
--- a/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Library/Management/CancelLibrariesScan/CancelLibrariesScanEndpointTests.cs
+++ b/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Library/Management/CancelLibrariesScan/CancelLibrariesScanEndpointTests.cs
@@ -1,21 +1,18 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
-using Lumina.Contracts.Requests.Authentication;
+using Lumina.Application.Fixtures.Common.DataAccess.Entities.UsersManagement;
+using Lumina.Contracts.Fixtures.Core.Requests.Authentication;
using Lumina.Contracts.Responses.Authentication;
using Lumina.DataAccess.Core.UoW;
using Lumina.Infrastructure.Core.Security;
using Lumina.Presentation.Api.SecurityTests.Common.Setup;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
-using System;
-using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Net;
-using System.Net.Http;
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text.Json;
-using System.Threading.Tasks;
#endregion
namespace Lumina.Presentation.Api.SecurityTests.Core.Endpoints.Library.Management.CancelLibrariesScan;
@@ -33,6 +30,8 @@ public class CancelLibrariesScanEndpointTests : IClassFixture
{
PropertyNameCaseInsensitive = true
};
+ private readonly UserEntityFixture _userEntityFixture = new();
+ private readonly LoginRequestFixture _loginRequestFixture = new();
///
/// Initializes a new instance of the class.
@@ -96,20 +95,12 @@ public class CancelLibrariesScanEndpointTests : IClassFixture
LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService();
Guid userId = Guid.NewGuid();
string username = $"testuser_{Guid.NewGuid()}";
- dbContext.Users.Add(new UserEntity
- {
- Id = userId,
- Username = username,
- Password = _hashService.HashString("TestPass123!"),
- Libraries = [],
- UserPermissions = [],
- UserRole = null,
- CreatedBy = userId,
- CreatedOnUtc = DateTime.UtcNow
- });
+ UserEntity user = _userEntityFixture.Create(id: userId, username: username, password: _hashService.HashString("TestPass123!"));
+ user.TotpSecret = null;
+ dbContext.Users.Add(user);
await dbContext.SaveChangesAsync();
- HttpResponseMessage loginResponse = await client.PostAsJsonAsync("/api/v1/auth/login", new LoginRequest(username, "TestPass123!"));
+ HttpResponseMessage loginResponse = await client.PostAsJsonAsync("/api/v1/auth/login", _loginRequestFixture.Create(username: username, password: "TestPass123!"));
string content = await loginResponse.Content.ReadAsStringAsync();
LoginResponse? loginResult = JsonSerializer.Deserialize(content, _jsonOptions);
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", loginResult!.Token);
diff --git a/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Library/Management/CancelLibraryScan/CancelLibraryScanEndpointTests.cs b/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Library/Management/CancelLibraryScan/CancelLibraryScanEndpointTests.cs
index defa9e3b..bfb988e1 100644
--- a/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Library/Management/CancelLibraryScan/CancelLibraryScanEndpointTests.cs
+++ b/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Library/Management/CancelLibraryScan/CancelLibraryScanEndpointTests.cs
@@ -1,19 +1,14 @@
#region ========================================================================= USING =====================================================================================
-using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
+using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
using Lumina.DataAccess.Core.UoW;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using Lumina.Presentation.Api.SecurityTests.Common.Setup;
using Microsoft.AspNetCore.Http;
-using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
-using System;
-using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Net;
-using System.Net.Http;
using System.Net.Http.Json;
using System.Text.Json;
-using System.Threading.Tasks;
#endregion
namespace Lumina.Presentation.Api.SecurityTests.Core.Endpoints.Library.Management.CancelLibraryScan;
@@ -30,6 +25,7 @@ public class CancelLibraryScanEndpointTests : IClassFixture
{
PropertyNameCaseInsensitive = true
};
+ private readonly LibraryEntityFixture _libraryEntityFixture = new();
///
/// Initializes a new instance of the class.
@@ -101,17 +97,7 @@ public class CancelLibraryScanEndpointTests : IClassFixture
{
using IServiceScope scope = _apiFactory.Services.CreateScope();
LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService();
- dbContext.Libraries.Add(new LibraryEntity
- {
- Id = Guid.NewGuid(),
- UserId = userId,
- Title = "Test Library",
- LibraryType = LibraryType.EBook,
- ContentLocations = [],
- CreatedBy = userId,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedBy = null
- });
+ dbContext.Libraries.Add(_libraryEntityFixture.Create(userId: userId, title: "Test Library", libraryType: LibraryType.EBook, contentLocations: []));
await dbContext.SaveChangesAsync();
}
}
diff --git a/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Library/Management/DeleteLibrary/DeleteLibraryEndpointTests.cs b/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Library/Management/DeleteLibrary/DeleteLibraryEndpointTests.cs
index f950d534..ee2af717 100644
--- a/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Library/Management/DeleteLibrary/DeleteLibraryEndpointTests.cs
+++ b/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Library/Management/DeleteLibrary/DeleteLibraryEndpointTests.cs
@@ -1,19 +1,13 @@
#region ========================================================================= USING =====================================================================================
-using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
+using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
using Lumina.DataAccess.Core.UoW;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using Lumina.Presentation.Api.SecurityTests.Common.Setup;
using Microsoft.AspNetCore.Http;
-using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
-using System;
-using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Net;
-using System.Net.Http;
-using System.Net.Http.Json;
using System.Text.Json;
-using System.Threading.Tasks;
#endregion
namespace Lumina.Presentation.Api.SecurityTests.Core.Endpoints.Library.Management.DeleteLibrary;
@@ -30,6 +24,7 @@ public class DeleteLibraryEndpointTests : IClassFixture
{
PropertyNameCaseInsensitive = true
};
+ private readonly LibraryEntityFixture _libraryEntityFixture = new();
///
/// Initializes a new instance of the class.
@@ -100,17 +95,7 @@ public class DeleteLibraryEndpointTests : IClassFixture
{
using IServiceScope scope = _apiFactory.Services.CreateScope();
LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService();
- dbContext.Libraries.Add(new LibraryEntity
- {
- Id = Guid.NewGuid(),
- UserId = userId,
- Title = "Test Library",
- LibraryType = LibraryType.EBook,
- ContentLocations = [],
- CreatedBy = userId,
- CreatedOnUtc = DateTime.UtcNow,
- UpdatedBy = null
- });
+ dbContext.Libraries.Add(_libraryEntityFixture.Create(userId: userId, title: "Test Library", libraryType: LibraryType.EBook, contentLocations: []));
await dbContext.SaveChangesAsync();
}
}
diff --git a/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Library/Management/GetEnabledLibraries/GetEnabledLibrariesEndpointTests.cs b/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Library/Management/GetEnabledLibraries/GetEnabledLibrariesEndpointTests.cs
index e9e1557e..dd622751 100644
--- a/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Library/Management/GetEnabledLibraries/GetEnabledLibrariesEndpointTests.cs
+++ b/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Library/Management/GetEnabledLibraries/GetEnabledLibrariesEndpointTests.cs
@@ -1,21 +1,18 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
-using Lumina.Contracts.Requests.Authentication;
+using Lumina.Application.Fixtures.Common.DataAccess.Entities.UsersManagement;
+using Lumina.Contracts.Fixtures.Core.Requests.Authentication;
using Lumina.Contracts.Responses.Authentication;
using Lumina.DataAccess.Core.UoW;
using Lumina.Infrastructure.Core.Security;
using Lumina.Presentation.Api.SecurityTests.Common.Setup;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
-using System;
-using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Net;
-using System.Net.Http;
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text.Json;
-using System.Threading.Tasks;
#endregion
namespace Lumina.Presentation.Api.SecurityTests.Core.Endpoints.Library.Management.GetEnabledLibraries;
@@ -33,6 +30,8 @@ public class GetEnabledLibrariesEndpointTests : IClassFixture
{
PropertyNameCaseInsensitive = true
};
+ private readonly UserEntityFixture _userEntityFixture = new();
+ private readonly LoginRequestFixture _loginRequestFixture = new();
///
/// Initializes a new instance of the class.
@@ -97,20 +96,12 @@ public class GetEnabledLibrariesEndpointTests : IClassFixture
LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService();
Guid userId = Guid.NewGuid();
string username = $"testuser_{Guid.NewGuid()}";
- dbContext.Users.Add(new UserEntity
- {
- Id = userId,
- Username = username,
- Password = _hashService.HashString("TestPass123!"),
- Libraries = [],
- UserPermissions = [],
- UserRole = null,
- CreatedBy = userId,
- CreatedOnUtc = DateTime.UtcNow
- });
+ UserEntity user = _userEntityFixture.Create(id: userId, username: username, password: _hashService.HashString("TestPass123!"));
+ user.TotpSecret = null;
+ dbContext.Users.Add(user);
await dbContext.SaveChangesAsync();
- HttpResponseMessage loginResponse = await client.PostAsJsonAsync("/api/v1/auth/login", new LoginRequest(username, "TestPass123!"));
+ HttpResponseMessage loginResponse = await client.PostAsJsonAsync("/api/v1/auth/login", _loginRequestFixture.Create(username: username, password: "TestPass123!"));
string content = await loginResponse.Content.ReadAsStringAsync();
LoginResponse? loginResult = JsonSerializer.Deserialize(content, _jsonOptions);
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", loginResult!.Token);
diff --git a/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Library/Management/GetLibraries/GetLibrariesEndpointTests.cs b/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Library/Management/GetLibraries/GetLibrariesEndpointTests.cs
index e642ca58..c433756b 100644
--- a/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Library/Management/GetLibraries/GetLibrariesEndpointTests.cs
+++ b/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Library/Management/GetLibraries/GetLibrariesEndpointTests.cs
@@ -1,21 +1,18 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
-using Lumina.Contracts.Requests.Authentication;
+using Lumina.Application.Fixtures.Common.DataAccess.Entities.UsersManagement;
+using Lumina.Contracts.Fixtures.Core.Requests.Authentication;
using Lumina.Contracts.Responses.Authentication;
using Lumina.DataAccess.Core.UoW;
using Lumina.Infrastructure.Core.Security;
using Lumina.Presentation.Api.SecurityTests.Common.Setup;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
-using System;
-using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Net;
-using System.Net.Http;
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text.Json;
-using System.Threading.Tasks;
#endregion
namespace Lumina.Presentation.Api.SecurityTests.Core.Endpoints.Library.Management.GetLibraries;
@@ -33,6 +30,8 @@ public class GetLibrariesEndpointTests : IClassFixture
{
PropertyNameCaseInsensitive = true
};
+ private readonly UserEntityFixture _userEntityFixture = new();
+ private readonly LoginRequestFixture _loginRequestFixture = new();
///
/// Initializes a new instance of the class.
@@ -97,20 +96,12 @@ public class GetLibrariesEndpointTests : IClassFixture
LuminaDbContext dbContext = scope.ServiceProvider.GetRequiredService();
Guid userId = Guid.NewGuid();
string username = $"testuser_{Guid.NewGuid()}";
- dbContext.Users.Add(new UserEntity
- {
- Id = userId,
- Username = username,
- Password = _hashService.HashString("TestPass123!"),
- Libraries = [],
- UserPermissions = [],
- UserRole = null,
- CreatedBy = userId,
- CreatedOnUtc = DateTime.UtcNow
- });
+ UserEntity user = _userEntityFixture.Create(id: userId, username: username, password: _hashService.HashString("TestPass123!"));
+ user.TotpSecret = null;
+ dbContext.Users.Add(user);
await dbContext.SaveChangesAsync();
- HttpResponseMessage loginResponse = await client.PostAsJsonAsync("/api/v1/auth/login", new LoginRequest(username, "TestPass123!"));
+ HttpResponseMessage loginResponse = await client.PostAsJsonAsync("/api/v1/auth/login", _loginRequestFixture.Create(username: username, password: "TestPass123!"));
string content = await loginResponse.Content.ReadAsStringAsync();
LoginResponse? loginResult = JsonSerializer.Deserialize(content, _jsonOptions);
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", loginResult!.Token);
diff --git a/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Library/Management/GetLibrary/GetLibraryEndpointTests.cs b/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Library/Management/GetLibrary/GetLibraryEndpointTests.cs
index 8b3347ed..d9dc96f4 100644
--- a/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Library/Management/GetLibrary/GetLibraryEndpointTests.cs
+++ b/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Library/Management/GetLibrary/GetLibraryEndpointTests.cs
@@ -1,24 +1,20 @@
#region ========================================================================= USING =====================================================================================
-using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
-using Lumina.Contracts.Requests.Authentication;
+using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
+using Lumina.Application.Fixtures.Common.DataAccess.Entities.UsersManagement;
+using Lumina.Contracts.Fixtures.Core.Requests.Authentication;
using Lumina.Contracts.Responses.Authentication;
using Lumina.DataAccess.Core.UoW;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using Lumina.Infrastructure.Core.Security;
using Lumina.Presentation.Api.SecurityTests.Common.Setup;
using Microsoft.AspNetCore.Http;
-using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
-using System;
-using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Net;
-using System.Net.Http;
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text.Json;
-using System.Threading.Tasks;
#endregion
namespace Lumina.Presentation.Api.SecurityTests.Core.Endpoints.Library.Management.GetLibrary;
@@ -36,6 +32,9 @@ public class GetLibraryEndpointTests : IClassFixture
{
PropertyNameCaseInsensitive = true
};
+ private readonly LibraryEntityFixture _libraryEntityFixture = new();
+ private readonly UserEntityFixture _userEntityFixture = new();
+ private readonly LoginRequestFixture _loginRequestFixture = new();
///
/// Initializes a new instance of the