-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathInvokeDelegateUsage.cs
39 lines (33 loc) · 989 Bytes
/
InvokeDelegateUsage.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using VerifyTests.Wolverine;
using Wolverine;
// ReSharper disable ArrangeObjectCreationWhenTypeNotEvident
public class InvokeDelegateUsage
{
#region InvokeDelegateTest
[Fact]
public async Task HandlerTest()
{
var context = new RecordingMessageContext();
context.AddInvokeResult<Response>(
message =>
{
var request = (Request) message;
return new Response(request.Property);
});
var handler = new Handler(context);
await handler.Handle(new Message("value"));
await Verify(context);
}
#endregion
#region InvokeAsyncHandler
public class Handler(IMessageBus context)
{
public async Task Handle(Message message)
{
var request = new Request(message.Property);
var response = await context.InvokeAsync<Response>(request);
Trace.WriteLine(response.Property);
}
}
#endregion
}