Last active
March 15, 2024 14:32
-
-
Save mxmissile/e3471cb4549de0b38ba7aca314f8d09c to your computer and use it in GitHub Desktop.
Before With ProblemDetails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var builder = WebApplication.CreateBuilder(args); | |
builder.Host.UseWolverine(); | |
builder.Services.AddHttpContextAccessor(); | |
var app = builder.Build(); | |
app.MapWolverineEndpoints(); | |
app.Run(); | |
[TestClass] | |
public class BeforeTests | |
{ | |
[TestMethod] | |
public async Task spin_it_up() | |
{ | |
await using var host = await AlbaHost.For<Program>(); | |
var json = new TestMessage(); | |
await host.Scenario(x => | |
{ | |
x.Post.Json(json).ToUrl("/problem"); | |
x.StatusCodeShouldBe(200); | |
}); | |
} | |
} | |
public static class ProblemEndpoint | |
{ | |
[WolverinePost("/problem")] | |
public static async Task Post(TestMessage request, IMessageBus bus) => | |
await bus.InvokeAsync(request); | |
} | |
public record TestMessage; | |
[WolverineHandler] | |
public static class TestHandler | |
{ | |
public static ProblemDetails Before(TestMessage msg) | |
{ | |
return WolverineContinue.NoProblems; | |
} | |
public static void Handle(TestMessage msg) | |
{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment