mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 12:11:10 +00:00
Refactors the test fixtures and their consumers to compose other fixtures instead of instantiating models inline
This commit is contained in:
1 parent
0abda472c6
commit
3aadd6de84
157 files changed
+1312
-597
No files matched your search
+9
-6
@@ -1,5 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.DTO.Common.Pagination;
|
||||
using Lumina.Contracts.Fixtures.Core.DTO.Common.Pagination;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
@@ -11,11 +12,13 @@ namespace Lumina.Contracts.UnitTests.DTO.Common.Pagination;
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PaginationDataDtoTests
|
||||
{
|
||||
private readonly PaginationDataDtoFixture _paginationDataDtoFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void CurrentPage_WhenNotSet_ShouldDefaultToOne()
|
||||
{
|
||||
// Arrange
|
||||
PaginationDataDto sut = new();
|
||||
PaginationDataDto sut = _paginationDataDtoFixture.Create(includeCurrentPage: false, includePerPage: false);
|
||||
|
||||
// Act
|
||||
int currentPage = sut.CurrentPage;
|
||||
@@ -28,7 +31,7 @@ public class PaginationDataDtoTests
|
||||
public void PerPage_WhenNotSet_ShouldDefaultToTwoHundred()
|
||||
{
|
||||
// Arrange
|
||||
PaginationDataDto sut = new();
|
||||
PaginationDataDto sut = _paginationDataDtoFixture.Create(includeCurrentPage: false, includePerPage: false);
|
||||
|
||||
// Act
|
||||
int perPage = sut.PerPage;
|
||||
@@ -43,7 +46,7 @@ public class PaginationDataDtoTests
|
||||
public void CurrentPage_WhenSettingValueBelowOne_ShouldClampToOne(int value)
|
||||
{
|
||||
// Arrange
|
||||
PaginationDataDto sut = new();
|
||||
PaginationDataDto sut = _paginationDataDtoFixture.Create(includeCurrentPage: false, includePerPage: false);
|
||||
|
||||
// Act
|
||||
sut.CurrentPage = value;
|
||||
@@ -58,7 +61,7 @@ public class PaginationDataDtoTests
|
||||
public void PerPage_WhenSettingValueBelowOne_ShouldClampToOne(int value)
|
||||
{
|
||||
// Arrange
|
||||
PaginationDataDto sut = new();
|
||||
PaginationDataDto sut = _paginationDataDtoFixture.Create(includeCurrentPage: false, includePerPage: false);
|
||||
|
||||
// Act
|
||||
sut.PerPage = value;
|
||||
@@ -71,7 +74,7 @@ public class PaginationDataDtoTests
|
||||
public void CurrentPage_WhenSettingValueAboveOne_ShouldPreserveValue()
|
||||
{
|
||||
// Arrange
|
||||
PaginationDataDto sut = new();
|
||||
PaginationDataDto sut = _paginationDataDtoFixture.Create(includeCurrentPage: false, includePerPage: false);
|
||||
|
||||
// Act
|
||||
sut.CurrentPage = 5;
|
||||
@@ -84,7 +87,7 @@ public class PaginationDataDtoTests
|
||||
public void PerPage_WhenSettingValueAboveOne_ShouldPreserveValue()
|
||||
{
|
||||
// Arrange
|
||||
PaginationDataDto sut = new();
|
||||
PaginationDataDto sut = _paginationDataDtoFixture.Create(includeCurrentPage: false, includePerPage: false);
|
||||
|
||||
// Act
|
||||
sut.PerPage = 25;
|
||||
|
||||
+4
-1
@@ -2,6 +2,7 @@
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using Lumina.Contracts.DTO.MediaContributors;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.BookLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -16,6 +17,8 @@ namespace Lumina.Contracts.UnitTests.DTO.MediaLibrary.WrittenContentLibrary.Book
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class BookMetadataLookupDtoTests
|
||||
{
|
||||
private readonly BookMetadataLookupDtoFixture _bookMetadataLookupDtoFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void Constructor_WhenOmittingOptionalParameters_ShouldUseNullDefaults()
|
||||
{
|
||||
@@ -23,7 +26,7 @@ public class BookMetadataLookupDtoTests
|
||||
Guid libraryId = Guid.NewGuid();
|
||||
|
||||
// Act
|
||||
BookMetadataLookupDto sut = new(libraryId, @"/media/books/dune.epub");
|
||||
BookMetadataLookupDto sut = _bookMetadataLookupDtoFixture.Create(libraryId: libraryId, path: @"/media/books/dune.epub");
|
||||
|
||||
// Assert
|
||||
Assert.Equal(libraryId, sut.LibraryId);
|
||||
|
||||
+4
-1
@@ -1,4 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.Authentication;
|
||||
using Lumina.Contracts.Requests.Authentication;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
@@ -11,11 +12,13 @@ namespace Lumina.Contracts.UnitTests.Requests.Authentication;
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class RegistrationRequestTests
|
||||
{
|
||||
private readonly RegistrationRequestFixture _registrationRequestFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void Constructor_WhenOmittingUse2fa_ShouldDefaultToTrue()
|
||||
{
|
||||
// Act
|
||||
RegistrationRequest sut = new(Username: "user1", Password: "pass1", PasswordConfirm: "pass1");
|
||||
RegistrationRequest sut = _registrationRequestFixture.Create(username: "user1", password: "pass1", passwordConfirm: "pass1", use2fa: true);
|
||||
|
||||
// Assert
|
||||
Assert.True(sut.Use2fa);
|
||||
|
||||
+4
-1
@@ -1,4 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.Authorization;
|
||||
using Lumina.Contracts.Requests.Authorization;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
@@ -11,11 +12,13 @@ namespace Lumina.Contracts.UnitTests.Requests.Authorization;
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AddRoleRequestTests
|
||||
{
|
||||
private readonly AddRoleRequestFixture _addRoleRequestFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void Constructor_WhenPassingNullPermissions_ShouldReturnNullPermissions()
|
||||
{
|
||||
// Act
|
||||
AddRoleRequest sut = new(RoleName: "Admin", Permissions: null);
|
||||
AddRoleRequest sut = _addRoleRequestFixture.Create(roleName: "Admin", includePermissions: false);
|
||||
|
||||
// Assert
|
||||
Assert.Null(sut.Permissions);
|
||||
|
||||
+4
-1
@@ -1,4 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.Authorization;
|
||||
using Lumina.Contracts.Requests.Authorization;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
@@ -11,11 +12,13 @@ namespace Lumina.Contracts.UnitTests.Requests.Authorization;
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class DeleteRoleRequestTests
|
||||
{
|
||||
private readonly DeleteRoleRequestFixture _deleteRoleRequestFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void Constructor_WhenPassingNullRoleId_ShouldReturnNullRoleId()
|
||||
{
|
||||
// Act
|
||||
DeleteRoleRequest sut = new(RoleId: null);
|
||||
DeleteRoleRequest sut = _deleteRoleRequestFixture.Create(includeRoleId: false);
|
||||
|
||||
// Assert
|
||||
Assert.Null(sut.RoleId);
|
||||
|
||||
+4
-1
@@ -1,4 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.Authorization;
|
||||
using Lumina.Contracts.Requests.Authorization;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
@@ -11,11 +12,13 @@ namespace Lumina.Contracts.UnitTests.Requests.Authorization;
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetAuthorizationRequestTests
|
||||
{
|
||||
private readonly GetAuthorizationRequestFixture _getAuthorizationRequestFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void Constructor_WhenPassingNullUserId_ShouldReturnNullUserId()
|
||||
{
|
||||
// Act
|
||||
GetAuthorizationRequest sut = new(UserId: null);
|
||||
GetAuthorizationRequest sut = _getAuthorizationRequestFixture.Create(includeUserId: false);
|
||||
|
||||
// Assert
|
||||
Assert.Null(sut.UserId);
|
||||
|
||||
+4
-1
@@ -1,4 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.Authorization;
|
||||
using Lumina.Contracts.Requests.Authorization;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
@@ -11,11 +12,13 @@ namespace Lumina.Contracts.UnitTests.Requests.Authorization;
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetUserPermissionsRequestTests
|
||||
{
|
||||
private readonly GetUserPermissionsRequestFixture _getUserPermissionsRequestFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void Constructor_WhenPassingNullUserId_ShouldReturnNullUserId()
|
||||
{
|
||||
// Act
|
||||
GetUserPermissionsRequest sut = new(UserId: null);
|
||||
GetUserPermissionsRequest sut = _getUserPermissionsRequestFixture.Create(includeUserId: false);
|
||||
|
||||
// Assert
|
||||
Assert.Null(sut.UserId);
|
||||
|
||||
+4
-1
@@ -1,4 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.Authorization;
|
||||
using Lumina.Contracts.Requests.Authorization;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
@@ -11,11 +12,13 @@ namespace Lumina.Contracts.UnitTests.Requests.Authorization;
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetUserRoleRequestTests
|
||||
{
|
||||
private readonly GetUserRoleRequestFixture _getUserRoleRequestFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void Constructor_WhenPassingNullUserId_ShouldReturnNullUserId()
|
||||
{
|
||||
// Act
|
||||
GetUserRoleRequest sut = new(UserId: null);
|
||||
GetUserRoleRequest sut = _getUserRoleRequestFixture.Create(includeUserId: false);
|
||||
|
||||
// Assert
|
||||
Assert.Null(sut.UserId);
|
||||
|
||||
+4
-1
@@ -1,4 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.Fixtures.Core.Responses.FileSystemManagement.Common;
|
||||
using Lumina.Contracts.Responses.FileSystemManagement.Common;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
@@ -11,11 +12,13 @@ namespace Lumina.Contracts.UnitTests.Responses.FileSystemManagement.Common;
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class FileSystemTreeNodeResponseTests
|
||||
{
|
||||
private readonly FileSystemTreeNodeResponseFixture _fileSystemTreeNodeResponseFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void Constructor_WhenInstantiatingNode_ShouldInitializeEmptyChildren()
|
||||
{
|
||||
// Act
|
||||
FileSystemTreeNodeResponse sut = new();
|
||||
FileSystemTreeNodeResponse sut = _fileSystemTreeNodeResponseFixture.Create(maxDepth: 0);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(sut.Children);
|
||||
|
||||
Reference in new issue
Block a user