public void DualSendMessageTest() { MessageBus bus = new MessageBus(); var singleSub = new MockSingleSubscriber(); bus.Subscribe(singleSub); var dualSub = new MockDualSubscriber(); bus.Subscribe(dualSub); StatusMsg statusMsg = new StatusMsg() { Text = "Test" }; bus.SendMessage(statusMsg); Assert.That(singleSub.StatusMsgs[0], Is.EqualTo(statusMsg)); Assert.That(dualSub.StatusMsgs[0], Is.EqualTo(statusMsg)); ResetMsg resetMsg = new ResetMsg() { Reason = "Test2" }; bus.SendMessage(resetMsg); Assert.That(singleSub.StatusMsgs.Count, Is.EqualTo(1)); Assert.That(dualSub.StatusMsgs.Count, Is.EqualTo(1)); Assert.That(dualSub.ResetMsgs.Count, Is.EqualTo(1)); }
public void SingleSendMessageTest() { MessageBus bus = new MessageBus(); var singleSub = new MockSingleSubscriber(); bus.Subscribe(singleSub); StatusMsg statusMsg = new StatusMsg() { Text = "Test" }; bus.SendMessage(statusMsg); Assert.That(singleSub.StatusMsgs.Count, Is.EqualTo(1)); Assert.That(singleSub.StatusMsgs[0], Is.EqualTo(statusMsg)); StatusMsg statusMsg2 = new StatusMsg() { Text = "Test2" }; bus.SendMessage(statusMsg2); Assert.That(singleSub.StatusMsgs.Count, Is.EqualTo(2)); Assert.That(singleSub.StatusMsgs[0], Is.EqualTo(statusMsg)); Assert.That(singleSub.StatusMsgs[1], Is.EqualTo(statusMsg2)); }
public void ExceptionSendMessageTest() { MessageBus bus = new MessageBus(); var failSubscriber = new FailSubscriber(); bus.Subscribe(failSubscriber); Exception e = null; bus.ExceptionRaised += (exception, o) => e = exception; StatusMsg statusMsg = new StatusMsg() { Text = "Test" }; bus.SendMessage(statusMsg); Assert.That(e, Is.Not.Null); Assert.That(e, Is.EqualTo(failSubscriber.Ex)); }