-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Tests.cs
76 lines (68 loc) · 2.04 KB
/
Tests.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using VerifyTests.Wolverine;
using Wolverine;
// ReSharper disable ArrangeObjectCreationWhenTypeNotEvident
public class Tests
{
#region HandlerTest
[Fact]
public async Task HandlerTest()
{
var context = new RecordingMessageContext();
var handler = new Handler(context);
await handler.Handle(new Message("value"));
await Verify(context);
}
#endregion
[Fact]
public async Task AllTest()
{
var context = new RecordingMessageContext();
var handler = new AllHandler(context);
await handler.Handle(new Message("value"));
await Verify(context);
}
}
#region Handler
public class Handler(IMessageBus context)
{
public ValueTask Handle(Message message) =>
context.SendAsync(new Response("Property Value"));
}
#endregion
public class AllHandler(IMessageContext context)
{
public async ValueTask Handle(Message message)
{
await context.SendAsync(
new Response("Property Value"),
new DeliveryOptions
{
DeliverWithin = TimeSpan.FromDays(1)
});
await context.RespondToSenderAsync(
new Response("Property Value"));
await context.InvokeAsync(
new Response("Property Value"),
timeout: TimeSpan.FromDays(2));
await context.InvokeAsync<Guid>(
new Response("Property Value"),
timeout: TimeSpan.FromDays(2));
await context.BroadcastToTopicAsync(
"topic",
new Response("Property Value"),
new DeliveryOptions
{
DeliverWithin = TimeSpan.FromDays(3)
});
var destination = context.EndpointFor("endpoint");
await destination.SendAsync(
new Response("Property Value"),
new DeliveryOptions
{
DeliverWithin = TimeSpan.FromDays(1)
});
await destination.InvokeAsync(
new Response("Property Value"),
timeout: TimeSpan.FromDays(2));
}
}