public void check_response_handled() { var sampleMessage = new SampleTestCommand(10); sampleMessage.SetContextData(MessagesConstants.ReplyToHeader, "test"); _bus.Send(sampleMessage); var handled = _handler.Reset.WaitOne(10000); //cycle until we found handled message on tracking List<TrackedMessageModel> tracks = null; DateTime startTime = DateTime.Now; do { Thread.Sleep(50); tracks = _messages.FindAll().ToList(); } while ( tracks.Count < 2 && //command tracking and commandhandled tracking DateTime.Now.Subtract(startTime).TotalSeconds < 4 ); var track = tracks.Single(t => t.MessageId == sampleMessage.MessageId.ToString()); Assert.That(track.Description, Is.EqualTo(sampleMessage.Describe())); Assert.That(track.StartedAt, Is.Not.Null); Assert.That(track.CompletedAt, Is.Not.Null); var handledTrack = tracks.Single(t => t.MessageId != sampleMessage.MessageId.ToString()); CommandHandled commandHandled = (CommandHandled)handledTrack.Message; Assert.That(commandHandled.CommandId, Is.EqualTo(sampleMessage.MessageId)); Assert.That(handledTrack.Description, Is.StringContaining(sampleMessage.MessageId.ToString())); Assert.That(handledTrack.Description, Is.StringContaining("Handled!")); }
public void check_basic_tracking() { var sampleMessage = new SampleTestCommand(10); _bus.Send(sampleMessage); var handled = _handler.Reset.WaitOne(10000); //cycle until we found handled message on tracking TrackedMessageModel track = null; DateTime startTime = DateTime.Now; do { Thread.Sleep(50); var tracks = _messages.FindAll().ToList(); Assert.That(tracks, Has.Count.EqualTo(1)); track = tracks.Single(); } while ( track.CompletedAt == null && DateTime.Now.Subtract(startTime).TotalSeconds < 4 ); Assert.That(track.MessageId, Is.EqualTo(sampleMessage.MessageId.ToString())); Assert.That(track.Description, Is.EqualTo(sampleMessage.Describe())); Assert.That(track.StartedAt, Is.Not.Null); Assert.That(track.CompletedAt, Is.Not.Null); }