-
-
Notifications
You must be signed in to change notification settings - Fork 122
/
end_to_end_with_conventional_routing.cs
69 lines (57 loc) · 2.08 KB
/
end_to_end_with_conventional_routing.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
using JasperFx.Core;
using Microsoft.Extensions.Hosting;
using Shouldly;
using TestingSupport;
using Wolverine.Tracking;
using Xunit;
namespace Wolverine.AzureServiceBus.Tests.ConventionalRouting.Broadcasting;
public class end_to_end_with_conventional_routing : IDisposable
{
private readonly IHost _receiver;
private readonly IHost _sender;
public end_to_end_with_conventional_routing()
{
_sender = WolverineHost.For(opts =>
{
opts.UseAzureServiceBusTesting().UseTopicAndSubscriptionConventionalRouting().AutoProvision().AutoPurgeOnStartup();
opts.DisableConventionalDiscovery();
opts.ServiceName = "Sender";
});
_receiver = WolverineHost.For(opts =>
{
#region sample_using_topic_and_subscription_conventional_routing_with_azure_service_bus
opts.UseAzureServiceBusTesting()
.UseTopicAndSubscriptionConventionalRouting(convention =>
{
// Optionally control every aspect of the convention and
// its applicability to types
// as well as overriding any listener, sender, topic, or subscription
// options
})
.AutoProvision()
.AutoPurgeOnStartup();
#endregion
opts.ServiceName = "Receiver";
});
}
public void Dispose()
{
_sender?.Dispose();
_receiver?.Dispose();
}
[Fact]
public async Task send_from_one_node_to_another_all_with_conventional_routing()
{
var session = await _sender.TrackActivity()
.AlsoTrack(_receiver)
.IncludeExternalTransports()
.Timeout(30.Seconds())
.SendMessageAndWaitAsync(new Routed2Message());
var received = session
.AllRecordsInOrder()
.Where(x => x.Envelope.Message?.GetType() == typeof(Routed2Message))
.Single(x => x.MessageEventType == MessageEventType.Received);
received
.ServiceName.ShouldBe("Receiver");
}
}