public Send ( IEnumerable |
||
messages | IEnumerable |
|
return | System.Threading.Tasks.Task |
public void WhenMultipleSubscribers_EachGetOwnMessage() { // arrange var client = CreateOutboundTransportMock(); // create two subscriptions for "mytopic" this.subscriptionStore.AddSubscription(new Subscription("mytopic", "e1", "c1")); this.subscriptionStore.AddSubscription(new Subscription("mytopic", "e2", "c2")); var bus = new MessageBus(this.subscriptionManager, client.Object, NullLoggerFactory.Instance); var message = new Message(new object(), "mytopic"); // act bus.Send(message); // assert // since multiple messages are to be sent, it should use the SendMultiple method client.Verify(b => b.Send(It.IsAny<TransportMessage>()), Times.Never); client.Verify(b => b.SendMultiple(It.Is<IEnumerable<TransportMessage>>(msgs => msgs.Count() == 2 && msgs.Count(m => m.Headers[MessageHeaders.Endpoint] == "e1" && m.Headers[MessageHeaders.Component] == "c1") == 1 && msgs.Count(m => m.Headers[MessageHeaders.Endpoint] == "e2" && m.Headers[MessageHeaders.Component] == "c2") == 1) ), Times.Once); }
public void WhenNoSubscribers_MessageIsNotSent() { // arrange var client = CreateOutboundTransportMock(); var bus = new MessageBus(this.subscriptionManager, client.Object, NullLoggerFactory.Instance); var message = new Message(new object(), "topic"); // act bus.Send(message); // assert client.Verify(b => b.Send(It.IsAny<TransportMessage>()), Times.Never); }