public void when_receiving_message_then_other_receivers_cannot_see_message_but_see_other_messages() { var secondReceiver = new TestableMessageReceiver(); this.sender.Send(new Message("message1")); this.sender.Send(new Message("message2")); var waitEvent = new AutoResetEvent(false); string receiver1Message = null; string receiver2Message = null; this.receiver.MessageReceived += (s, e) => { waitEvent.Set(); receiver1Message = e.Message.Body; waitEvent.WaitOne(); }; secondReceiver.MessageReceived += (s, e) => { receiver2Message = e.Message.Body; }; ThreadPool.QueueUserWorkItem(_ => { this.receiver.ReceiveMessage(); }); Assert.True(waitEvent.WaitOne(TimeSpan.FromSeconds(10))); secondReceiver.ReceiveMessage(); waitEvent.Set(); Assert.Equal("message1", receiver1Message); Assert.Equal("message2", receiver2Message); }
public void when_receiving_message_then_can_send_new_message() { var secondReceiver = new TestableMessageReceiver(this.connectionFactory); this.sender.Send(new Message("message1")); var waitEvent = new AutoResetEvent(false); string receiver1Message = null; string receiver2Message = null; this.receiver.MessageReceived += (s, e) => { waitEvent.Set(); receiver1Message = e.Message.Body; waitEvent.WaitOne(); }; secondReceiver.MessageReceived += (s, e) => { receiver2Message = e.Message.Body; }; ThreadPool.QueueUserWorkItem(_ => { this.receiver.ReceiveMessage(); }); Assert.IsTrue(waitEvent.WaitOne(TimeSpan.FromSeconds(10))); this.sender.Send(new Message("message2")); secondReceiver.ReceiveMessage(); waitEvent.Set(); Assert.IsTrue("message1" == receiver1Message); Assert.IsTrue("message2" == receiver2Message); }
public void when_receiving_message_then_can_send_new_message() { var secondReceiver = new TestableMessageReceiver(this.connectionFactory); this.sender.Send(new Message("message1")); var waitEvent = new AutoResetEvent(false); string receiver1Message = null; string receiver2Message = null; this.receiver.MessageReceived += (s, e) => { waitEvent.Set(); receiver1Message = e.Message.Body; waitEvent.WaitOne(); }; secondReceiver.MessageReceived += (s, e) => { receiver2Message = e.Message.Body; }; ThreadPool.QueueUserWorkItem(_ => { this.receiver.ReceiveMessage(); }); Assert.IsTrue(waitEvent.WaitOne(TimeSpan.FromSeconds(10))); this.sender.Send(new Message("message2")); secondReceiver.ReceiveMessage(); waitEvent.Set(); Assert.IsTrue("message1" == receiver1Message); Assert.IsTrue("message2" == receiver2Message); }
public void WhenReceivingMessageThenCanSendNewMessage() { var secondReceiver = new TestableMessageReceiver(this._connectionFactory); this._sender.Send(new Message("message1")); var waitEvent = new AutoResetEvent(false); string receiver1Message = null; string receiver2Message = null; this._receiver.MessageReceived += (s, e) => { waitEvent.Set(); receiver1Message = e.Message.Body; waitEvent.WaitOne(); }; secondReceiver.MessageReceived += (s, e) => { receiver2Message = e.Message.Body; }; ThreadPool.QueueUserWorkItem(_ => this._receiver.ReceiveMessage()); Assert.IsTrue(waitEvent.WaitOne(TimeSpan.FromSeconds(10))); this._sender.Send(new Message("message2")); secondReceiver.ReceiveMessage(); waitEvent.Set(); Assert.AreEqual("message1", receiver1Message); Assert.AreEqual("message2", receiver2Message); }