GreenMessage TriggerFailingHandler(IReceiverNode receiverNode) { receiverNode.Register(new Binding().Handle<IColourMessage>().With<FailingColourHandler>()); var message = new GreenMessage(); var senderNode = ObjectFactory.GetInstance<ISenderNode>(); senderNode.SendMessage(message); Assert.That(FailingColourHandler.AutoResetEvent.WaitOne(LongInterval)); Thread.Sleep(100); return message; }
public void Should_not_trigger_any_event_hooks_when_hooks_have_been_cleared() { MessagingSystem.Events.ClearEventHooks(); using (node_factory.Listen(_=>_.Handle<IColourMessage>().With<ColourMessageHandler>())) { var message = new GreenMessage(); senderNode.SendMessage(message); ColourMessageHandler.AutoResetEvent.WaitOne(ShortInterval); Assert.That(WaitingHookOne.SentEvent.WaitOne(ShortInterval), Is.False, "Hook one didn't get sent event"); Assert.That(WaitingHookOne.ReceivedEvent.WaitOne(ShortInterval), Is.False, "Hook one didn't get received event"); Assert.That(WaitingHookTwo.SentEvent.WaitOne(ShortInterval), Is.False, "Hook one didn't get sent event"); Assert.That(WaitingHookTwo.ReceivedEvent.WaitOne(ShortInterval), Is.False, "Hook one didn't get received event"); } }
public void Should_trigger_all_event_hooks_with_message_when_sending_and_receiving_a_message() { MessagingSystem.Events .AddEventHook<FailingHook>() .AddEventHook<SucceedingHook>(); using (node_factory.Listen(_=>_.Handle<IColourMessage>().With<ColourMessageHandler>())) { var message = new GreenMessage(); senderNode.SendMessage(message); ColourMessageHandler.AutoResetEvent.WaitOne(ShortInterval); Assert.That(SucceedingHook.SentEvent.WaitOne(ShortInterval), Is.True, "Hook one didn't get sent event"); Assert.That(SucceedingHook.ReceivedEvent.WaitOne(ShortInterval), Is.True, "Hook one didn't get received event"); } }
public void Sent_and_received_messages_should_be_equal() { using (node_factory.Listen(_=>_.Handle<IColourMessage>().With<ColourMessageHandler>())) { var message = new GreenMessage(); senderNode.SendMessage(message); ColourMessageHandler.AutoResetEvent.WaitOne(LongInterval); HoldingEventHook.AutoResetEvent.WaitOne(ShortInterval); var sent = (IColourMessage)event_hook.sent; var received = (IColourMessage)event_hook.received; Assert.That(sent, Is.Not.Null, "sent message was null"); Assert.That(received, Is.Not.Null, "received message was null"); Assert.That(sent.CorrelationId, Is.EqualTo(received.CorrelationId)); Assert.That(sent.Text, Is.EqualTo(received.Text)); } }