Replaces FluentValidation and Mediator command/queries handling with custom implementations.

This commit is contained in:
BinaryAlley committed 2026-08-13 08:53:06 -07:00
1 parent 9a5c7473f9
commit 2d1c6b1ab8
297 files changed
+3619 -3045

No files matched your search

@@ -6,6 +6,7 @@ using Lumina.Application.Core.FileSystemManagement.Paths.Commands.CombinePath;
using Lumina.Application.UnitTests.Core.FileSystemManagement.Pahs.Commands.CombinePath.Fixtures;
using Lumina.Contracts.Responses.FileSystemManagement.Path;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
using Lumina.Application.Common.Infrastructure.Validation;
using NSubstitute;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
@@ -31,7 +32,10 @@ public class CombinePathCommandHandlerTests
{
_fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
_mockPathService = Substitute.For<IPathService>();
_sut = new CombinePathCommandHandler(_mockPathService);
IValidator<CombinePathCommand> mockValidator = Substitute.For<IValidator<CombinePathCommand>>();
mockValidator.Validate(Arg.Any<CombinePathCommand>())
.Returns([]);
_sut = new CombinePathCommandHandler(_mockPathService, mockValidator);
}
[Fact]
@@ -45,7 +49,7 @@ public class CombinePathCommandHandlerTests
.Returns(ErrorOrFactory.From(combinedPath));
// Act
ErrorOr<PathSegmentResponse> result = await _sut.Handle(combinePathCommand, CancellationToken.None);
ErrorOr<PathSegmentResponse> result = await _sut.HandleAsync(combinePathCommand, CancellationToken.None);
// Assert
Assert.False(result.IsError);
@@ -64,7 +68,7 @@ public class CombinePathCommandHandlerTests
.Returns(error);
// Act
ErrorOr<PathSegmentResponse> result = await _sut.Handle(command, CancellationToken.None);
ErrorOr<PathSegmentResponse> result = await _sut.HandleAsync(command, CancellationToken.None);
// Assert
Assert.True(result.IsError);
@@ -81,7 +85,7 @@ public class CombinePathCommandHandlerTests
.Returns(ErrorOrFactory.From(string.Empty));
// Act
ErrorOr<PathSegmentResponse> result = await _sut.Handle(command, CancellationToken.None);
ErrorOr<PathSegmentResponse> result = await _sut.HandleAsync(command, CancellationToken.None);
// Assert
Assert.False(result.IsError);
@@ -1,8 +1,10 @@
#region ========================================================================= USING =====================================================================================
using FluentValidation.TestHelper;
using ErrorOr;
using Lumina.Application.Core.FileSystemManagement.Paths.Commands.CombinePath;
using Lumina.Application.UnitTests.Common.Setup;
using Lumina.Application.UnitTests.Core.FileSystemManagement.Pahs.Commands.CombinePath.Fixtures;
using Lumina.Domain.SharedKernel.Common.Errors;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
#endregion
@@ -32,11 +34,10 @@ public class CombinePathCommandValidatorTests
command = command with { OriginalPath = null! };
// Act
TestValidationResult<CombinePathCommand> result = _validator.TestValidate(command);
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldHaveValidationErrorFor(x => x.OriginalPath)
.WithErrorMessage(Errors.FileSystemManagement.PathCannotBeEmpty.Description);
result.ShouldHaveValidationError(Errors.FileSystemManagement.PathCannotBeEmpty);
}
[Fact]
@@ -47,11 +48,10 @@ public class CombinePathCommandValidatorTests
command = command with { OriginalPath = string.Empty };
// Act
TestValidationResult<CombinePathCommand> result = _validator.TestValidate(command);
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldHaveValidationErrorFor(x => x.OriginalPath)
.WithErrorMessage(Errors.FileSystemManagement.PathCannotBeEmpty.Description);
result.ShouldHaveValidationError(Errors.FileSystemManagement.PathCannotBeEmpty);
}
[Fact]
@@ -62,11 +62,10 @@ public class CombinePathCommandValidatorTests
command = command with { OriginalPath = " " };
// Act
TestValidationResult<CombinePathCommand> result = _validator.TestValidate(command);
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldHaveValidationErrorFor(x => x.OriginalPath)
.WithErrorMessage(Errors.FileSystemManagement.PathCannotBeEmpty.Description);
result.ShouldHaveValidationError(Errors.FileSystemManagement.PathCannotBeEmpty);
}
[Fact]
@@ -77,11 +76,10 @@ public class CombinePathCommandValidatorTests
command = command with { NewPath = null! };
// Act
TestValidationResult<CombinePathCommand> result = _validator.TestValidate(command);
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldHaveValidationErrorFor(x => x.NewPath)
.WithErrorMessage(Errors.FileSystemManagement.PathCannotBeEmpty.Description);
result.ShouldHaveValidationError(Errors.FileSystemManagement.PathCannotBeEmpty);
}
[Fact]
@@ -92,11 +90,10 @@ public class CombinePathCommandValidatorTests
command = command with { NewPath = string.Empty };
// Act
TestValidationResult<CombinePathCommand> result = _validator.TestValidate(command);
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldHaveValidationErrorFor(x => x.NewPath)
.WithErrorMessage(Errors.FileSystemManagement.PathCannotBeEmpty.Description);
result.ShouldHaveValidationError(Errors.FileSystemManagement.PathCannotBeEmpty);
}
[Fact]
@@ -107,11 +104,10 @@ public class CombinePathCommandValidatorTests
command = command with { NewPath = " " };
// Act
TestValidationResult<CombinePathCommand> result = _validator.TestValidate(command);
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldHaveValidationErrorFor(x => x.NewPath)
.WithErrorMessage(Errors.FileSystemManagement.PathCannotBeEmpty.Description);
result.ShouldHaveValidationError(Errors.FileSystemManagement.PathCannotBeEmpty);
}
[Fact]
@@ -122,10 +118,10 @@ public class CombinePathCommandValidatorTests
command = command with { OriginalPath = "/valid/path", NewPath = "new/segment" };
// Act
TestValidationResult<CombinePathCommand> result = _validator.TestValidate(command);
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldNotHaveValidationErrorFor(x => x.OriginalPath);
result.ShouldNotHaveValidationErrorFor(x => x.NewPath);
result.ShouldNotHaveValidationError(Errors.FileSystemManagement.PathCannotBeEmpty);
result.ShouldNotHaveValidationError(Errors.FileSystemManagement.PathCannotBeEmpty);
}
}
@@ -8,6 +8,7 @@ using Lumina.Application.UnitTests.Core.FileSystemManagement.Pahs.Fixtures;
using Lumina.Contracts.Responses.FileSystemManagement.Path;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
using Lumina.Application.Common.Infrastructure.Validation;
using NSubstitute;
using System;
using System.Collections.Generic;
@@ -37,7 +38,10 @@ public class SplitPathCommandHandlerTests
{
_fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
_mockPathService = Substitute.For<IPathService>();
_sut = new SplitPathCommandHandler(_mockPathService);
IValidator<SplitPathCommand> mockValidator = Substitute.For<IValidator<SplitPathCommand>>();
mockValidator.Validate(Arg.Any<SplitPathCommand>())
.Returns([]);
_sut = new SplitPathCommandHandler(_mockPathService, mockValidator);
_pathSegmentFixture = new PathSegmentFixture();
}
@@ -53,7 +57,7 @@ public class SplitPathCommandHandlerTests
.Returns(ErrorOrFactory.From(pathSegments));
// Act
ErrorOr<IEnumerable<PathSegmentResponse>> result = await _sut.Handle(splitPathCommand, CancellationToken.None);
ErrorOr<IEnumerable<PathSegmentResponse>> result = await _sut.HandleAsync(splitPathCommand, CancellationToken.None);
// Assert
Assert.False(result.IsError);
@@ -78,7 +82,7 @@ public class SplitPathCommandHandlerTests
.Returns(error);
// Act
ErrorOr<IEnumerable<PathSegmentResponse>> result = await _sut.Handle(command, CancellationToken.None);
ErrorOr<IEnumerable<PathSegmentResponse>> result = await _sut.HandleAsync(command, CancellationToken.None);
// Assert
Assert.True(result.IsError);
@@ -96,7 +100,7 @@ public class SplitPathCommandHandlerTests
.Returns(emptyList);
// Act
ErrorOr<IEnumerable<PathSegmentResponse>> result = await _sut.Handle(command, CancellationToken.None);
ErrorOr<IEnumerable<PathSegmentResponse>> result = await _sut.HandleAsync(command, CancellationToken.None);
// Assert
Assert.False(result.IsError);
@@ -1,8 +1,10 @@
#region ========================================================================= USING =====================================================================================
using FluentValidation.TestHelper;
using ErrorOr;
using Lumina.Application.Core.FileSystemManagement.Paths.Commands.SplitPath;
using Lumina.Application.UnitTests.Common.Setup;
using Lumina.Application.UnitTests.Core.FileSystemManagement.Pahs.Commands.SplitPath.Fixtures;
using Lumina.Domain.SharedKernel.Common.Errors;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
#endregion
@@ -32,11 +34,10 @@ public class SplitPathCommandValidatorTests
command = command with { Path = null! };
// Act
TestValidationResult<SplitPathCommand> result = _validator.TestValidate(command);
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldHaveValidationErrorFor(x => x.Path)
.WithErrorMessage(Errors.FileSystemManagement.PathCannotBeEmpty.Description);
result.ShouldHaveValidationError(Errors.FileSystemManagement.PathCannotBeEmpty);
}
[Fact]
@@ -47,11 +48,10 @@ public class SplitPathCommandValidatorTests
command = command with { Path = string.Empty };
// Act
TestValidationResult<SplitPathCommand> result = _validator.TestValidate(command);
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldHaveValidationErrorFor(x => x.Path)
.WithErrorMessage(Errors.FileSystemManagement.PathCannotBeEmpty.Description);
result.ShouldHaveValidationError(Errors.FileSystemManagement.PathCannotBeEmpty);
}
[Fact]
@@ -62,11 +62,10 @@ public class SplitPathCommandValidatorTests
command = command with { Path = " " };
// Act
TestValidationResult<SplitPathCommand> result = _validator.TestValidate(command);
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldHaveValidationErrorFor(x => x.Path)
.WithErrorMessage(Errors.FileSystemManagement.PathCannotBeEmpty.Description);
result.ShouldHaveValidationError(Errors.FileSystemManagement.PathCannotBeEmpty);
}
[Fact]
@@ -77,9 +76,9 @@ public class SplitPathCommandValidatorTests
command = command with { Path = "/valid/path" };
// Act
TestValidationResult<SplitPathCommand> result = _validator.TestValidate(command);
List<Error> result = _validator.TestValidate(command);
// Assert
result.ShouldNotHaveValidationErrorFor(x => x.Path);
result.ShouldNotHaveValidationError(Errors.FileSystemManagement.PathCannotBeEmpty);
}
}
@@ -4,6 +4,7 @@ using Lumina.Application.Core.FileSystemManagement.Paths.Queries.CheckPathExists
using Lumina.Application.UnitTests.Core.FileSystemManagement.Pahs.Queries.CheckPathExists.Fixtures;
using Lumina.Contracts.Responses.FileSystemManagement.Path;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
using Lumina.Application.Common.Infrastructure.Validation;
using NSubstitute;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
@@ -27,7 +28,10 @@ public class CheckPathExistsQueryHandlerTests
public CheckPathExistsQueryHandlerTests()
{
_mockPathService = Substitute.For<IPathService>();
_sut = new CheckPathExistsQueryHandler(_mockPathService);
IValidator<CheckPathExistsQuery> mockValidator = Substitute.For<IValidator<CheckPathExistsQuery>>();
mockValidator.Validate(Arg.Any<CheckPathExistsQuery>())
.Returns([]);
_sut = new CheckPathExistsQueryHandler(_mockPathService, mockValidator);
}
[Fact]
@@ -38,7 +42,7 @@ public class CheckPathExistsQueryHandlerTests
_mockPathService.Exists(query.Path!).Returns(true);
// Act
ErrorOr<PathExistsResponse> result = await _sut.Handle(query, CancellationToken.None);
ErrorOr<PathExistsResponse> result = await _sut.HandleAsync(query, CancellationToken.None);
// Assert
Assert.False(result.IsError);
@@ -54,7 +58,7 @@ public class CheckPathExistsQueryHandlerTests
_mockPathService.Exists(query.Path!).Returns(true);
// Act
ErrorOr<PathExistsResponse> result = await _sut.Handle(query, CancellationToken.None);
ErrorOr<PathExistsResponse> result = await _sut.HandleAsync(query, CancellationToken.None);
// Assert
Assert.False(result.IsError);
@@ -70,7 +74,7 @@ public class CheckPathExistsQueryHandlerTests
_mockPathService.Exists(query.Path!, false).Returns(false);
// Act
ErrorOr<PathExistsResponse> result = await _sut.Handle(query, CancellationToken.None);
ErrorOr<PathExistsResponse> result = await _sut.HandleAsync(query, CancellationToken.None);
// Assert
Assert.False(result.IsError);
@@ -86,7 +90,7 @@ public class CheckPathExistsQueryHandlerTests
_mockPathService.Exists(query.Path!).Returns(false);
// Act
ErrorOr<PathExistsResponse> result = await _sut.Handle(query, CancellationToken.None);
ErrorOr<PathExistsResponse> result = await _sut.HandleAsync(query, CancellationToken.None);
// Assert
Assert.False(result.IsError);
@@ -102,7 +106,7 @@ public class CheckPathExistsQueryHandlerTests
_mockPathService.Exists(Arg.Any<string>(), Arg.Any<bool>()).Returns(false);
// Act
ErrorOr<PathExistsResponse> result = await _sut.Handle(query, CancellationToken.None);
ErrorOr<PathExistsResponse> result = await _sut.HandleAsync(query, CancellationToken.None);
// Assert
Assert.False(result.IsError);
@@ -119,7 +123,7 @@ public class CheckPathExistsQueryHandlerTests
CancellationToken cancellationToken = new(true);
// Act
ErrorOr<PathExistsResponse> result = await _sut.Handle(query, CancellationToken.None);
ErrorOr<PathExistsResponse> result = await _sut.HandleAsync(query, CancellationToken.None);
// Assert
Assert.False(result.IsError);
@@ -1,8 +1,10 @@
#region ========================================================================= USING =====================================================================================
using FluentValidation.TestHelper;
using ErrorOr;
using Lumina.Application.Core.FileSystemManagement.Paths.Queries.CheckPathExists;
using Lumina.Application.UnitTests.Common.Setup;
using Lumina.Application.UnitTests.Core.FileSystemManagement.Pahs.Queries.CheckPathExists.Fixtures;
using Lumina.Domain.SharedKernel.Common.Errors;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
#endregion
@@ -32,11 +34,10 @@ public class CheckPathExistsQueryValidatorTests
query = query with { Path = null! };
// Act
TestValidationResult<CheckPathExistsQuery> result = _validator.TestValidate(query);
List<Error> result = _validator.TestValidate(query);
// Assert
result.ShouldHaveValidationErrorFor(x => x.Path)
.WithErrorMessage(Errors.FileSystemManagement.PathCannotBeEmpty.Description);
result.ShouldHaveValidationError(Errors.FileSystemManagement.PathCannotBeEmpty);
}
[Fact]
@@ -47,11 +48,10 @@ public class CheckPathExistsQueryValidatorTests
query = query with { Path = string.Empty };
// Act
TestValidationResult<CheckPathExistsQuery> result = _validator.TestValidate(query);
List<Error> result = _validator.TestValidate(query);
// Assert
result.ShouldHaveValidationErrorFor(x => x.Path)
.WithErrorMessage(Errors.FileSystemManagement.PathCannotBeEmpty.Description);
result.ShouldHaveValidationError(Errors.FileSystemManagement.PathCannotBeEmpty);
}
[Fact]
@@ -62,11 +62,10 @@ public class CheckPathExistsQueryValidatorTests
query = query with { Path = " " };
// Act
TestValidationResult<CheckPathExistsQuery> result = _validator.TestValidate(query);
List<Error> result = _validator.TestValidate(query);
// Assert
result.ShouldHaveValidationErrorFor(x => x.Path)
.WithErrorMessage(Errors.FileSystemManagement.PathCannotBeEmpty.Description);
result.ShouldHaveValidationError(Errors.FileSystemManagement.PathCannotBeEmpty);
}
[Fact]
@@ -77,9 +76,9 @@ public class CheckPathExistsQueryValidatorTests
query = query with { Path = "/valid/path" };
// Act
TestValidationResult<CheckPathExistsQuery> result = _validator.TestValidate(query);
List<Error> result = _validator.TestValidate(query);
// Assert
result.ShouldNotHaveValidationErrorFor(x => x.Path);
result.ShouldNotHaveValidationError(Errors.FileSystemManagement.PathCannotBeEmpty);
}
}
@@ -8,6 +8,7 @@ using Lumina.Application.UnitTests.Core.FileSystemManagement.Pahs.Queries.GetPat
using Lumina.Contracts.Responses.FileSystemManagement.Path;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
using Lumina.Application.Common.Infrastructure.Validation;
using NSubstitute;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
@@ -33,7 +34,10 @@ public class GetPathParentQueryHandlerTests
{
_fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
_mockPathService = Substitute.For<IPathService>();
_sut = new GetPathParentQueryHandler(_mockPathService);
IValidator<GetPathParentQuery> mockValidator = Substitute.For<IValidator<GetPathParentQuery>>();
mockValidator.Validate(Arg.Any<GetPathParentQuery>())
.Returns([]);
_sut = new GetPathParentQueryHandler(_mockPathService, mockValidator);
_pathSegmentFixture = new PathSegmentFixture();
}
@@ -52,7 +56,7 @@ public class GetPathParentQueryHandlerTests
.Returns(ErrorOrFactory.From(pathSegments));
// Act
ErrorOr<IEnumerable<PathSegmentResponse>> result = await _sut.Handle(query, CancellationToken.None);
ErrorOr<IEnumerable<PathSegmentResponse>> result = await _sut.HandleAsync(query, CancellationToken.None);
// Assert
Assert.False(result.IsError);
@@ -71,7 +75,7 @@ public class GetPathParentQueryHandlerTests
.Returns(error);
// Act
ErrorOr<IEnumerable<PathSegmentResponse>> result = await _sut.Handle(query, CancellationToken.None);
ErrorOr<IEnumerable<PathSegmentResponse>> result = await _sut.HandleAsync(query, CancellationToken.None);
// Assert
Assert.True(result.IsError);
@@ -89,7 +93,7 @@ public class GetPathParentQueryHandlerTests
.Returns(emptyList);
// Act
ErrorOr<IEnumerable<PathSegmentResponse>> result = await _sut.Handle(query, CancellationToken.None);
ErrorOr<IEnumerable<PathSegmentResponse>> result = await _sut.HandleAsync(query, CancellationToken.None);
// Assert
Assert.False(result.IsError);
@@ -1,8 +1,10 @@
#region ========================================================================= USING =====================================================================================
using FluentValidation.TestHelper;
using ErrorOr;
using Lumina.Application.Core.FileSystemManagement.Paths.Queries.GetPathParent;
using Lumina.Application.UnitTests.Common.Setup;
using Lumina.Application.UnitTests.Core.FileSystemManagement.Pahs.Queries.GetPathParent.Fixtures;
using Lumina.Domain.SharedKernel.Common.Errors;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
#endregion
@@ -32,11 +34,10 @@ public class GetPathParentQueryValidatorTests
query = query with { Path = null! };
// Act
TestValidationResult<GetPathParentQuery> result = _validator.TestValidate(query);
List<Error> result = _validator.TestValidate(query);
// Assert
result.ShouldHaveValidationErrorFor(x => x.Path)
.WithErrorMessage(Errors.FileSystemManagement.PathCannotBeEmpty.Description);
result.ShouldHaveValidationError(Errors.FileSystemManagement.PathCannotBeEmpty);
}
[Fact]
@@ -47,11 +48,10 @@ public class GetPathParentQueryValidatorTests
query = query with { Path = string.Empty };
// Act
TestValidationResult<GetPathParentQuery> result = _validator.TestValidate(query);
List<Error> result = _validator.TestValidate(query);
// Assert
result.ShouldHaveValidationErrorFor(x => x.Path)
.WithErrorMessage(Errors.FileSystemManagement.PathCannotBeEmpty.Description);
result.ShouldHaveValidationError(Errors.FileSystemManagement.PathCannotBeEmpty);
}
[Fact]
@@ -62,11 +62,10 @@ public class GetPathParentQueryValidatorTests
query = query with { Path = " " };
// Act
TestValidationResult<GetPathParentQuery> result = _validator.TestValidate(query);
List<Error> result = _validator.TestValidate(query);
// Assert
result.ShouldHaveValidationErrorFor(x => x.Path)
.WithErrorMessage(Errors.FileSystemManagement.PathCannotBeEmpty.Description);
result.ShouldHaveValidationError(Errors.FileSystemManagement.PathCannotBeEmpty);
}
[Fact]
@@ -77,9 +76,9 @@ public class GetPathParentQueryValidatorTests
query = query with { Path = "/valid/path" };
// Act
TestValidationResult<GetPathParentQuery> result = _validator.TestValidate(query);
List<Error> result = _validator.TestValidate(query);
// Assert
result.ShouldNotHaveValidationErrorFor(x => x.Path);
result.ShouldNotHaveValidationError(Errors.FileSystemManagement.PathCannotBeEmpty);
}
}
@@ -6,6 +6,7 @@ using Lumina.Application.UnitTests.Core.FileSystemManagement.Pahs.Queries.GetPat
using Lumina.Contracts.Responses.FileSystemManagement.Path;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services;
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
using Lumina.Application.Common.Infrastructure.Validation;
using NSubstitute;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
@@ -30,7 +31,10 @@ public class GetPathRootQueryHandlerTests
public GetPathRootQueryHandlerTests()
{
_mockPathService = Substitute.For<IPathService>();
_sut = new GetPathRootQueryHandler(_mockPathService);
IValidator<GetPathRootQuery> mockValidator = Substitute.For<IValidator<GetPathRootQuery>>();
mockValidator.Validate(Arg.Any<GetPathRootQuery>())
.Returns([]);
_sut = new GetPathRootQueryHandler(_mockPathService, mockValidator);
_pathSegmentFixture = new PathSegmentFixture();
}
@@ -45,7 +49,7 @@ public class GetPathRootQueryHandlerTests
.Returns(ErrorOrFactory.From(pathSegment));
// Act
ErrorOr<PathSegmentResponse> result = await _sut.Handle(query, CancellationToken.None);
ErrorOr<PathSegmentResponse> result = await _sut.HandleAsync(query, CancellationToken.None);
// Assert
Assert.False(result.IsError);
@@ -64,7 +68,7 @@ public class GetPathRootQueryHandlerTests
.Returns(error);
// Act
ErrorOr<PathSegmentResponse> result = await _sut.Handle(query, CancellationToken.None);
ErrorOr<PathSegmentResponse> result = await _sut.HandleAsync(query, CancellationToken.None);
// Assert
Assert.True(result.IsError);
@@ -83,7 +87,7 @@ public class GetPathRootQueryHandlerTests
.Returns(ErrorOrFactory.From(rootPathSegment));
// Act
ErrorOr<PathSegmentResponse> result = await _sut.Handle(query, CancellationToken.None);
ErrorOr<PathSegmentResponse> result = await _sut.HandleAsync(query, CancellationToken.None);
// Assert
Assert.False(result.IsError);
@@ -1,8 +1,10 @@
#region ========================================================================= USING =====================================================================================
using FluentValidation.TestHelper;
using ErrorOr;
using Lumina.Application.Core.FileSystemManagement.Paths.Queries.GetPathRoot;
using Lumina.Application.UnitTests.Common.Setup;
using Lumina.Application.UnitTests.Core.FileSystemManagement.Pahs.Queries.GetPathRoot.Fixtures;
using Lumina.Domain.SharedKernel.Common.Errors;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
#endregion
@@ -32,11 +34,10 @@ public class GetPathRootQueryValidatorTests
query = query with { Path = null! };
// Act
TestValidationResult<GetPathRootQuery> result = _validator.TestValidate(query);
List<Error> result = _validator.TestValidate(query);
// Assert
result.ShouldHaveValidationErrorFor(x => x.Path)
.WithErrorMessage(Errors.FileSystemManagement.PathCannotBeEmpty.Description);
result.ShouldHaveValidationError(Errors.FileSystemManagement.PathCannotBeEmpty);
}
[Fact]
@@ -47,11 +48,10 @@ public class GetPathRootQueryValidatorTests
query = query with { Path = string.Empty };
// Act
TestValidationResult<GetPathRootQuery> result = _validator.TestValidate(query);
List<Error> result = _validator.TestValidate(query);
// Assert
result.ShouldHaveValidationErrorFor(x => x.Path)
.WithErrorMessage(Errors.FileSystemManagement.PathCannotBeEmpty.Description);
result.ShouldHaveValidationError(Errors.FileSystemManagement.PathCannotBeEmpty);
}
[Fact]
@@ -62,11 +62,10 @@ public class GetPathRootQueryValidatorTests
query = query with { Path = " " };
// Act
TestValidationResult<GetPathRootQuery> result = _validator.TestValidate(query);
List<Error> result = _validator.TestValidate(query);
// Assert
result.ShouldHaveValidationErrorFor(x => x.Path)
.WithErrorMessage(Errors.FileSystemManagement.PathCannotBeEmpty.Description);
result.ShouldHaveValidationError(Errors.FileSystemManagement.PathCannotBeEmpty);
}
[Fact]
@@ -77,9 +76,9 @@ public class GetPathRootQueryValidatorTests
query = query with { Path = "/valid/path" };
// Act
TestValidationResult<GetPathRootQuery> result = _validator.TestValidate(query);
List<Error> result = _validator.TestValidate(query);
// Assert
result.ShouldNotHaveValidationErrorFor(x => x.Path);
result.ShouldNotHaveValidationError(Errors.FileSystemManagement.PathCannotBeEmpty);
}
}
@@ -38,7 +38,7 @@ public class GetPathSeparatorQueryHandlerTests
_mockPathService.PathSeparator.Returns(expectedSeparator);
// Act
PathSeparatorResponse result = await _sut.Handle(query, CancellationToken.None);
PathSeparatorResponse result = await _sut.HandleAsync(query, CancellationToken.None);
// Assert
Assert.NotNull(result);
@@ -57,7 +57,7 @@ public class GetPathSeparatorQueryHandlerTests
_mockPathService.PathSeparator.Returns(separator);
// Act
PathSeparatorResponse result = await _sut.Handle(query, CancellationToken.None);
PathSeparatorResponse result = await _sut.HandleAsync(query, CancellationToken.None);
// Assert
Assert.NotNull(result);
@@ -74,8 +74,8 @@ public class GetPathSeparatorQueryHandlerTests
_mockPathService.PathSeparator.Returns(expectedSeparator);
// Act
PathSeparatorResponse result1 = await _sut.Handle(query, CancellationToken.None);
PathSeparatorResponse result2 = await _sut.Handle(query, CancellationToken.None);
PathSeparatorResponse result1 = await _sut.HandleAsync(query, CancellationToken.None);
PathSeparatorResponse result2 = await _sut.HandleAsync(query, CancellationToken.None);
// Assert
Assert.Equal(result1, result2);
@@ -91,7 +91,7 @@ public class GetPathSeparatorQueryHandlerTests
// Act
Exception? exception = await Record.ExceptionAsync(
async () => await _sut.Handle(query, cts.Token)
async () => await _sut.HandleAsync(query, cts.Token)
);
// Assert
@@ -37,7 +37,7 @@ public class ValidatePathQueryHandlerTests
_mockPathService.IsValidPath(query.Path!).Returns(true);
// Act
PathValidResponse result = await _sut.Handle(query, CancellationToken.None);
PathValidResponse result = await _sut.HandleAsync(query, CancellationToken.None);
// Assert
Assert.True(result.IsValid);
@@ -52,7 +52,7 @@ public class ValidatePathQueryHandlerTests
_mockPathService.IsValidPath(query.Path!).Returns(false);
// Act
PathValidResponse result = await _sut.Handle(query, CancellationToken.None);
PathValidResponse result = await _sut.HandleAsync(query, CancellationToken.None);
// Assert
Assert.False(result.IsValid);
@@ -67,7 +67,7 @@ public class ValidatePathQueryHandlerTests
_mockPathService.IsValidPath(Arg.Any<string>()).Returns(false);
// Act
PathValidResponse result = await _sut.Handle(query, CancellationToken.None);
PathValidResponse result = await _sut.HandleAsync(query, CancellationToken.None);
// Assert
Assert.False(result.IsValid);
@@ -82,7 +82,7 @@ public class ValidatePathQueryHandlerTests
_mockPathService.IsValidPath(Arg.Any<string>()).Returns(false);
// Act
PathValidResponse result = await _sut.Handle(query, CancellationToken.None);
PathValidResponse result = await _sut.HandleAsync(query, CancellationToken.None);
// Assert
Assert.False(result.IsValid);
@@ -1,8 +1,10 @@
#region ========================================================================= USING =====================================================================================
using FluentValidation.TestHelper;
using ErrorOr;
using Lumina.Application.Core.FileSystemManagement.Paths.Queries.ValidatePath;
using Lumina.Application.UnitTests.Common.Setup;
using Lumina.Application.UnitTests.Core.FileSystemManagement.Pahs.Queries.ValidatePath.Fixtures;
using Lumina.Domain.SharedKernel.Common.Errors;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
#endregion
@@ -32,11 +34,10 @@ public class ValidatePathQueryValidatorTests
query = query with { Path = null! };
// Act
TestValidationResult<ValidatePathQuery> result = _validator.TestValidate(query);
List<Error> result = _validator.TestValidate(query);
// Assert
result.ShouldHaveValidationErrorFor(x => x.Path)
.WithErrorMessage(Errors.FileSystemManagement.PathCannotBeEmpty.Description);
result.ShouldHaveValidationError(Errors.FileSystemManagement.PathCannotBeEmpty);
}
[Fact]
@@ -47,11 +48,10 @@ public class ValidatePathQueryValidatorTests
query = query with { Path = string.Empty };
// Act
TestValidationResult<ValidatePathQuery> result = _validator.TestValidate(query);
List<Error> result = _validator.TestValidate(query);
// Assert
result.ShouldHaveValidationErrorFor(x => x.Path)
.WithErrorMessage(Errors.FileSystemManagement.PathCannotBeEmpty.Description);
result.ShouldHaveValidationError(Errors.FileSystemManagement.PathCannotBeEmpty);
}
[Fact]
@@ -62,11 +62,10 @@ public class ValidatePathQueryValidatorTests
query = query with { Path = " " };
// Act
TestValidationResult<ValidatePathQuery> result = _validator.TestValidate(query);
List<Error> result = _validator.TestValidate(query);
// Assert
result.ShouldHaveValidationErrorFor(x => x.Path)
.WithErrorMessage(Errors.FileSystemManagement.PathCannotBeEmpty.Description);
result.ShouldHaveValidationError(Errors.FileSystemManagement.PathCannotBeEmpty);
}
[Fact]
@@ -77,9 +76,9 @@ public class ValidatePathQueryValidatorTests
query = query with { Path = "/valid/path" };
// Act
TestValidationResult<ValidatePathQuery> result = _validator.TestValidate(query);
List<Error> result = _validator.TestValidate(query);
// Assert
result.ShouldNotHaveValidationErrorFor(x => x.Path);
result.ShouldNotHaveValidationError(Errors.FileSystemManagement.PathCannotBeEmpty);
}
}