Removes FluentAssertions library from test projects, due to licensing changes

This commit is contained in:
BinaryAlley committed 2025-02-03 00:31:15 +02:00
1 parent c1100e5398
commit d46bfae4fc
235 files changed
+4468 -4725

No files matched your search

@@ -1,5 +1,4 @@
#region ========================================================================= USING =====================================================================================
using FluentAssertions;
using Lumina.Presentation.Api.Common.Authentication;
using Microsoft.AspNetCore.Http;
using NSubstitute;
@@ -38,7 +37,7 @@ public class HttpContextCurrentUserServiceTests
Guid? result = _sut.UserId;
// Assert
result.Should().BeNull();
Assert.Null(result);
}
[Fact]
@@ -52,7 +51,7 @@ public class HttpContextCurrentUserServiceTests
Guid? result = _sut.UserId;
// Assert
result.Should().BeNull();
Assert.Null(result);
}
[Fact]
@@ -71,7 +70,7 @@ public class HttpContextCurrentUserServiceTests
Guid? result = _sut.UserId;
// Assert
result.Should().BeNull();
Assert.Null(result);
}
[Fact]
@@ -90,7 +89,7 @@ public class HttpContextCurrentUserServiceTests
Guid? result = _sut.UserId;
// Assert
result.Should().BeNull();
Assert.Null(result);
}
[Fact]
@@ -110,7 +109,7 @@ public class HttpContextCurrentUserServiceTests
Guid? result = _sut.UserId;
// Assert
result.Should().Be(expectedUserId);
Assert.Equal(expectedUserId, result);
}
[Fact]
@@ -131,6 +130,6 @@ public class HttpContextCurrentUserServiceTests
Guid? result = _sut.UserId;
// Assert
result.Should().Be(expectedUserId);
Assert.Equal(expectedUserId, result);
}
}
@@ -1,15 +1,10 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FastEndpoints;
using FluentAssertions;
using Lumina.Application.Core.Admin.Authorization.Permissions.Queries.GetPermissions;
using Lumina.Application.Core.UsersManagement.Authorization.Queries.GetAuthorization;
using Lumina.Contracts.Requests.Authorization;
using Lumina.Contracts.Responses.Authorization;
using Lumina.Domain.Common.Enums.Authorization;
using Lumina.Presentation.Api.Core.Endpoints.Admin.Authorization.Permissions.GetPermissions;
using Lumina.Presentation.Api.Core.Endpoints.UsersManagement.Authorization.GetAuthorization;
using Lumina.Presentation.Api.UnitTests.Core.Endpoints.UsersManagement.Authorization.GetAuthorization.Fixtures;
using Mediator;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.HttpResults;
@@ -60,8 +55,8 @@ public class GetPermissionsEndpointTests
IResult result = await _sut.ExecuteAsync(new EmptyRequest(), cancellationToken);
// Assert
Ok<IEnumerable<PermissionResponse>> okResult = result.Should().BeOfType<Ok<IEnumerable<PermissionResponse>>>().Subject;
okResult.Value.Should().BeEquivalentTo(expectedResponse);
Ok<IEnumerable<PermissionResponse>> okResult = Assert.IsType<Ok<IEnumerable<PermissionResponse>>>(result);
Assert.Equal(expectedResponse, okResult.Value);
}
[Fact]
@@ -77,16 +72,16 @@ public class GetPermissionsEndpointTests
IResult result = await _sut.ExecuteAsync(new EmptyRequest(), cancellationToken);
// Assert
ProblemHttpResult problemResult = result.Should().BeOfType<ProblemHttpResult>().Subject;
problemResult.StatusCode.Should().Be(StatusCodes.Status403Forbidden);
problemResult.ContentType.Should().Be("application/problem+json");
problemResult.ProblemDetails.Should().BeOfType<Microsoft.AspNetCore.Mvc.ProblemDetails>();
ProblemHttpResult problemResult = Assert.IsType<ProblemHttpResult>(result);
Assert.Equal(StatusCodes.Status403Forbidden, problemResult.StatusCode);
Assert.Equal("application/problem+json", problemResult.ContentType);
Assert.IsType<Microsoft.AspNetCore.Mvc.ProblemDetails>(problemResult.ProblemDetails);
problemResult.ProblemDetails.Title.Should().Be("Permissions.NotFound");
problemResult.ProblemDetails.Detail.Should().Be("No permissions found.");
problemResult.ProblemDetails.Status.Should().Be(StatusCodes.Status403Forbidden);
problemResult.ProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc9110#section-15.5.4");
problemResult.ProblemDetails.Extensions["traceId"].Should().NotBeNull();
Assert.Equal("Permissions.NotFound", problemResult.ProblemDetails.Title);
Assert.Equal("No permissions found.", problemResult.ProblemDetails.Detail);
Assert.Equal(StatusCodes.Status403Forbidden, problemResult.ProblemDetails.Status);
Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.4", problemResult.ProblemDetails.Type);
Assert.NotNull(problemResult.ProblemDetails.Extensions["traceId"]);
}
[Fact]
@@ -1,7 +1,6 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FastEndpoints;
using FluentAssertions;
using Lumina.Application.Core.Admin.Authorization.Permissions.Queries.GetPermissions;
using Lumina.Application.Core.Admin.Authorization.Roles.Commands.AddRole;
using Lumina.Application.Core.UsersManagement.Authorization.Queries.GetAuthorization;
@@ -59,8 +58,8 @@ public class AddRoleEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
Ok<RolePermissionsResponse> okResult = result.Should().BeOfType<Ok<RolePermissionsResponse>>().Subject;
okResult.Value.Should().BeEquivalentTo(expectedResponse);
Ok<RolePermissionsResponse> okResult = Assert.IsType<Ok<RolePermissionsResponse>>(result);
Assert.Equal(expectedResponse, okResult.Value);
}
[Fact]
@@ -77,16 +76,16 @@ public class AddRoleEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
ProblemHttpResult problemResult = result.Should().BeOfType<ProblemHttpResult>().Subject;
problemResult.StatusCode.Should().Be(StatusCodes.Status403Forbidden);
problemResult.ContentType.Should().Be("application/problem+json");
problemResult.ProblemDetails.Should().BeOfType<Microsoft.AspNetCore.Mvc.ProblemDetails>();
ProblemHttpResult problemResult = Assert.IsType<ProblemHttpResult>(result);
Assert.Equal(StatusCodes.Status403Forbidden, problemResult.StatusCode);
Assert.Equal("application/problem+json", problemResult.ContentType);
Assert.IsType<Microsoft.AspNetCore.Mvc.ProblemDetails>(problemResult.ProblemDetails);
problemResult.ProblemDetails.Title.Should().Be("Role.Creation.Failed");
problemResult.ProblemDetails.Detail.Should().Be("Failed to create role.");
problemResult.ProblemDetails.Status.Should().Be(StatusCodes.Status403Forbidden);
problemResult.ProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc9110#section-15.5.4");
problemResult.ProblemDetails.Extensions["traceId"].Should().NotBeNull();
Assert.Equal("Role.Creation.Failed", problemResult.ProblemDetails.Title);
Assert.Equal("Failed to create role.", problemResult.ProblemDetails.Detail);
Assert.Equal(StatusCodes.Status403Forbidden, problemResult.ProblemDetails.Status);
Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.4", problemResult.ProblemDetails.Type);
Assert.NotNull(problemResult.ProblemDetails.Extensions["traceId"]);
}
[Fact]
@@ -1,7 +1,6 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FastEndpoints;
using FluentAssertions;
using Lumina.Application.Core.Admin.Authorization.Roles.Commands.DeleteRole;
using Lumina.Contracts.Requests.Authorization;
using Lumina.Presentation.Api.Core.Endpoints.Admin.Authorization.Roles.DeleteRole;
@@ -48,7 +47,7 @@ public class DeleteRoleEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
result.Should().BeOfType<NoContent>();
Assert.IsType<NoContent>(result);
}
[Fact]
@@ -65,16 +64,16 @@ public class DeleteRoleEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
ProblemHttpResult problemResult = result.Should().BeOfType<ProblemHttpResult>().Subject;
problemResult.StatusCode.Should().Be(StatusCodes.Status403Forbidden);
problemResult.ContentType.Should().Be("application/problem+json");
problemResult.ProblemDetails.Should().BeOfType<Microsoft.AspNetCore.Mvc.ProblemDetails>();
ProblemHttpResult problemResult = Assert.IsType<ProblemHttpResult>(result);
Assert.Equal(StatusCodes.Status403Forbidden, problemResult.StatusCode);
Assert.Equal("application/problem+json", problemResult.ContentType);
Assert.IsType<Microsoft.AspNetCore.Mvc.ProblemDetails>(problemResult.ProblemDetails);
problemResult.ProblemDetails.Title.Should().Be("Role.Deletion.Failed");
problemResult.ProblemDetails.Detail.Should().Be("Failed to delete role.");
problemResult.ProblemDetails.Status.Should().Be(StatusCodes.Status403Forbidden);
problemResult.ProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc9110#section-15.5.4");
problemResult.ProblemDetails.Extensions["traceId"].Should().NotBeNull();
Assert.Equal("Role.Deletion.Failed", problemResult.ProblemDetails.Title);
Assert.Equal("Failed to delete role.", problemResult.ProblemDetails.Detail);
Assert.Equal(StatusCodes.Status403Forbidden, problemResult.ProblemDetails.Status);
Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.4", problemResult.ProblemDetails.Type);
Assert.NotNull(problemResult.ProblemDetails.Extensions["traceId"]);
}
[Fact]
@@ -1,7 +1,6 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FastEndpoints;
using FluentAssertions;
using Lumina.Application.Core.Admin.Authorization.Roles.Queries.GetRolePermissions;
using Lumina.Contracts.DTO.Authentication;
using Lumina.Contracts.Requests.Authorization;
@@ -55,8 +54,8 @@ public class GetRolePermissionsEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
Ok<RolePermissionsResponse> okResult = result.Should().BeOfType<Ok<RolePermissionsResponse>>().Subject;
okResult.Value.Should().BeEquivalentTo(expectedResponse);
Ok<RolePermissionsResponse> okResult = Assert.IsType<Ok<RolePermissionsResponse>>(result);
Assert.Equal(expectedResponse, okResult.Value);
}
[Fact]
@@ -73,16 +72,16 @@ public class GetRolePermissionsEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
ProblemHttpResult problemResult = result.Should().BeOfType<ProblemHttpResult>().Subject;
problemResult.StatusCode.Should().Be(StatusCodes.Status403Forbidden);
problemResult.ContentType.Should().Be("application/problem+json");
problemResult.ProblemDetails.Should().BeOfType<Microsoft.AspNetCore.Mvc.ProblemDetails>();
ProblemHttpResult problemResult = Assert.IsType<ProblemHttpResult>(result);
Assert.Equal(StatusCodes.Status403Forbidden, problemResult.StatusCode);
Assert.Equal("application/problem+json", problemResult.ContentType);
Assert.IsType<Microsoft.AspNetCore.Mvc.ProblemDetails>(problemResult.ProblemDetails);
problemResult.ProblemDetails.Title.Should().Be("Role.Permissions.NotFound");
problemResult.ProblemDetails.Detail.Should().Be("Role permissions not found.");
problemResult.ProblemDetails.Status.Should().Be(StatusCodes.Status403Forbidden);
problemResult.ProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc9110#section-15.5.4");
problemResult.ProblemDetails.Extensions["traceId"].Should().NotBeNull();
Assert.Equal("Role.Permissions.NotFound", problemResult.ProblemDetails.Title);
Assert.Equal("Role permissions not found.", problemResult.ProblemDetails.Detail);
Assert.Equal(StatusCodes.Status403Forbidden, problemResult.ProblemDetails.Status);
Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.4", problemResult.ProblemDetails.Type);
Assert.NotNull(problemResult.ProblemDetails.Extensions["traceId"]);
}
[Fact]
@@ -1,7 +1,6 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FastEndpoints;
using FluentAssertions;
using Lumina.Application.Core.Admin.Authorization.Roles.Queries.GetRoles;
using Lumina.Contracts.Responses.Authorization;
using Lumina.Presentation.Api.Core.Endpoints.Admin.Authorization.Roles.GetRoles;
@@ -52,8 +51,8 @@ public class GetRolesEndpointTests
IResult result = await _sut.ExecuteAsync(new EmptyRequest(), cancellationToken);
// Assert
Ok<IEnumerable<RoleResponse>> okResult = result.Should().BeOfType<Ok<IEnumerable<RoleResponse>>>().Subject;
okResult.Value.Should().BeEquivalentTo(expectedResponse);
Ok<IEnumerable<RoleResponse>> okResult = Assert.IsType<Ok<IEnumerable<RoleResponse>>>(result);
Assert.Equal(expectedResponse, okResult.Value);
}
[Fact]
@@ -69,16 +68,16 @@ public class GetRolesEndpointTests
IResult result = await _sut.ExecuteAsync(new EmptyRequest(), cancellationToken);
// Assert
ProblemHttpResult problemResult = result.Should().BeOfType<ProblemHttpResult>().Subject;
problemResult.StatusCode.Should().Be(StatusCodes.Status403Forbidden);
problemResult.ContentType.Should().Be("application/problem+json");
problemResult.ProblemDetails.Should().BeOfType<Microsoft.AspNetCore.Mvc.ProblemDetails>();
ProblemHttpResult problemResult = Assert.IsType<ProblemHttpResult>(result);
Assert.Equal(StatusCodes.Status403Forbidden, problemResult.StatusCode);
Assert.Equal("application/problem+json", problemResult.ContentType);
Assert.IsType<Microsoft.AspNetCore.Mvc.ProblemDetails>(problemResult.ProblemDetails);
problemResult.ProblemDetails.Title.Should().Be("Roles.NotFound");
problemResult.ProblemDetails.Detail.Should().Be("No roles found.");
problemResult.ProblemDetails.Status.Should().Be(StatusCodes.Status403Forbidden);
problemResult.ProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc9110#section-15.5.4");
problemResult.ProblemDetails.Extensions["traceId"].Should().NotBeNull();
Assert.Equal("Roles.NotFound", problemResult.ProblemDetails.Title);
Assert.Equal("No roles found.", problemResult.ProblemDetails.Detail);
Assert.Equal(StatusCodes.Status403Forbidden, problemResult.ProblemDetails.Status);
Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.4", problemResult.ProblemDetails.Type);
Assert.NotNull(problemResult.ProblemDetails.Extensions["traceId"]);
}
[Fact]
@@ -1,7 +1,6 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FastEndpoints;
using FluentAssertions;
using Lumina.Application.Core.Admin.Authorization.Roles.Commands.UpdateRole;
using Lumina.Contracts.DTO.Authentication;
using Lumina.Contracts.Requests.Authorization;
@@ -57,8 +56,8 @@ public class UpdateRoleEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
Ok<RolePermissionsResponse> okResult = result.Should().BeOfType<Ok<RolePermissionsResponse>>().Subject;
okResult.Value.Should().BeEquivalentTo(expectedResponse);
Ok<RolePermissionsResponse> okResult = Assert.IsType<Ok<RolePermissionsResponse>>(result);
Assert.Equal(expectedResponse, okResult.Value);
}
[Fact]
@@ -75,16 +74,16 @@ public class UpdateRoleEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
ProblemHttpResult problemResult = result.Should().BeOfType<ProblemHttpResult>().Subject;
problemResult.StatusCode.Should().Be(StatusCodes.Status403Forbidden);
problemResult.ContentType.Should().Be("application/problem+json");
problemResult.ProblemDetails.Should().BeOfType<Microsoft.AspNetCore.Mvc.ProblemDetails>();
ProblemHttpResult problemResult = Assert.IsType<ProblemHttpResult>(result);
Assert.Equal(StatusCodes.Status403Forbidden, problemResult.StatusCode);
Assert.Equal("application/problem+json", problemResult.ContentType);
Assert.IsType<Microsoft.AspNetCore.Mvc.ProblemDetails>(problemResult.ProblemDetails);
problemResult.ProblemDetails.Title.Should().Be("Role.Update.Failed");
problemResult.ProblemDetails.Detail.Should().Be("Failed to update role.");
problemResult.ProblemDetails.Status.Should().Be(StatusCodes.Status403Forbidden);
problemResult.ProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc9110#section-15.5.4");
problemResult.ProblemDetails.Extensions["traceId"].Should().NotBeNull();
Assert.Equal("Role.Update.Failed", problemResult.ProblemDetails.Title);
Assert.Equal("Failed to update role.", problemResult.ProblemDetails.Detail);
Assert.Equal(StatusCodes.Status403Forbidden, problemResult.ProblemDetails.Status);
Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.4", problemResult.ProblemDetails.Type);
Assert.NotNull(problemResult.ProblemDetails.Extensions["traceId"]);
}
[Fact]
@@ -1,7 +1,6 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FastEndpoints;
using FluentAssertions;
using Lumina.Presentation.Api.UnitTests.Core.Endpoints.Common.Fixtures;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.HttpResults;
@@ -34,7 +33,7 @@ public class BaseEndpointTests
IResult result = _sut.TestProblem([]);
// Assert
result.Should().BeOfType<ProblemHttpResult>();
Assert.IsType<ProblemHttpResult>(result);
}
[Fact]
@@ -50,19 +49,17 @@ public class BaseEndpointTests
IResult result = _sut.TestProblem(errors);
// Assert
result.Should().BeOfType<ProblemHttpResult>();
ProblemHttpResult problemDetails = (ProblemHttpResult)result;
problemDetails.StatusCode.Should().Be(StatusCodes.Status422UnprocessableEntity);
problemDetails.ContentType.Should().Be("application/problem+json");
problemDetails.ProblemDetails.Should().BeOfType<HttpValidationProblemDetails>();
HttpValidationProblemDetails validationProblemDetails = (HttpValidationProblemDetails)problemDetails.ProblemDetails;
validationProblemDetails.Status.Should().Be(StatusCodes.Status422UnprocessableEntity);
validationProblemDetails.Title.Should().Be("General.Validation");
validationProblemDetails.Detail.Should().Be("OneOrMoreValidationErrorsOccurred");
validationProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2");
validationProblemDetails.Errors.Should().HaveCount(2);
validationProblemDetails.Errors["Code1"].Should().BeEquivalentTo(["Description1"]);
validationProblemDetails.Errors["Code2"].Should().BeEquivalentTo(["Description2"]);
ProblemHttpResult problemDetails = Assert.IsType<ProblemHttpResult>(result);
Assert.Equal(StatusCodes.Status422UnprocessableEntity, problemDetails.StatusCode);
Assert.Equal("application/problem+json", problemDetails.ContentType);
HttpValidationProblemDetails validationProblemDetails = Assert.IsType<HttpValidationProblemDetails>(problemDetails.ProblemDetails);
Assert.Equal(StatusCodes.Status422UnprocessableEntity, validationProblemDetails.Status);
Assert.Equal("General.Validation", validationProblemDetails.Title);
Assert.Equal("OneOrMoreValidationErrorsOccurred", validationProblemDetails.Detail);
Assert.Equal("https://tools.ietf.org/html/rfc4918#section-11.2", validationProblemDetails.Type);
Assert.Equal(2, validationProblemDetails.Errors.Count);
Assert.Equal(new[] { "Description1" }, validationProblemDetails.Errors["Code1"]);
Assert.Equal(new[] { "Description2" }, validationProblemDetails.Errors["Code2"]);
}
[Theory]
@@ -87,14 +84,13 @@ public class BaseEndpointTests
IResult result = _sut.TestProblem(errors);
// Assert
result.Should().BeOfType<ProblemHttpResult>();
ProblemHttpResult problemResult = (ProblemHttpResult)result;
problemResult.StatusCode.Should().Be(expectedStatusCode);
problemResult.ProblemDetails.Status.Should().Be(expectedStatusCode);
problemResult.ProblemDetails.Title.Should().Be("ErrorCode");
problemResult.ProblemDetails.Detail.Should().Be("ErrorDescription");
problemResult.ProblemDetails.Instance.Should().NotBeNull();
problemResult.ProblemDetails.Extensions.Should().ContainKey("traceId");
ProblemHttpResult problemResult = Assert.IsType<ProblemHttpResult>(result);
Assert.Equal(expectedStatusCode, problemResult.StatusCode);
Assert.Equal(expectedStatusCode, problemResult.ProblemDetails.Status);
Assert.Equal("ErrorCode", problemResult.ProblemDetails.Title);
Assert.Equal("ErrorDescription", problemResult.ProblemDetails.Detail);
Assert.NotNull(problemResult.ProblemDetails.Instance);
Assert.Contains("traceId", problemResult.ProblemDetails.Extensions.Keys);
}
[Fact]
@@ -108,14 +104,13 @@ public class BaseEndpointTests
IResult result = _sut.TestProblem(errors);
// Assert
result.Should().BeOfType<ProblemHttpResult>();
ProblemHttpResult problemResult = (ProblemHttpResult)result;
problemResult.StatusCode.Should().Be(422);
problemResult.ProblemDetails.Status.Should().Be(StatusCodes.Status422UnprocessableEntity);
problemResult.ProblemDetails.Title.Should().Be("General.Validation");
problemResult.ProblemDetails.Detail.Should().Be("OneOrMoreValidationErrorsOccurred");
problemResult.ProblemDetails.Instance.Should().NotBeNull();
problemResult.ProblemDetails.Extensions.Should().ContainKey("traceId");
ProblemHttpResult problemResult = Assert.IsType<ProblemHttpResult>(result);
Assert.Equal(422, problemResult.StatusCode);
Assert.Equal(StatusCodes.Status422UnprocessableEntity, problemResult.ProblemDetails.Status);
Assert.Equal("General.Validation", problemResult.ProblemDetails.Title);
Assert.Equal("OneOrMoreValidationErrorsOccurred", problemResult.ProblemDetails.Detail);
Assert.NotNull(problemResult.ProblemDetails.Instance);
Assert.Contains("traceId", problemResult.ProblemDetails.Extensions.Keys);
}
[Fact]
@@ -131,12 +126,12 @@ public class BaseEndpointTests
IResult result = _sut.TestProblem(errors);
// Assert
result.Should().BeOfType<ProblemHttpResult>();
ProblemHttpResult problemResult = (ProblemHttpResult)result;
problemResult.StatusCode.Should().BeOneOf(StatusCodes.Status404NotFound, StatusCodes.Status400BadRequest);
problemResult.ProblemDetails.Status.Should().BeOneOf(StatusCodes.Status404NotFound, StatusCodes.Status400BadRequest);
problemResult.ProblemDetails.Title.Should().Be("FailureCode");
problemResult.ProblemDetails.Detail.Should().Be("Failure Error");
ProblemHttpResult problemResult = Assert.IsType<ProblemHttpResult>(result);
Assert.Contains(problemResult.StatusCode, new[] { StatusCodes.Status404NotFound, StatusCodes.Status400BadRequest });
int?[] allowedStatusCodes = [StatusCodes.Status404NotFound, StatusCodes.Status400BadRequest];
Assert.Contains(problemResult.ProblemDetails.Status, allowedStatusCodes);
Assert.Equal("FailureCode", problemResult.ProblemDetails.Title);
Assert.Equal("Failure Error", problemResult.ProblemDetails.Detail);
}
[Fact]
@@ -152,19 +147,17 @@ public class BaseEndpointTests
IResult result = _sut.TestValidationProblem(errors);
// Assert
result.Should().BeOfType<ProblemHttpResult>();
ProblemHttpResult problemDetails = (ProblemHttpResult)result;
problemDetails.StatusCode.Should().Be(StatusCodes.Status422UnprocessableEntity);
problemDetails.ContentType.Should().Be("application/problem+json");
problemDetails.ProblemDetails.Should().BeOfType<HttpValidationProblemDetails>();
HttpValidationProblemDetails validationProblemDetails = (HttpValidationProblemDetails)problemDetails.ProblemDetails;
validationProblemDetails.Status.Should().Be(StatusCodes.Status422UnprocessableEntity);
validationProblemDetails.Title.Should().Be("General.Validation");
validationProblemDetails.Detail.Should().Be("OneOrMoreValidationErrorsOccurred");
validationProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2");
validationProblemDetails.Errors.Should().HaveCount(2);
validationProblemDetails.Errors["Code1"].Should().BeEquivalentTo(["Description1"]);
validationProblemDetails.Errors["Code2"].Should().BeEquivalentTo(["Description2"]);
ProblemHttpResult problemDetails = Assert.IsType<ProblemHttpResult>(result);
Assert.Equal(StatusCodes.Status422UnprocessableEntity, problemDetails.StatusCode);
Assert.Equal("application/problem+json", problemDetails.ContentType);
HttpValidationProblemDetails validationProblemDetails = Assert.IsType<HttpValidationProblemDetails>(problemDetails.ProblemDetails);
Assert.Equal(StatusCodes.Status422UnprocessableEntity, validationProblemDetails.Status);
Assert.Equal("General.Validation", validationProblemDetails.Title);
Assert.Equal("OneOrMoreValidationErrorsOccurred", validationProblemDetails.Detail);
Assert.Equal("https://tools.ietf.org/html/rfc4918#section-11.2", validationProblemDetails.Type);
Assert.Equal(2, validationProblemDetails.Errors.Count);
Assert.Equal(new[] { "Description1" }, validationProblemDetails.Errors["Code1"]);
Assert.Equal(new[] { "Description2" }, validationProblemDetails.Errors["Code2"]);
}
[Fact]
@@ -181,11 +174,11 @@ public class BaseEndpointTests
IResult result = _sut.TestValidationProblem(errors);
// Assert
result.Should().BeOfType<ProblemHttpResult>();
ProblemHttpResult problemDetails = (ProblemHttpResult)result;
HttpValidationProblemDetails validationProblemDetails = (HttpValidationProblemDetails)problemDetails.ProblemDetails;
validationProblemDetails.Errors.Should().ContainKeys("Code1", "Code2");
validationProblemDetails.Errors["Code1"].Should().BeEquivalentTo(["Description1", "Description2"]);
validationProblemDetails.Errors["Code2"].Should().BeEquivalentTo(["Description3"]);
ProblemHttpResult problemDetails = Assert.IsType<ProblemHttpResult>(result);
HttpValidationProblemDetails validationProblemDetails = Assert.IsType<HttpValidationProblemDetails>(problemDetails.ProblemDetails);
Assert.Contains("Code1", validationProblemDetails.Errors.Keys);
Assert.Contains("Code2", validationProblemDetails.Errors.Keys);
Assert.Equal(new[] { "Description1", "Description2" }, validationProblemDetails.Errors["Code1"]);
Assert.Equal(new[] { "Description3" }, validationProblemDetails.Errors["Code2"]);
}
}
@@ -3,7 +3,6 @@ using AutoFixture;
using AutoFixture.AutoNSubstitute;
using ErrorOr;
using FastEndpoints;
using FluentAssertions;
using Lumina.Application.Core.FileSystemManagement.Directories.Queries.GetDirectories;
using Lumina.Contracts.Requests.FileSystemManagement.Directories;
using Lumina.Contracts.Responses.FileSystemManagement.Directories;
@@ -56,8 +55,8 @@ public class GetDirectoriesEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
IEnumerable<DirectoryResponse> actualResponses = result.Should().BeOfType<Ok<IEnumerable<DirectoryResponse>>>().Subject.Value!;
actualResponses.Should().BeEquivalentTo(expectedResponses);
Ok<IEnumerable<DirectoryResponse>> okResult = Assert.IsType<Ok<IEnumerable<DirectoryResponse>>>(result);
Assert.Equal(expectedResponses, okResult.Value);
}
[Fact]
@@ -74,17 +73,16 @@ public class GetDirectoriesEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
result.Should().BeOfType<ProblemHttpResult>();
ProblemHttpResult problemDetails = (ProblemHttpResult)result;
problemDetails.StatusCode.Should().Be(StatusCodes.Status404NotFound);
problemDetails.ContentType.Should().Be("application/problem+json");
problemDetails.ProblemDetails.Should().BeOfType<Microsoft.AspNetCore.Mvc.ProblemDetails>();
problemDetails.ProblemDetails.Title.Should().Be("Directory.NotFound");
problemDetails.ProblemDetails.Detail.Should().Be("The requested directory was not found.");
problemDetails.ProblemDetails.Status.Should().Be(StatusCodes.Status404NotFound);
problemDetails.ProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc9110#section-15.5.5");
problemDetails.ProblemDetails.Extensions["traceId"].Should().NotBeNull();
ProblemHttpResult problemDetails = Assert.IsType<ProblemHttpResult>(result);
Assert.Equal(StatusCodes.Status404NotFound, problemDetails.StatusCode);
Assert.Equal("application/problem+json", problemDetails.ContentType);
Assert.IsType<Microsoft.AspNetCore.Mvc.ProblemDetails>(problemDetails.ProblemDetails);
Assert.Equal("Directory.NotFound", problemDetails.ProblemDetails.Title);
Assert.Equal("The requested directory was not found.", problemDetails.ProblemDetails.Detail);
Assert.Equal(StatusCodes.Status404NotFound, problemDetails.ProblemDetails.Status);
Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.5", problemDetails.ProblemDetails.Type);
Assert.NotNull(problemDetails.ProblemDetails.Extensions["traceId"]);
}
[Fact]
@@ -101,22 +99,16 @@ public class GetDirectoriesEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
result.Should().BeOfType<ProblemHttpResult>();
ProblemHttpResult problemDetails = (ProblemHttpResult)result;
problemDetails.StatusCode.Should().Be(StatusCodes.Status422UnprocessableEntity);
problemDetails.ContentType.Should().Be("application/problem+json");
problemDetails.ProblemDetails.Should().BeOfType<HttpValidationProblemDetails>();
HttpValidationProblemDetails validationProblemDetails = (HttpValidationProblemDetails)problemDetails.ProblemDetails;
validationProblemDetails.Status.Should().Be(StatusCodes.Status422UnprocessableEntity);
validationProblemDetails.Title.Should().Be("General.Validation");
validationProblemDetails.Detail.Should().Be("OneOrMoreValidationErrorsOccurred");
validationProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2");
validationProblemDetails.Errors.Should().ContainSingle()
.Which.Should().BeEquivalentTo(new
{
Key = "Path.Invalid",
Value = new[] { "The provided path is invalid." }
});
ProblemHttpResult problemDetails = Assert.IsType<ProblemHttpResult>(result);
Assert.Equal(StatusCodes.Status422UnprocessableEntity, problemDetails.StatusCode);
Assert.Equal("application/problem+json", problemDetails.ContentType);
HttpValidationProblemDetails validationProblemDetails = Assert.IsType<HttpValidationProblemDetails>(problemDetails.ProblemDetails);
Assert.Equal(StatusCodes.Status422UnprocessableEntity, validationProblemDetails.Status);
Assert.Equal("General.Validation", validationProblemDetails.Title);
Assert.Equal("OneOrMoreValidationErrorsOccurred", validationProblemDetails.Detail);
Assert.Equal("https://tools.ietf.org/html/rfc4918#section-11.2", validationProblemDetails.Type);
Assert.Single(validationProblemDetails.Errors);
Assert.Equal(new[] { "The provided path is invalid." }, validationProblemDetails.Errors["Path.Invalid"]);
}
[Fact]
@@ -1,7 +1,6 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FastEndpoints;
using FluentAssertions;
using Lumina.Application.Core.FileSystemManagement.Drives.Queries.GetDrives;
using Lumina.Contracts.Responses.FileSystemManagement.Common;
using Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Drives.GetDrives;
@@ -53,8 +52,8 @@ public class GetDrivesEndpointTests
IResult result = await _sut.ExecuteAsync(new EmptyRequest(), cancellationToken);
// Assert
IEnumerable<FileSystemTreeNodeResponse> actualResponses = result.Should().BeOfType<Ok<IEnumerable<FileSystemTreeNodeResponse>>>().Subject.Value!;
actualResponses.Should().BeEquivalentTo(expectedResponses);
Ok<IEnumerable<FileSystemTreeNodeResponse>> okResult = Assert.IsType<Ok<IEnumerable<FileSystemTreeNodeResponse>>>(result);
Assert.Equal(expectedResponses, okResult.Value);
}
[Fact]
@@ -70,17 +69,16 @@ public class GetDrivesEndpointTests
IResult result = await _sut.ExecuteAsync(new EmptyRequest(), cancellationToken);
// Assert
result.Should().BeOfType<ProblemHttpResult>();
ProblemHttpResult problemDetails = (ProblemHttpResult)result;
problemDetails.StatusCode.Should().Be(StatusCodes.Status404NotFound);
problemDetails.ContentType.Should().Be("application/problem+json");
problemDetails.ProblemDetails.Should().BeOfType<Microsoft.AspNetCore.Mvc.ProblemDetails>();
ProblemHttpResult problemDetails = Assert.IsType<ProblemHttpResult>(result);
Assert.Equal(StatusCodes.Status404NotFound, problemDetails.StatusCode);
Assert.Equal("application/problem+json", problemDetails.ContentType);
Assert.IsType<Microsoft.AspNetCore.Mvc.ProblemDetails>(problemDetails.ProblemDetails);
problemDetails.ProblemDetails.Title.Should().Be("Drive.NotFound");
problemDetails.ProblemDetails.Detail.Should().Be("The requested drive was not found.");
problemDetails.ProblemDetails.Status.Should().Be(StatusCodes.Status404NotFound);
problemDetails.ProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc9110#section-15.5.5");
problemDetails.ProblemDetails.Extensions["traceId"].Should().NotBeNull();
Assert.Equal("Drive.NotFound", problemDetails.ProblemDetails.Title);
Assert.Equal("The requested drive was not found.", problemDetails.ProblemDetails.Detail);
Assert.Equal(StatusCodes.Status404NotFound, problemDetails.ProblemDetails.Status);
Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.5", problemDetails.ProblemDetails.Type);
Assert.NotNull(problemDetails.ProblemDetails.Extensions["traceId"]);
}
[Fact]
@@ -1,6 +1,5 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using FluentAssertions;
using Lumina.Application.Core.FileSystemManagement.FileSystem.Queries.GetFileSystem;
using Lumina.Domain.Common.Enums.FileSystem;
using Lumina.Contracts.Responses.FileSystemManagement.FileSystem;
@@ -48,8 +47,8 @@ public class GetFileSystemTypeEndpointTests
IResult result = await _sut.ExecuteAsync(new EmptyRequest(), cancellationToken);
// Assert
Ok<FileSystemTypeResponse> okResult = result.Should().BeOfType<Ok<FileSystemTypeResponse>>().Subject;
okResult.Value.Should().BeEquivalentTo(expectedResponse);
Ok<FileSystemTypeResponse> okResult = Assert.IsType<Ok<FileSystemTypeResponse>>(result);
Assert.Equal(expectedResponse, okResult.Value);
}
[Theory]
@@ -67,8 +66,8 @@ public class GetFileSystemTypeEndpointTests
IResult result = await _sut.ExecuteAsync(new EmptyRequest(), cancellationToken);
// Assert
Ok<FileSystemTypeResponse> okResult = result.Should().BeOfType<Ok<FileSystemTypeResponse>>().Subject;
okResult.Value!.PlatformType.Should().Be(platformType);
Ok<FileSystemTypeResponse> okResult = Assert.IsType<Ok<FileSystemTypeResponse>>(result);
Assert.Equal(platformType, okResult.Value!.PlatformType);
}
[Fact]
@@ -3,7 +3,6 @@ using AutoFixture;
using AutoFixture.AutoNSubstitute;
using ErrorOr;
using FastEndpoints;
using FluentAssertions;
using Lumina.Application.Core.FileSystemManagement.Files.Queries.GetFiles;
using Lumina.Contracts.Requests.FileSystemManagement.Files;
using Lumina.Contracts.Responses.FileSystemManagement.Files;
@@ -58,8 +57,8 @@ public class GetFilesEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
IEnumerable<FileResponse> actualResponses = result.Should().BeOfType<Ok<IEnumerable<FileResponse>>>().Subject.Value!;
actualResponses.Should().BeEquivalentTo(expectedResponses);
Ok<IEnumerable<FileResponse>> okResult = Assert.IsType<Ok<IEnumerable<FileResponse>>>(result);
Assert.Equal(expectedResponses, okResult.Value);
}
[Fact]
@@ -76,17 +75,16 @@ public class GetFilesEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
result.Should().BeOfType<ProblemHttpResult>();
ProblemHttpResult problemDetails = (ProblemHttpResult)result;
problemDetails.StatusCode.Should().Be(StatusCodes.Status404NotFound);
problemDetails.ContentType.Should().Be("application/problem+json");
problemDetails.ProblemDetails.Should().BeOfType<Microsoft.AspNetCore.Mvc.ProblemDetails>();
ProblemHttpResult problemDetails = Assert.IsType<ProblemHttpResult>(result);
Assert.Equal(StatusCodes.Status404NotFound, problemDetails.StatusCode);
Assert.Equal("application/problem+json", problemDetails.ContentType);
Assert.IsType<Microsoft.AspNetCore.Mvc.ProblemDetails>(problemDetails.ProblemDetails);
problemDetails.ProblemDetails.Title.Should().Be("File.NotFound");
problemDetails.ProblemDetails.Detail.Should().Be("The requested file was not found.");
problemDetails.ProblemDetails.Status.Should().Be(StatusCodes.Status404NotFound);
problemDetails.ProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc9110#section-15.5.5");
problemDetails.ProblemDetails.Extensions["traceId"].Should().NotBeNull();
Assert.Equal("File.NotFound", problemDetails.ProblemDetails.Title);
Assert.Equal("The requested file was not found.", problemDetails.ProblemDetails.Detail);
Assert.Equal(StatusCodes.Status404NotFound, problemDetails.ProblemDetails.Status);
Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.5", problemDetails.ProblemDetails.Type);
Assert.NotNull(problemDetails.ProblemDetails.Extensions["traceId"]);
}
[Fact]
@@ -103,22 +101,16 @@ public class GetFilesEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
result.Should().BeOfType<ProblemHttpResult>();
ProblemHttpResult problemDetails = (ProblemHttpResult)result;
problemDetails.StatusCode.Should().Be(StatusCodes.Status422UnprocessableEntity);
problemDetails.ContentType.Should().Be("application/problem+json");
problemDetails.ProblemDetails.Should().BeOfType<HttpValidationProblemDetails>();
HttpValidationProblemDetails validationProblemDetails = (HttpValidationProblemDetails)problemDetails.ProblemDetails;
validationProblemDetails.Status.Should().Be(StatusCodes.Status422UnprocessableEntity);
validationProblemDetails.Title.Should().Be("General.Validation");
validationProblemDetails.Detail.Should().Be("OneOrMoreValidationErrorsOccurred");
validationProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2");
validationProblemDetails.Errors.Should().ContainSingle()
.Which.Should().BeEquivalentTo(new
{
Key = "Path.Invalid",
Value = new[] { "The provided path is invalid." }
});
ProblemHttpResult problemDetails = Assert.IsType<ProblemHttpResult>(result);
Assert.Equal(StatusCodes.Status422UnprocessableEntity, problemDetails.StatusCode);
Assert.Equal("application/problem+json", problemDetails.ContentType);
HttpValidationProblemDetails validationProblemDetails = Assert.IsType<HttpValidationProblemDetails>(problemDetails.ProblemDetails);
Assert.Equal(StatusCodes.Status422UnprocessableEntity, validationProblemDetails.Status);
Assert.Equal("General.Validation", validationProblemDetails.Title);
Assert.Equal("OneOrMoreValidationErrorsOccurred", validationProblemDetails.Detail);
Assert.Equal("https://tools.ietf.org/html/rfc4918#section-11.2", validationProblemDetails.Type);
Assert.Single(validationProblemDetails.Errors);
Assert.Equal(new[] { "The provided path is invalid." }, validationProblemDetails.Errors["Path.Invalid"]);
}
[Fact]
@@ -3,7 +3,6 @@ using AutoFixture;
using AutoFixture.AutoNSubstitute;
using ErrorOr;
using FastEndpoints;
using FluentAssertions;
using Lumina.Application.Core.FileSystemManagement.Files.Queries.GetTreeFiles;
using Lumina.Contracts.Requests.FileSystemManagement.Files;
using Lumina.Contracts.Responses.FileSystemManagement.Common;
@@ -59,8 +58,8 @@ public class GetTreeFilesEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
IEnumerable<FileSystemTreeNodeResponse> actualResponses = result.Should().BeOfType<Ok<IEnumerable<FileSystemTreeNodeResponse>>>().Subject.Value!;
actualResponses.Should().BeEquivalentTo(expectedResponses);
Ok<IEnumerable<FileSystemTreeNodeResponse>> okResult = Assert.IsType<Ok<IEnumerable<FileSystemTreeNodeResponse>>>(result);
Assert.Equal(expectedResponses, okResult.Value);
}
[Fact]
@@ -77,17 +76,16 @@ public class GetTreeFilesEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
result.Should().BeOfType<ProblemHttpResult>();
ProblemHttpResult problemDetails = (ProblemHttpResult)result;
problemDetails.StatusCode.Should().Be(StatusCodes.Status404NotFound);
problemDetails.ContentType.Should().Be("application/problem+json");
problemDetails.ProblemDetails.Should().BeOfType<Microsoft.AspNetCore.Mvc.ProblemDetails>();
ProblemHttpResult problemDetails = Assert.IsType<ProblemHttpResult>(result);
Assert.Equal(StatusCodes.Status404NotFound, problemDetails.StatusCode);
Assert.Equal("application/problem+json", problemDetails.ContentType);
Assert.IsType<Microsoft.AspNetCore.Mvc.ProblemDetails>(problemDetails.ProblemDetails);
problemDetails.ProblemDetails.Title.Should().Be("File.NotFound");
problemDetails.ProblemDetails.Detail.Should().Be("The requested file was not found.");
problemDetails.ProblemDetails.Status.Should().Be(StatusCodes.Status404NotFound);
problemDetails.ProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc9110#section-15.5.5");
problemDetails.ProblemDetails.Extensions["traceId"].Should().NotBeNull();
Assert.Equal("File.NotFound", problemDetails.ProblemDetails.Title);
Assert.Equal("The requested file was not found.", problemDetails.ProblemDetails.Detail);
Assert.Equal(StatusCodes.Status404NotFound, problemDetails.ProblemDetails.Status);
Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.5", problemDetails.ProblemDetails.Type);
Assert.NotNull(problemDetails.ProblemDetails.Extensions["traceId"]);
}
[Fact]
@@ -104,22 +102,16 @@ public class GetTreeFilesEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
result.Should().BeOfType<ProblemHttpResult>();
ProblemHttpResult problemDetails = (ProblemHttpResult)result;
problemDetails.StatusCode.Should().Be(StatusCodes.Status422UnprocessableEntity);
problemDetails.ContentType.Should().Be("application/problem+json");
problemDetails.ProblemDetails.Should().BeOfType<HttpValidationProblemDetails>();
HttpValidationProblemDetails validationProblemDetails = (HttpValidationProblemDetails)problemDetails.ProblemDetails;
validationProblemDetails.Status.Should().Be(StatusCodes.Status422UnprocessableEntity);
validationProblemDetails.Title.Should().Be("General.Validation");
validationProblemDetails.Detail.Should().Be("OneOrMoreValidationErrorsOccurred");
validationProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2");
validationProblemDetails.Errors.Should().ContainSingle()
.Which.Should().BeEquivalentTo(new
{
Key = "Path.Invalid",
Value = new[] { "The provided path is invalid." }
});
ProblemHttpResult problemDetails = Assert.IsType<ProblemHttpResult>(result);
Assert.Equal(StatusCodes.Status422UnprocessableEntity, problemDetails.StatusCode);
Assert.Equal("application/problem+json", problemDetails.ContentType);
HttpValidationProblemDetails validationProblemDetails = Assert.IsType<HttpValidationProblemDetails>(problemDetails.ProblemDetails);
Assert.Equal(StatusCodes.Status422UnprocessableEntity, validationProblemDetails.Status);
Assert.Equal("General.Validation", validationProblemDetails.Title);
Assert.Equal("OneOrMoreValidationErrorsOccurred", validationProblemDetails.Detail);
Assert.Equal("https://tools.ietf.org/html/rfc4918#section-11.2", validationProblemDetails.Type);
Assert.Single(validationProblemDetails.Errors);
Assert.Equal(new[] { "The provided path is invalid." }, validationProblemDetails.Errors["Path.Invalid"]);
}
[Fact]
@@ -1,7 +1,6 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FastEndpoints;
using FluentAssertions;
using Lumina.Application.Core.FileSystemManagement.Paths.Queries.CheckPathExists;
using Lumina.Contracts.Requests.FileSystemManagement.Path;
using Lumina.Contracts.Responses.FileSystemManagement.Path;
@@ -53,8 +52,8 @@ public class CheckPathExistsEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
PathExistsResponse actualResponse = result.Should().BeOfType<Ok<PathExistsResponse>>().Subject.Value!;
actualResponse.Should().BeEquivalentTo(expectedResponse);
Ok<PathExistsResponse> okResult = Assert.IsType<Ok<PathExistsResponse>>(result);
Assert.Equal(expectedResponse, okResult.Value);
}
[Fact]
@@ -1,7 +1,6 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FastEndpoints;
using FluentAssertions;
using Lumina.Application.Core.FileSystemManagement.Paths.Commands.CombinePath;
using Lumina.Contracts.Requests.FileSystemManagement.Path;
using Lumina.Contracts.Responses.FileSystemManagement.Path;
@@ -55,8 +54,8 @@ public class CombinePathEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
PathSegmentResponse actualResponse = result.Should().BeOfType<Ok<PathSegmentResponse>>().Subject.Value!;
actualResponse.Should().BeEquivalentTo(expectedResponse);
Ok<PathSegmentResponse> okResult = Assert.IsType<Ok<PathSegmentResponse>>(result);
Assert.Equal(expectedResponse, okResult.Value);
}
[Fact]
@@ -73,17 +72,16 @@ public class CombinePathEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
result.Should().BeOfType<ProblemHttpResult>();
ProblemHttpResult problemDetails = (ProblemHttpResult)result;
problemDetails.StatusCode.Should().Be(StatusCodes.Status404NotFound);
problemDetails.ContentType.Should().Be("application/problem+json");
problemDetails.ProblemDetails.Should().BeOfType<Microsoft.AspNetCore.Mvc.ProblemDetails>();
ProblemHttpResult problemDetails = Assert.IsType<ProblemHttpResult>(result);
Assert.Equal(StatusCodes.Status404NotFound, problemDetails.StatusCode);
Assert.Equal("application/problem+json", problemDetails.ContentType);
Assert.IsType<Microsoft.AspNetCore.Mvc.ProblemDetails>(problemDetails.ProblemDetails);
problemDetails.ProblemDetails.Title.Should().Be("Path.NotFound");
problemDetails.ProblemDetails.Detail.Should().Be("The requested path was not found.");
problemDetails.ProblemDetails.Status.Should().Be(StatusCodes.Status404NotFound);
problemDetails.ProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc9110#section-15.5.5");
problemDetails.ProblemDetails.Extensions["traceId"].Should().NotBeNull();
Assert.Equal("Path.NotFound", problemDetails.ProblemDetails.Title);
Assert.Equal("The requested path was not found.", problemDetails.ProblemDetails.Detail);
Assert.Equal(StatusCodes.Status404NotFound, problemDetails.ProblemDetails.Status);
Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.5", problemDetails.ProblemDetails.Type);
Assert.NotNull(problemDetails.ProblemDetails.Extensions["traceId"]);
}
[Fact]
@@ -100,22 +98,16 @@ public class CombinePathEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
result.Should().BeOfType<ProblemHttpResult>();
ProblemHttpResult problemDetails = (ProblemHttpResult)result;
problemDetails.StatusCode.Should().Be(StatusCodes.Status422UnprocessableEntity);
problemDetails.ContentType.Should().Be("application/problem+json");
problemDetails.ProblemDetails.Should().BeOfType<HttpValidationProblemDetails>();
HttpValidationProblemDetails validationProblemDetails = (HttpValidationProblemDetails)problemDetails.ProblemDetails;
validationProblemDetails.Status.Should().Be(StatusCodes.Status422UnprocessableEntity);
validationProblemDetails.Title.Should().Be("General.Validation");
validationProblemDetails.Detail.Should().Be("OneOrMoreValidationErrorsOccurred");
validationProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2");
validationProblemDetails.Errors.Should().ContainSingle()
.Which.Should().BeEquivalentTo(new
{
Key = "Path.Invalid",
Value = new[] { "The provided path is invalid." }
});
ProblemHttpResult problemDetails = Assert.IsType<ProblemHttpResult>(result);
Assert.Equal(StatusCodes.Status422UnprocessableEntity, problemDetails.StatusCode);
Assert.Equal("application/problem+json", problemDetails.ContentType);
HttpValidationProblemDetails validationProblemDetails = Assert.IsType<HttpValidationProblemDetails>(problemDetails.ProblemDetails);
Assert.Equal(StatusCodes.Status422UnprocessableEntity, validationProblemDetails.Status);
Assert.Equal("General.Validation", validationProblemDetails.Title);
Assert.Equal("OneOrMoreValidationErrorsOccurred", validationProblemDetails.Detail);
Assert.Equal("https://tools.ietf.org/html/rfc4918#section-11.2", validationProblemDetails.Type);
Assert.Single(validationProblemDetails.Errors);
Assert.Equal(new[] { "The provided path is invalid." }, validationProblemDetails.Errors["Path.Invalid"]);
}
[Fact]
@@ -1,7 +1,6 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FastEndpoints;
using FluentAssertions;
using Lumina.Application.Core.FileSystemManagement.Paths.Queries.GetPathParent;
using Lumina.Contracts.Requests.FileSystemManagement.Path;
using Lumina.Contracts.Responses.FileSystemManagement.Path;
@@ -57,8 +56,8 @@ public class GetPathParentEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
IEnumerable<PathSegmentResponse> actualResponse = result.Should().BeOfType<Ok<IEnumerable<PathSegmentResponse>>>().Subject.Value!;
actualResponse.Should().BeEquivalentTo(expectedResponse);
Ok<IEnumerable<PathSegmentResponse>> okResult = Assert.IsType<Ok<IEnumerable<PathSegmentResponse>>>(result);
Assert.Equal(expectedResponse, okResult.Value);
}
[Fact]
@@ -75,17 +74,16 @@ public class GetPathParentEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
result.Should().BeOfType<ProblemHttpResult>();
ProblemHttpResult problemDetails = (ProblemHttpResult)result;
problemDetails.StatusCode.Should().Be(StatusCodes.Status404NotFound);
problemDetails.ContentType.Should().Be("application/problem+json");
problemDetails.ProblemDetails.Should().BeOfType<Microsoft.AspNetCore.Mvc.ProblemDetails>();
ProblemHttpResult problemDetails = Assert.IsType<ProblemHttpResult>(result);
Assert.Equal(StatusCodes.Status404NotFound, problemDetails.StatusCode);
Assert.Equal("application/problem+json", problemDetails.ContentType);
Assert.IsType<Microsoft.AspNetCore.Mvc.ProblemDetails>(problemDetails.ProblemDetails);
problemDetails.ProblemDetails.Title.Should().Be("Path.NotFound");
problemDetails.ProblemDetails.Detail.Should().Be("The requested path was not found.");
problemDetails.ProblemDetails.Status.Should().Be(StatusCodes.Status404NotFound);
problemDetails.ProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc9110#section-15.5.5");
problemDetails.ProblemDetails.Extensions["traceId"].Should().NotBeNull();
Assert.Equal("Path.NotFound", problemDetails.ProblemDetails.Title);
Assert.Equal("The requested path was not found.", problemDetails.ProblemDetails.Detail);
Assert.Equal(StatusCodes.Status404NotFound, problemDetails.ProblemDetails.Status);
Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.5", problemDetails.ProblemDetails.Type);
Assert.NotNull(problemDetails.ProblemDetails.Extensions["traceId"]);
}
[Fact]
@@ -102,22 +100,16 @@ public class GetPathParentEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
result.Should().BeOfType<ProblemHttpResult>();
ProblemHttpResult problemDetails = (ProblemHttpResult)result;
problemDetails.StatusCode.Should().Be(StatusCodes.Status422UnprocessableEntity);
problemDetails.ContentType.Should().Be("application/problem+json");
problemDetails.ProblemDetails.Should().BeOfType<HttpValidationProblemDetails>();
HttpValidationProblemDetails validationProblemDetails = (HttpValidationProblemDetails)problemDetails.ProblemDetails;
validationProblemDetails.Status.Should().Be(StatusCodes.Status422UnprocessableEntity);
validationProblemDetails.Title.Should().Be("General.Validation");
validationProblemDetails.Detail.Should().Be("OneOrMoreValidationErrorsOccurred");
validationProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2");
validationProblemDetails.Errors.Should().ContainSingle()
.Which.Should().BeEquivalentTo(new
{
Key = "Path.Invalid",
Value = new[] { "The provided path is invalid." }
});
ProblemHttpResult problemDetails = Assert.IsType<ProblemHttpResult>(result);
Assert.Equal(StatusCodes.Status422UnprocessableEntity, problemDetails.StatusCode);
Assert.Equal("application/problem+json", problemDetails.ContentType);
HttpValidationProblemDetails validationProblemDetails = Assert.IsType<HttpValidationProblemDetails>(problemDetails.ProblemDetails);
Assert.Equal(StatusCodes.Status422UnprocessableEntity, validationProblemDetails.Status);
Assert.Equal("General.Validation", validationProblemDetails.Title);
Assert.Equal("OneOrMoreValidationErrorsOccurred", validationProblemDetails.Detail);
Assert.Equal("https://tools.ietf.org/html/rfc4918#section-11.2", validationProblemDetails.Type);
Assert.Single(validationProblemDetails.Errors);
Assert.Equal(new[] { "The provided path is invalid." }, validationProblemDetails.Errors["Path.Invalid"]);
}
[Fact]
@@ -1,7 +1,6 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FastEndpoints;
using FluentAssertions;
using Lumina.Application.Core.FileSystemManagement.Paths.Queries.GetPathRoot;
using Lumina.Contracts.Requests.FileSystemManagement.Path;
using Lumina.Contracts.Responses.FileSystemManagement.Path;
@@ -55,8 +54,8 @@ public class GetPathRootEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
PathSegmentResponse actualResponse = result.Should().BeOfType<Ok<PathSegmentResponse>>().Subject.Value!;
actualResponse.Should().BeEquivalentTo(expectedResponse);
Ok<PathSegmentResponse> okResult = Assert.IsType<Ok<PathSegmentResponse>>(result);
Assert.Equal(expectedResponse, okResult.Value);
}
[Fact]
@@ -73,17 +72,16 @@ public class GetPathRootEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
result.Should().BeOfType<ProblemHttpResult>();
ProblemHttpResult problemDetails = (ProblemHttpResult)result;
problemDetails.StatusCode.Should().Be(StatusCodes.Status404NotFound);
problemDetails.ContentType.Should().Be("application/problem+json");
problemDetails.ProblemDetails.Should().BeOfType<Microsoft.AspNetCore.Mvc.ProblemDetails>();
ProblemHttpResult problemDetails = Assert.IsType<ProblemHttpResult>(result);
Assert.Equal(StatusCodes.Status404NotFound, problemDetails.StatusCode);
Assert.Equal("application/problem+json", problemDetails.ContentType);
Assert.IsType<Microsoft.AspNetCore.Mvc.ProblemDetails>(problemDetails.ProblemDetails);
problemDetails.ProblemDetails.Title.Should().Be("Path.NotFound");
problemDetails.ProblemDetails.Detail.Should().Be("The requested path was not found.");
problemDetails.ProblemDetails.Status.Should().Be(StatusCodes.Status404NotFound);
problemDetails.ProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc9110#section-15.5.5");
problemDetails.ProblemDetails.Extensions["traceId"].Should().NotBeNull();
Assert.Equal("Path.NotFound", problemDetails.ProblemDetails.Title);
Assert.Equal("The requested path was not found.", problemDetails.ProblemDetails.Detail);
Assert.Equal(StatusCodes.Status404NotFound, problemDetails.ProblemDetails.Status);
Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.5", problemDetails.ProblemDetails.Type);
Assert.NotNull(problemDetails.ProblemDetails.Extensions["traceId"]);
}
[Fact]
@@ -100,22 +98,16 @@ public class GetPathRootEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
result.Should().BeOfType<ProblemHttpResult>();
ProblemHttpResult problemDetails = (ProblemHttpResult)result;
problemDetails.StatusCode.Should().Be(StatusCodes.Status422UnprocessableEntity);
problemDetails.ContentType.Should().Be("application/problem+json");
problemDetails.ProblemDetails.Should().BeOfType<HttpValidationProblemDetails>();
HttpValidationProblemDetails validationProblemDetails = (HttpValidationProblemDetails)problemDetails.ProblemDetails;
validationProblemDetails.Status.Should().Be(StatusCodes.Status422UnprocessableEntity);
validationProblemDetails.Title.Should().Be("General.Validation");
validationProblemDetails.Detail.Should().Be("OneOrMoreValidationErrorsOccurred");
validationProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2");
validationProblemDetails.Errors.Should().ContainSingle()
.Which.Should().BeEquivalentTo(new
{
Key = "Path.Invalid",
Value = new[] { "The provided path is invalid." }
});
ProblemHttpResult problemDetails = Assert.IsType<ProblemHttpResult>(result);
Assert.Equal(StatusCodes.Status422UnprocessableEntity, problemDetails.StatusCode);
Assert.Equal("application/problem+json", problemDetails.ContentType);
HttpValidationProblemDetails validationProblemDetails = Assert.IsType<HttpValidationProblemDetails>(problemDetails.ProblemDetails);
Assert.Equal(StatusCodes.Status422UnprocessableEntity, validationProblemDetails.Status);
Assert.Equal("General.Validation", validationProblemDetails.Title);
Assert.Equal("OneOrMoreValidationErrorsOccurred", validationProblemDetails.Detail);
Assert.Equal("https://tools.ietf.org/html/rfc4918#section-11.2", validationProblemDetails.Type);
Assert.Single(validationProblemDetails.Errors);
Assert.Equal(new[] { "The provided path is invalid." }, validationProblemDetails.Errors["Path.Invalid"]);
}
[Fact]
@@ -1,6 +1,5 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using FluentAssertions;
using Lumina.Application.Core.FileSystemManagement.Paths.Queries.GetPathSeparator;
using Lumina.Contracts.Responses.FileSystemManagement.Path;
using Lumina.Presentation.Api.Core.Endpoints.FileSystemManagement.Path.GetPathSeparator;
@@ -50,8 +49,8 @@ public class GetPathSeparatorEndpointTests
IResult result = await _sut.ExecuteAsync(cancellationToken);
// Assert
PathSeparatorResponse actualResponse = result.Should().BeOfType<Ok<PathSeparatorResponse>>().Subject.Value!;
actualResponse.Should().BeEquivalentTo(expectedResponse);
Ok<PathSeparatorResponse> okResult = Assert.IsType<Ok<PathSeparatorResponse>>(result);
Assert.Equal(expectedResponse, okResult.Value);
}
[Fact]
@@ -1,7 +1,6 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FastEndpoints;
using FluentAssertions;
using Lumina.Application.Core.FileSystemManagement.Paths.Commands.SplitPath;
using Lumina.Contracts.Requests.FileSystemManagement.Path;
using Lumina.Contracts.Responses.FileSystemManagement.Path;
@@ -57,8 +56,8 @@ public class SplitPathEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
IEnumerable<PathSegmentResponse> actualResponse = result.Should().BeOfType<Ok<IEnumerable<PathSegmentResponse>>>().Subject.Value!;
actualResponse.Should().BeEquivalentTo(expectedResponse);
Ok<IEnumerable<PathSegmentResponse>> okResult = Assert.IsType<Ok<IEnumerable<PathSegmentResponse>>>(result);
Assert.Equal(expectedResponse, okResult.Value);
}
[Fact]
@@ -75,22 +74,17 @@ public class SplitPathEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
result.Should().BeOfType<ProblemHttpResult>();
ProblemHttpResult problemDetails = (ProblemHttpResult)result;
problemDetails.StatusCode.Should().Be(StatusCodes.Status422UnprocessableEntity);
problemDetails.ContentType.Should().Be("application/problem+json");
problemDetails.ProblemDetails.Should().BeOfType<HttpValidationProblemDetails>();
HttpValidationProblemDetails validationProblemDetails = (HttpValidationProblemDetails)problemDetails.ProblemDetails;
validationProblemDetails.Status.Should().Be(StatusCodes.Status422UnprocessableEntity);
validationProblemDetails.Title.Should().Be("General.Validation");
validationProblemDetails.Detail.Should().Be("OneOrMoreValidationErrorsOccurred");
validationProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2");
validationProblemDetails.Errors.Should().ContainSingle()
.Which.Should().BeEquivalentTo(new
{
Key = "Path.Invalid",
Value = new[] { "The provided path is invalid." }
});
ProblemHttpResult problemDetails = Assert.IsType<ProblemHttpResult>(result);
Assert.Equal(StatusCodes.Status422UnprocessableEntity, problemDetails.StatusCode);
Assert.Equal("application/problem+json", problemDetails.ContentType);
HttpValidationProblemDetails validationProblemDetails = Assert.IsType<HttpValidationProblemDetails>(problemDetails.ProblemDetails);
Assert.Equal(StatusCodes.Status422UnprocessableEntity, validationProblemDetails.Status);
Assert.Equal("General.Validation", validationProblemDetails.Title);
Assert.Equal("OneOrMoreValidationErrorsOccurred", validationProblemDetails.Detail);
Assert.Equal("https://tools.ietf.org/html/rfc4918#section-11.2", validationProblemDetails.Type);
Assert.Single(validationProblemDetails.Errors);
Assert.Equal(new[] { "The provided path is invalid." }, validationProblemDetails.Errors["Path.Invalid"]);
Assert.NotNull(problemDetails.ProblemDetails.Extensions["traceId"]);
}
[Fact]
@@ -1,6 +1,5 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using FluentAssertions;
using Lumina.Application.Core.FileSystemManagement.Paths.Queries.ValidatePath;
using Lumina.Contracts.Requests.FileSystemManagement.Path;
using Lumina.Contracts.Responses.FileSystemManagement.Path;
@@ -52,8 +51,8 @@ public class ValidatePathEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
PathValidResponse actualResponse = result.Should().BeOfType<Ok<PathValidResponse>>().Subject.Value!;
actualResponse.Should().BeEquivalentTo(expectedResponse);
Ok<PathValidResponse> okResult = Assert.IsType<Ok<PathValidResponse>>(result);
Assert.Equal(expectedResponse, okResult.Value);
}
[Fact]
@@ -1,7 +1,6 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FastEndpoints;
using FluentAssertions;
using Lumina.Application.Core.FileSystemManagement.Thumbnails.Queries.GetThumbnail;
using Lumina.Contracts.Requests.FileSystemManagement.Thumbnails;
using Lumina.Contracts.Responses.FileSystemManagement.Thumbnails;
@@ -54,9 +53,9 @@ public class GetThumbnailEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
FileContentHttpResult fileResult = result.Should().BeOfType<FileContentHttpResult>().Subject;
fileResult.FileContents.ToArray().Should().BeEquivalentTo(expectedResponse.Bytes);
fileResult.ContentType.Should().Be(MimeTypes.GetMimeType(expectedResponse.Type));
FileContentHttpResult fileResult = Assert.IsType<FileContentHttpResult>(result);
Assert.Equal(expectedResponse.Bytes, fileResult.FileContents.ToArray());
Assert.Equal(MimeTypes.GetMimeType(expectedResponse.Type), fileResult.ContentType);
}
[Fact]
@@ -73,17 +72,16 @@ public class GetThumbnailEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
result.Should().BeOfType<ProblemHttpResult>();
ProblemHttpResult problemDetails = (ProblemHttpResult)result;
problemDetails.StatusCode.Should().Be(StatusCodes.Status404NotFound);
problemDetails.ContentType.Should().Be("application/problem+json");
problemDetails.ProblemDetails.Should().BeOfType<Microsoft.AspNetCore.Mvc.ProblemDetails>();
ProblemHttpResult problemDetails = Assert.IsType<ProblemHttpResult>(result);
Assert.Equal(StatusCodes.Status404NotFound, problemDetails.StatusCode);
Assert.Equal("application/problem+json", problemDetails.ContentType);
Assert.IsType<Microsoft.AspNetCore.Mvc.ProblemDetails>(problemDetails.ProblemDetails);
problemDetails.ProblemDetails.Title.Should().Be("Thumbnail.NotFound");
problemDetails.ProblemDetails.Detail.Should().Be("The requested thumbnail was not found.");
problemDetails.ProblemDetails.Status.Should().Be(StatusCodes.Status404NotFound);
problemDetails.ProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc9110#section-15.5.5");
problemDetails.ProblemDetails.Extensions["traceId"].Should().NotBeNull();
Assert.Equal("Thumbnail.NotFound", problemDetails.ProblemDetails.Title);
Assert.Equal("The requested thumbnail was not found.", problemDetails.ProblemDetails.Detail);
Assert.Equal(StatusCodes.Status404NotFound, problemDetails.ProblemDetails.Status);
Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.5", problemDetails.ProblemDetails.Type);
Assert.NotNull(problemDetails.ProblemDetails.Extensions["traceId"]);
}
[Fact]
@@ -100,22 +98,16 @@ public class GetThumbnailEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
result.Should().BeOfType<ProblemHttpResult>();
ProblemHttpResult problemDetails = (ProblemHttpResult)result;
problemDetails.StatusCode.Should().Be(StatusCodes.Status422UnprocessableEntity);
problemDetails.ContentType.Should().Be("application/problem+json");
problemDetails.ProblemDetails.Should().BeOfType<HttpValidationProblemDetails>();
HttpValidationProblemDetails validationProblemDetails = (HttpValidationProblemDetails)problemDetails.ProblemDetails;
validationProblemDetails.Status.Should().Be(StatusCodes.Status422UnprocessableEntity);
validationProblemDetails.Title.Should().Be("General.Validation");
validationProblemDetails.Detail.Should().Be("OneOrMoreValidationErrorsOccurred");
validationProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2");
validationProblemDetails.Errors.Should().ContainSingle()
.Which.Should().BeEquivalentTo(new
{
Key = "Path.Invalid",
Value = new[] { "The provided path is invalid." }
});
ProblemHttpResult problemDetails = Assert.IsType<ProblemHttpResult>(result);
Assert.Equal(StatusCodes.Status422UnprocessableEntity, problemDetails.StatusCode);
Assert.Equal("application/problem+json", problemDetails.ContentType);
HttpValidationProblemDetails validationProblemDetails = Assert.IsType<HttpValidationProblemDetails>(problemDetails.ProblemDetails);
Assert.Equal(StatusCodes.Status422UnprocessableEntity, validationProblemDetails.Status);
Assert.Equal("General.Validation", validationProblemDetails.Title);
Assert.Equal("OneOrMoreValidationErrorsOccurred", validationProblemDetails.Detail);
Assert.Equal("https://tools.ietf.org/html/rfc4918#section-11.2", validationProblemDetails.Type);
Assert.Single(validationProblemDetails.Errors);
Assert.Equal(new[] { "The provided path is invalid." }, validationProblemDetails.Errors["Path.Invalid"]);
}
[Fact]
@@ -1,6 +1,5 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using FluentAssertions;
using Lumina.Application.Core.Maintenance.ApplicationSetup.Queries.CheckInitialization;
using Lumina.Contracts.Responses.UsersManagement;
using Lumina.Presentation.Api.Core.Endpoints.Maintenance.ApplicationSetup;
@@ -47,8 +46,8 @@ public class CheckInitializationEndpointTests
IResult result = await _sut.ExecuteAsync(new EmptyRequest(), cancellationToken);
// Assert
InitializationResponse actualResponse = result.Should().BeOfType<Ok<InitializationResponse>>().Subject.Value!;
actualResponse.Should().BeEquivalentTo(expectedResponse);
Ok<InitializationResponse> okResult = Assert.IsType<Ok<InitializationResponse>>(result);
Assert.Equal(expectedResponse, okResult.Value);
}
[Fact]
@@ -1,7 +1,6 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FastEndpoints;
using FluentAssertions;
using Lumina.Application.Core.Maintenance.ApplicationSetup.Commands.SetupApplication;
using Lumina.Application.Core.Maintenance.ApplicationSetup.Queries.CheckInitialization;
using Lumina.Contracts.Requests.Authentication;
@@ -55,9 +54,9 @@ public class SetupApplicationEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
Created<RegistrationResponse> createdResult = result.Should().BeOfType<Created<RegistrationResponse>>().Subject;
createdResult.Value.Should().BeEquivalentTo(expectedResponse);
createdResult.Location.Should().EndWith(expectedResponse.Id.ToString());
Created<RegistrationResponse> createdResult = Assert.IsType<Created<RegistrationResponse>>(result);
Assert.Equal(expectedResponse, createdResult.Value);
Assert.EndsWith(expectedResponse.Id.ToString(), createdResult.Location);
}
[Fact]
@@ -74,17 +73,16 @@ public class SetupApplicationEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
result.Should().BeOfType<ProblemHttpResult>();
ProblemHttpResult problemDetails = (ProblemHttpResult)result;
problemDetails.StatusCode.Should().Be(StatusCodes.Status409Conflict);
problemDetails.ContentType.Should().Be("application/problem+json");
problemDetails.ProblemDetails.Should().BeOfType<Microsoft.AspNetCore.Mvc.ProblemDetails>();
ProblemHttpResult problemDetails = Assert.IsType<ProblemHttpResult>(result);
Assert.Equal(StatusCodes.Status409Conflict, problemDetails.StatusCode);
Assert.Equal("application/problem+json", problemDetails.ContentType);
Assert.IsType<Microsoft.AspNetCore.Mvc.ProblemDetails>(problemDetails.ProblemDetails);
problemDetails.ProblemDetails.Title.Should().Be("Registration.Failed");
problemDetails.ProblemDetails.Detail.Should().Be("The application is already initialized.");
problemDetails.ProblemDetails.Status.Should().Be(StatusCodes.Status409Conflict);
problemDetails.ProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc9110#section-15.5.10");
problemDetails.ProblemDetails.Extensions["traceId"].Should().NotBeNull();
Assert.Equal("Registration.Failed", problemDetails.ProblemDetails.Title);
Assert.Equal("The application is already initialized.", problemDetails.ProblemDetails.Detail);
Assert.Equal(StatusCodes.Status409Conflict, problemDetails.ProblemDetails.Status);
Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.10", problemDetails.ProblemDetails.Type);
Assert.NotNull(problemDetails.ProblemDetails.Extensions["traceId"]);
}
[Fact]
@@ -1,7 +1,6 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FastEndpoints;
using FluentAssertions;
using Lumina.Application.Core.UsersManagement.Authentication.Commands.ChangePassword;
using Lumina.Contracts.Requests.Authentication;
using Lumina.Contracts.Responses.Authentication;
@@ -53,8 +52,8 @@ public class ChangePasswordEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
Ok<ChangePasswordResponse> okResult = result.Should().BeOfType<Ok<ChangePasswordResponse>>().Subject;
okResult.Value.Should().BeEquivalentTo(expectedResponse);
Ok<ChangePasswordResponse> okResult = Assert.IsType<Ok<ChangePasswordResponse>>(result);
Assert.Equal(expectedResponse, okResult.Value);
}
[Fact]
@@ -71,21 +70,15 @@ public class ChangePasswordEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
result.Should().BeOfType<ProblemHttpResult>();
ProblemHttpResult problemDetails = (ProblemHttpResult)result;
problemDetails.StatusCode.Should().Be(StatusCodes.Status422UnprocessableEntity);
problemDetails.ContentType.Should().Be("application/problem+json");
problemDetails.ProblemDetails.Should().BeOfType<HttpValidationProblemDetails>();
HttpValidationProblemDetails validationProblemDetails = (HttpValidationProblemDetails)problemDetails.ProblemDetails;
validationProblemDetails.Status.Should().Be(StatusCodes.Status422UnprocessableEntity);
validationProblemDetails.Title.Should().Be("General.Validation");
validationProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2");
validationProblemDetails.Errors.Should().ContainSingle()
.Which.Should().BeEquivalentTo(new
{
Key = "Password.Invalid",
Value = new[] { "The current password is incorrect." }
});
ProblemHttpResult problemDetails = Assert.IsType<ProblemHttpResult>(result);
Assert.Equal(StatusCodes.Status422UnprocessableEntity, problemDetails.StatusCode);
Assert.Equal("application/problem+json", problemDetails.ContentType);
HttpValidationProblemDetails validationProblemDetails = Assert.IsType<HttpValidationProblemDetails>(problemDetails.ProblemDetails);
Assert.Equal(StatusCodes.Status422UnprocessableEntity, validationProblemDetails.Status);
Assert.Equal("General.Validation", validationProblemDetails.Title);
Assert.Equal("https://tools.ietf.org/html/rfc4918#section-11.2", validationProblemDetails.Type);
Assert.Single(validationProblemDetails.Errors);
Assert.Equal(new[] { "The current password is incorrect." }, validationProblemDetails.Errors["Password.Invalid"]);
}
[Fact]
@@ -1,7 +1,6 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FastEndpoints;
using FluentAssertions;
using Lumina.Application.Core.UsersManagement.Authentication.Queries.GetUsers;
using Lumina.Contracts.Responses.UsersManagement.Users;
using Lumina.Presentation.Api.Core.Endpoints.UsersManagement.Authentication.GetUsers;
@@ -51,8 +50,8 @@ public class GetUsersEndpointTests
IResult result = await _sut.ExecuteAsync(new EmptyRequest(), cancellationToken);
// Assert
Ok<IEnumerable<UserResponse>> okResult = result.Should().BeOfType<Ok<IEnumerable<UserResponse>>>().Subject;
okResult.Value.Should().BeEquivalentTo(expectedResponse);
Ok<IEnumerable<UserResponse>> okResult = Assert.IsType<Ok<IEnumerable<UserResponse>>>(result);
Assert.Equal(expectedResponse, okResult.Value);
}
[Fact]
@@ -68,16 +67,16 @@ public class GetUsersEndpointTests
IResult result = await _sut.ExecuteAsync(new EmptyRequest(), cancellationToken);
// Assert
ProblemHttpResult problemResult = result.Should().BeOfType<ProblemHttpResult>().Subject;
problemResult.StatusCode.Should().Be(StatusCodes.Status403Forbidden);
problemResult.ContentType.Should().Be("application/problem+json");
problemResult.ProblemDetails.Should().BeOfType<Microsoft.AspNetCore.Mvc.ProblemDetails>();
ProblemHttpResult problemResult = Assert.IsType<ProblemHttpResult>(result);
Assert.Equal(StatusCodes.Status403Forbidden, problemResult.StatusCode);
Assert.Equal("application/problem+json", problemResult.ContentType);
Assert.IsType<Microsoft.AspNetCore.Mvc.ProblemDetails>(problemResult.ProblemDetails);
problemResult.ProblemDetails.Title.Should().Be("Users.NotFound");
problemResult.ProblemDetails.Detail.Should().Be("No users found.");
problemResult.ProblemDetails.Status.Should().Be(StatusCodes.Status403Forbidden);
problemResult.ProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc9110#section-15.5.4");
problemResult.ProblemDetails.Extensions["traceId"].Should().NotBeNull();
Assert.Equal("Users.NotFound", problemResult.ProblemDetails.Title);
Assert.Equal("No users found.", problemResult.ProblemDetails.Detail);
Assert.Equal(StatusCodes.Status403Forbidden, problemResult.ProblemDetails.Status);
Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.4", problemResult.ProblemDetails.Type);
Assert.NotNull(problemResult.ProblemDetails.Extensions["traceId"]);
}
[Fact]
@@ -1,7 +1,6 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FastEndpoints;
using FluentAssertions;
using Lumina.Application.Core.UsersManagement.Authentication.Queries.LoginUser;
using Lumina.Contracts.Requests.Authentication;
using Lumina.Contracts.Responses.Authentication;
@@ -53,8 +52,8 @@ public class LoginEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
Ok<LoginResponse> okResult = result.Should().BeOfType<Ok<LoginResponse>>().Subject;
okResult.Value.Should().BeEquivalentTo(expectedResponse);
Ok<LoginResponse> okResult = Assert.IsType<Ok<LoginResponse>>(result);
Assert.Equal(expectedResponse, okResult.Value);
}
[Fact]
@@ -71,21 +70,15 @@ public class LoginEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
result.Should().BeOfType<ProblemHttpResult>();
ProblemHttpResult problemDetails = (ProblemHttpResult)result;
problemDetails.StatusCode.Should().Be(StatusCodes.Status422UnprocessableEntity);
problemDetails.ContentType.Should().Be("application/problem+json");
problemDetails.ProblemDetails.Should().BeOfType<HttpValidationProblemDetails>();
HttpValidationProblemDetails validationProblemDetails = (HttpValidationProblemDetails)problemDetails.ProblemDetails;
validationProblemDetails.Status.Should().Be(StatusCodes.Status422UnprocessableEntity);
validationProblemDetails.Title.Should().Be("General.Validation");
validationProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2");
validationProblemDetails.Errors.Should().ContainSingle()
.Which.Should().BeEquivalentTo(new
{
Key = "Login.Failed",
Value = new[] { "Invalid username or password." }
});
ProblemHttpResult problemDetails = Assert.IsType<ProblemHttpResult>(result);
Assert.Equal(StatusCodes.Status422UnprocessableEntity, problemDetails.StatusCode);
Assert.Equal("application/problem+json", problemDetails.ContentType);
HttpValidationProblemDetails validationProblemDetails = Assert.IsType<HttpValidationProblemDetails>(problemDetails.ProblemDetails);
Assert.Equal(StatusCodes.Status422UnprocessableEntity, validationProblemDetails.Status);
Assert.Equal("General.Validation", validationProblemDetails.Title);
Assert.Equal("https://tools.ietf.org/html/rfc4918#section-11.2", validationProblemDetails.Type);
Assert.Single(validationProblemDetails.Errors);
Assert.Equal(new[] { "Invalid username or password." }, validationProblemDetails.Errors["Login.Failed"]);
}
[Fact]
@@ -1,7 +1,6 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FastEndpoints;
using FluentAssertions;
using Lumina.Application.Core.UsersManagement.Authentication.Commands.RecoverPassword;
using Lumina.Contracts.Requests.Authentication;
using Lumina.Contracts.Responses.Authentication;
@@ -53,8 +52,8 @@ public class RecoverPasswordEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
Ok<RecoverPasswordResponse> okResult = result.Should().BeOfType<Ok<RecoverPasswordResponse>>().Subject;
okResult.Value.Should().BeEquivalentTo(expectedResponse);
Ok<RecoverPasswordResponse> okResult = Assert.IsType<Ok<RecoverPasswordResponse>>(result);
Assert.Equal(expectedResponse, okResult.Value);
}
[Fact]
@@ -71,21 +70,15 @@ public class RecoverPasswordEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
result.Should().BeOfType<ProblemHttpResult>();
ProblemHttpResult problemDetails = (ProblemHttpResult)result;
problemDetails.StatusCode.Should().Be(StatusCodes.Status422UnprocessableEntity);
problemDetails.ContentType.Should().Be("application/problem+json");
problemDetails.ProblemDetails.Should().BeOfType<HttpValidationProblemDetails>();
HttpValidationProblemDetails validationProblemDetails = (HttpValidationProblemDetails)problemDetails.ProblemDetails;
validationProblemDetails.Status.Should().Be(StatusCodes.Status422UnprocessableEntity);
validationProblemDetails.Title.Should().Be("General.Validation");
validationProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2");
validationProblemDetails.Errors.Should().ContainSingle()
.Which.Should().BeEquivalentTo(new
{
Key = "Recovery.Failed",
Value = new[] { "Invalid username or TOTP code." }
});
ProblemHttpResult problemDetails = Assert.IsType<ProblemHttpResult>(result);
Assert.Equal(StatusCodes.Status422UnprocessableEntity, problemDetails.StatusCode);
Assert.Equal("application/problem+json", problemDetails.ContentType);
HttpValidationProblemDetails validationProblemDetails = Assert.IsType<HttpValidationProblemDetails>(problemDetails.ProblemDetails);
Assert.Equal(StatusCodes.Status422UnprocessableEntity, validationProblemDetails.Status);
Assert.Equal("General.Validation", validationProblemDetails.Title);
Assert.Equal("https://tools.ietf.org/html/rfc4918#section-11.2", validationProblemDetails.Type);
Assert.Single(validationProblemDetails.Errors);
Assert.Equal(new[] { "Invalid username or TOTP code." }, validationProblemDetails.Errors["Recovery.Failed"]);
}
[Fact]
@@ -1,7 +1,6 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FastEndpoints;
using FluentAssertions;
using Lumina.Application.Core.UsersManagement.Authentication.Commands.RegisterUser;
using Lumina.Contracts.Requests.Authentication;
using Lumina.Contracts.Responses.Authentication;
@@ -53,9 +52,9 @@ public class RegisterEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
Created<RegistrationResponse> createdResult = result.Should().BeOfType<Created<RegistrationResponse>>().Subject;
createdResult.Value.Should().BeEquivalentTo(expectedResponse);
createdResult.Location.Should().EndWith(expectedResponse.Id.ToString());
Created<RegistrationResponse> createdResult = Assert.IsType<Created<RegistrationResponse>>(result);
Assert.Equal(expectedResponse, createdResult.Value);
Assert.EndsWith(expectedResponse.Id.ToString(), createdResult.Location);
}
[Fact]
@@ -72,21 +71,15 @@ public class RegisterEndpointTests
IResult result = await _sut. ExecuteAsync(request, cancellationToken);
// Assert
result.Should().BeOfType<ProblemHttpResult>();
ProblemHttpResult problemDetails = (ProblemHttpResult)result;
problemDetails.StatusCode.Should().Be(StatusCodes.Status422UnprocessableEntity);
problemDetails.ContentType.Should().Be("application/problem+json");
problemDetails.ProblemDetails.Should().BeOfType<HttpValidationProblemDetails>();
HttpValidationProblemDetails validationProblemDetails = (HttpValidationProblemDetails)problemDetails.ProblemDetails;
validationProblemDetails.Status.Should().Be(StatusCodes.Status422UnprocessableEntity);
validationProblemDetails.Title.Should().Be("General.Validation");
validationProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc4918#section-11.2");
validationProblemDetails.Errors.Should().ContainSingle()
.Which.Should().BeEquivalentTo(new
{
Key = "Registration.Failed",
Value = new[] { "Username is already taken." }
});
ProblemHttpResult problemDetails = Assert.IsType<ProblemHttpResult>(result);
Assert.Equal(StatusCodes.Status422UnprocessableEntity, problemDetails.StatusCode);
Assert.Equal("application/problem+json", problemDetails.ContentType);
HttpValidationProblemDetails validationProblemDetails = Assert.IsType<HttpValidationProblemDetails>(problemDetails.ProblemDetails);
Assert.Equal(StatusCodes.Status422UnprocessableEntity, validationProblemDetails.Status);
Assert.Equal("General.Validation", validationProblemDetails.Title);
Assert.Equal("https://tools.ietf.org/html/rfc4918#section-11.2", validationProblemDetails.Type);
Assert.Single(validationProblemDetails.Errors);
Assert.Equal(new[] { "Username is already taken." }, validationProblemDetails.Errors["Registration.Failed"]);
}
[Fact]
@@ -1,7 +1,6 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FastEndpoints;
using FluentAssertions;
using Lumina.Application.Core.UsersManagement.Authorization.Queries.GetAuthorization;
using Lumina.Contracts.Requests.Authorization;
using Lumina.Contracts.Responses.Authorization;
@@ -58,8 +57,8 @@ public class GetAuthorizationEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
AuthorizationResponse actualResponse = result.Should().BeOfType<Ok<AuthorizationResponse>>().Subject.Value!;
actualResponse.Should().BeEquivalentTo(expectedResponse);
Ok<AuthorizationResponse> okResult = Assert.IsType<Ok<AuthorizationResponse>>(result);
Assert.Equal(expectedResponse, okResult.Value);
}
[Fact]
@@ -77,16 +76,16 @@ public class GetAuthorizationEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
ProblemHttpResult problemDetails = result.Should().BeOfType<ProblemHttpResult>().Subject;
problemDetails.StatusCode.Should().Be(StatusCodes.Status403Forbidden);
problemDetails.ContentType.Should().Be("application/problem+json");
problemDetails.ProblemDetails.Should().BeOfType<Microsoft.AspNetCore.Mvc.ProblemDetails>();
ProblemHttpResult problemDetails = Assert.IsType<ProblemHttpResult>(result);
Assert.Equal(StatusCodes.Status403Forbidden, problemDetails.StatusCode);
Assert.Equal("application/problem+json", problemDetails.ContentType);
Assert.IsType<Microsoft.AspNetCore.Mvc.ProblemDetails>(problemDetails.ProblemDetails);
problemDetails.ProblemDetails.Title.Should().Be("Authorization.Failed");
problemDetails.ProblemDetails.Detail.Should().Be("User is not authorized.");
problemDetails.ProblemDetails.Status.Should().Be(StatusCodes.Status403Forbidden);
problemDetails.ProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc9110#section-15.5.4");
problemDetails.ProblemDetails.Extensions["traceId"].Should().NotBeNull();
Assert.Equal("Authorization.Failed", problemDetails.ProblemDetails.Title);
Assert.Equal("User is not authorized.", problemDetails.ProblemDetails.Detail);
Assert.Equal(StatusCodes.Status403Forbidden, problemDetails.ProblemDetails.Status);
Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.4", problemDetails.ProblemDetails.Type);
Assert.NotNull(problemDetails.ProblemDetails.Extensions["traceId"]);
}
[Fact]
@@ -1,7 +1,6 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FastEndpoints;
using FluentAssertions;
using Lumina.Application.Core.UsersManagement.Authorization.Queries.GetUserPermissions;
using Lumina.Contracts.Requests.Authorization;
using Lumina.Contracts.Responses.Authorization;
@@ -56,8 +55,8 @@ public class GetUserPermissionsEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
Ok<IEnumerable<PermissionResponse>> okResult = result.Should().BeOfType<Ok<IEnumerable<PermissionResponse>>>().Subject;
okResult.Value.Should().BeEquivalentTo(expectedResponse);
Ok<IEnumerable<PermissionResponse>> okResult = Assert.IsType<Ok<IEnumerable<PermissionResponse>>>(result);
Assert.Equal(expectedResponse, okResult.Value);
}
[Fact]
@@ -74,16 +73,16 @@ public class GetUserPermissionsEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
ProblemHttpResult problemResult = result.Should().BeOfType<ProblemHttpResult>().Subject;
problemResult.StatusCode.Should().Be(StatusCodes.Status403Forbidden);
problemResult.ContentType.Should().Be("application/problem+json");
problemResult.ProblemDetails.Should().BeOfType<Microsoft.AspNetCore.Mvc.ProblemDetails>();
ProblemHttpResult problemResult = Assert.IsType<ProblemHttpResult>(result);
Assert.Equal(StatusCodes.Status403Forbidden, problemResult.StatusCode);
Assert.Equal("application/problem+json", problemResult.ContentType);
Assert.IsType<Microsoft.AspNetCore.Mvc.ProblemDetails>(problemResult.ProblemDetails);
problemResult.ProblemDetails.Title.Should().Be("User.Permissions.NotFound");
problemResult.ProblemDetails.Detail.Should().Be("User permissions not found.");
problemResult.ProblemDetails.Status.Should().Be(StatusCodes.Status403Forbidden);
problemResult.ProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc9110#section-15.5.4");
problemResult.ProblemDetails.Extensions["traceId"].Should().NotBeNull();
Assert.Equal("User.Permissions.NotFound", problemResult.ProblemDetails.Title);
Assert.Equal("User permissions not found.", problemResult.ProblemDetails.Detail);
Assert.Equal(StatusCodes.Status403Forbidden, problemResult.ProblemDetails.Status);
Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.4", problemResult.ProblemDetails.Type);
Assert.NotNull(problemResult.ProblemDetails.Extensions["traceId"]);
}
[Fact]
@@ -1,7 +1,6 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FastEndpoints;
using FluentAssertions;
using Lumina.Application.Core.UsersManagement.Authorization.Queries.GetUserRole;
using Lumina.Contracts.Requests.Authorization;
using Lumina.Contracts.Responses.Authorization;
@@ -50,8 +49,8 @@ public class GetUserRoleEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
Ok<RoleResponse> okResult = result.Should().BeOfType<Ok<RoleResponse>>().Subject;
okResult.Value.Should().BeEquivalentTo(expectedResponse);
Ok<RoleResponse> okResult = Assert.IsType<Ok<RoleResponse>>(result);
Assert.Equal(expectedResponse, okResult.Value);
}
[Fact]
@@ -68,16 +67,16 @@ public class GetUserRoleEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
ProblemHttpResult problemResult = result.Should().BeOfType<ProblemHttpResult>().Subject;
problemResult.StatusCode.Should().Be(StatusCodes.Status403Forbidden);
problemResult.ContentType.Should().Be("application/problem+json");
problemResult.ProblemDetails.Should().BeOfType<Microsoft.AspNetCore.Mvc.ProblemDetails>();
ProblemHttpResult problemResult = Assert.IsType<ProblemHttpResult>(result);
Assert.Equal(StatusCodes.Status403Forbidden, problemResult.StatusCode);
Assert.Equal("application/problem+json", problemResult.ContentType);
Assert.IsType<Microsoft.AspNetCore.Mvc.ProblemDetails>(problemResult.ProblemDetails);
problemResult.ProblemDetails.Title.Should().Be("User.Role.NotFound");
problemResult.ProblemDetails.Detail.Should().Be("User role not found.");
problemResult.ProblemDetails.Status.Should().Be(StatusCodes.Status403Forbidden);
problemResult.ProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc9110#section-15.5.4");
problemResult.ProblemDetails.Extensions["traceId"].Should().NotBeNull();
Assert.Equal("User.Role.NotFound", problemResult.ProblemDetails.Title);
Assert.Equal("User role not found.", problemResult.ProblemDetails.Detail);
Assert.Equal(StatusCodes.Status403Forbidden, problemResult.ProblemDetails.Status);
Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.4", problemResult.ProblemDetails.Type);
Assert.NotNull(problemResult.ProblemDetails.Extensions["traceId"]);
}
[Fact]
@@ -1,7 +1,6 @@
#region ========================================================================= USING =====================================================================================
using ErrorOr;
using FastEndpoints;
using FluentAssertions;
using Lumina.Application.Core.UsersManagement.Authorization.Commands.UpdateUserRoleAndPermissions;
using Lumina.Contracts.Requests.Authorization;
using Lumina.Contracts.Responses.Authorization;
@@ -61,8 +60,8 @@ public class UpdateUserRoleAndPermissionsEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
Ok<AuthorizationResponse> okResult = result.Should().BeOfType<Ok<AuthorizationResponse>>().Subject;
okResult.Value.Should().BeEquivalentTo(expectedResponse);
Ok<AuthorizationResponse> okResult = Assert.IsType<Ok<AuthorizationResponse>>(result);
Assert.Equal(expectedResponse, okResult.Value);
}
[Fact]
@@ -83,16 +82,16 @@ public class UpdateUserRoleAndPermissionsEndpointTests
IResult result = await _sut.ExecuteAsync(request, cancellationToken);
// Assert
ProblemHttpResult problemResult = result.Should().BeOfType<ProblemHttpResult>().Subject;
problemResult.StatusCode.Should().Be(StatusCodes.Status403Forbidden);
problemResult.ContentType.Should().Be("application/problem+json");
problemResult.ProblemDetails.Should().BeOfType<Microsoft.AspNetCore.Mvc.ProblemDetails>();
ProblemHttpResult problemResult = Assert.IsType<ProblemHttpResult>(result);
Assert.Equal(StatusCodes.Status403Forbidden, problemResult.StatusCode);
Assert.Equal("application/problem+json", problemResult.ContentType);
Assert.IsType<Microsoft.AspNetCore.Mvc.ProblemDetails>(problemResult.ProblemDetails);
problemResult.ProblemDetails.Title.Should().Be("Authorization.Update.Failed");
problemResult.ProblemDetails.Detail.Should().Be("Failed to update user role and permissions.");
problemResult.ProblemDetails.Status.Should().Be(StatusCodes.Status403Forbidden);
problemResult.ProblemDetails.Type.Should().Be("https://tools.ietf.org/html/rfc9110#section-15.5.4");
problemResult.ProblemDetails.Extensions["traceId"].Should().NotBeNull();
Assert.Equal("Authorization.Update.Failed", problemResult.ProblemDetails.Title);
Assert.Equal("Failed to update user role and permissions.", problemResult.ProblemDetails.Detail);
Assert.Equal(StatusCodes.Status403Forbidden, problemResult.ProblemDetails.Status);
Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.4", problemResult.ProblemDetails.Type);
Assert.NotNull(problemResult.ProblemDetails.Extensions["traceId"]);
}
[Fact]
@@ -24,7 +24,6 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="FluentAssertions" Version="7.0.0-alpha.5" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="NSubstitute" Version="5.3.0" />