-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSagaTests.cs
48 lines (40 loc) · 1.04 KB
/
SagaTests.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
namespace Tests;
public class SagaTests
{
#region SagaTests
[Fact]
public async Task Run()
{
using var harness = new InMemoryTestHarness();
var sagaHarness = harness.Saga<ConsumerSaga>();
var correlationId = NewId.NextGuid();
await harness.Start();
try
{
await harness.Bus.Publish(new Start {CorrelationId = correlationId});
await harness.Consumed.Any<Start>();
await Verify(new {harness, sagaHarness});
}
finally
{
await harness.Stop();
}
}
public class ConsumerSaga :
ISaga,
InitiatedBy<Start>
{
public Guid CorrelationId { get; set; }
public bool StartMessageReceived { get; set; }
public Task Consume(ConsumeContext<Start> context)
{
StartMessageReceived = true;
return Task.CompletedTask;
}
}
public class Start : CorrelatedBy<Guid>
{
public Guid CorrelationId { get; init; }
}
#endregion
}