public void TestMultipleSubscribersAllReceivingTheMessage() { var subscriber1 = new TestSubscriber1(); var subscriber2 = new TestSubscriber1(); MessageBusOf <TestMessage1> .AcceptSubscriber(subscriber1); MessageBusOf <TestMessage1> .AcceptSubscriber(subscriber2); MessageBusOf <TestMessage1> .Receive(new TestMessage1()); Assert.IsTrue(subscriber1.handlerWasExecuted); Assert.IsTrue(subscriber2.handlerWasExecuted); }
public void TestMultipleBussesNotInterferingWithEachother() { var subscriber1 = new TestSubscriber1(); var subscriber2 = new TestSubscriber2(); MessageBusOf <TestMessage1> .AcceptSubscriber(subscriber1); MessageBusOf <TestMessage2> .AcceptSubscriber(subscriber2); MessageBusOf <TestMessage2> .Receive(new TestMessage2()); Assert.IsTrue(subscriber2.handlerWasExecuted); Assert.IsFalse(subscriber1.handlerWasExecuted); // reset sub2's status subscriber2.handlerWasExecuted = false; MessageBusOf <TestMessage1> .Receive(new TestMessage1()); Assert.IsFalse(subscriber2.handlerWasExecuted); Assert.IsTrue(subscriber1.handlerWasExecuted); }