public void can_wait_for_multiple_message_already_in_the_queue() { using (var tq = new TestQueue(_dispatcher)) { var evt = new TestEvent(); var evt2 = new TestEvent(); _dispatcher.Publish(evt); _dispatcher.Publish(evt2); tq.WaitForMsgId(evt.MsgId, TimeSpan.FromMilliseconds(200)); tq.WaitForMsgId(evt2.MsgId, TimeSpan.FromMilliseconds(200)); tq.AssertNext <TestEvent>(evt.CorrelationId) .AssertNext <TestEvent>(evt2.CorrelationId) .AssertEmpty(); } }
public void can_wait_for_a_specific_message_twice() { using (var tq = new TestQueue(_dispatcher)) { var evt = new TestEvent(); Task.Delay(50) .ContinueWith(_ => _dispatcher.Publish(evt)); Parallel.Invoke( () => tq.WaitForMsgId(evt.MsgId, TimeSpan.FromMilliseconds(200)), () => tq.WaitForMsgId(evt.MsgId, TimeSpan.FromMilliseconds(200)) ); tq.AssertNext <TestEvent>(evt.CorrelationId) .AssertEmpty(); } }
public void can_wait_for_multiple_messages_not_yet_recieved() { using (var tq = new TestQueue(_dispatcher)) { var evt = new TestEvent(); var evt2 = new TestEvent(); Task.Delay(50) .ContinueWith(_ => { _dispatcher.Publish(evt); _dispatcher.Publish(evt2); }); tq.WaitForMsgId(evt.MsgId, TimeSpan.FromMilliseconds(200)); tq.WaitForMsgId(evt2.MsgId, TimeSpan.FromMilliseconds(200)); tq.AssertNext <TestEvent>(evt.CorrelationId) .AssertNext <TestEvent>(evt2.CorrelationId) .AssertEmpty(); } }
public void can_timeout_waiting_for_message_with_wrong_id() { using (var tq = new TestQueue(_dispatcher, new[] { typeof(Event), typeof(Command) })) { var evt = new TestEvent(); _dispatcher.Publish(evt); Assert.Throws <TimeoutException>(() => tq.WaitForMsgId(Guid.NewGuid(), TimeSpan.FromMilliseconds(100))); tq.AssertNext <TestEvent>(evt.CorrelationId) .AssertEmpty(); } }