WIP
This commit is contained in:
parent
54b057886c
commit
7fc1ae0650
204 changed files with 4345 additions and 134 deletions
37
PlanTempus.Tests/CommandQueryHandlerTests/HandlerTest.cs
Normal file
37
PlanTempus.Tests/CommandQueryHandlerTests/HandlerTest.cs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
using Autofac;
|
||||
using Insight.Database;
|
||||
using PlanTempus.Components;
|
||||
using PlanTempus.Components.Accounts.Create;
|
||||
using PlanTempus.Core.CommandQueries;
|
||||
using PlanTempus.Core.Database;
|
||||
using PlanTempus.Core.Database.ConnectionFactory;
|
||||
using Shouldly;
|
||||
namespace PlanTempus.X.TDD.CommandQueryHandlerTests;
|
||||
|
||||
[TestClass]
|
||||
public class HandlerTest : TestFixture
|
||||
{
|
||||
[TestInitialize]
|
||||
public void This()
|
||||
{
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task ShouldResolveCommandHandlerAndDispatchToGenericCommandHandler()
|
||||
{
|
||||
var commandHandler = Container.Resolve<ICommandHandler>();
|
||||
commandHandler.ShouldBeOfType<CommandHandler>();
|
||||
|
||||
var command = new CreateAccountCommand
|
||||
{
|
||||
Email = $"{GetRandomWord()}@dumbanddumber.com5", // Lloyd Christmas
|
||||
Password = "1234AceVentura#LOL", // Ace Ventura
|
||||
IsActive = true,
|
||||
CorrelationId = Guid.NewGuid()
|
||||
};
|
||||
|
||||
var result = await commandHandler.Handle(command);
|
||||
|
||||
result.ShouldNotBeNull();
|
||||
}
|
||||
}
|
||||
53
PlanTempus.Tests/CommandQueryHandlerTests/ResponseTests.cs
Normal file
53
PlanTempus.Tests/CommandQueryHandlerTests/ResponseTests.cs
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
using Newtonsoft.Json;
|
||||
using PlanTempus.Core.CommandQueries;
|
||||
using Shouldly;
|
||||
|
||||
namespace PlanTempus.X.TDD.CommandQueryHandlerTests;
|
||||
|
||||
[TestClass]
|
||||
public class ProblemDetailsTests
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestFormatOfProblemDetails()
|
||||
{
|
||||
// Arrange
|
||||
var problemDetails = new ProblemDetails
|
||||
{
|
||||
Type = "https://example.com/errors/invalid-input",
|
||||
Title = "Invalid Input",
|
||||
Status = 400,
|
||||
Detail = "The request body is invalid.",
|
||||
Instance = "/api/users"
|
||||
};
|
||||
|
||||
problemDetails.AddExtension("invalidFields", new[]
|
||||
{
|
||||
new { Field = "name", Message = "The 'name' field is required." },
|
||||
new { Field = "email", Message = "The 'email' field must be a valid email address." }
|
||||
});
|
||||
|
||||
var json = JsonConvert.SerializeObject(problemDetails, Formatting.Indented);
|
||||
|
||||
var expectedJson = """
|
||||
{
|
||||
"Type": "https://example.com/errors/invalid-input",
|
||||
"Title": "Invalid Input",
|
||||
"Status": 400,
|
||||
"Detail": "The request body is invalid.",
|
||||
"Instance": "/api/users",
|
||||
"invalidFields": [
|
||||
{
|
||||
"Field": "name",
|
||||
"Message": "The 'name' field is required."
|
||||
},
|
||||
{
|
||||
"Field": "email",
|
||||
"Message": "The 'email' field must be a valid email address."
|
||||
}
|
||||
]
|
||||
}
|
||||
""";
|
||||
|
||||
JsonConvert.DeserializeObject(json).ShouldBeSameAs(JsonConvert.DeserializeObject(expectedJson));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue