public MirrorMessage <T> Handle(T message) { TestMessageRecorder.Processed(GetType().Name, message, _envelope.ReceivedAt); return(new MirrorMessage <T> { Id = message.Id }); }
public IEnumerable <object> Handle(T message) { TestMessageRecorder.Processed(GetType().Name, message, _envelope.ReplyUri); yield return(new TR1 { Id = message.Id }); yield return(new TR2 { Id = message.Id }); yield return(new TR3 { Id = message.Id }); }
public void Handle(T message) { TestMessageRecorder.Processed(GetType().Name, message, _envelope.ReceivedAt); }
internal void Execute(IScenarioWriter writer) { TraceListener[] listeners = new TraceListener[Debug.Listeners.Count]; Debug.Listeners.CopyTo(listeners, 0); Debug.Listeners.Clear(); FubuTransport.SetupForInMemoryTesting(); InMemoryQueueManager.ClearAll(); TestMessageRecorder.Clear(); MessageHistory.ClearAll(); _configurations.Each(x => x.SpinUp()); writer.WriteTitle(Title); using (writer.Indent()) { writeArrangement(writer); writer.WriteLine("Actions"); using (writer.Indent()) { _steps.Each(x => { x.PreviewAct(writer); try { x.Act(writer); } catch (Exception e) { writer.Exception(e); } }); } var success = Wait.Until(() => { return(!MessageHistory.Outstanding().Any()); }, timeoutInMilliseconds: 60000); Debug.Listeners.AddRange(listeners); if (success) { writer.WriteLine("Messages are all accounted for"); } else { writer.WriteLine("Messages are outstanding:"); MessageHistory.Outstanding().Each(x => Debug.WriteLine(x)); } writer.BlankLine(); _configurations.Each(x => x.SafeDispose()); writer.WriteLine("Assertions"); using (writer.Indent()) { _steps.Each(x => { x.PreviewAssert(writer); x.Assert(writer); }); } writer.BlankLine(); if (TestMessageRecorder.AllProcessed.Any()) { writer.WriteLine("Messages Received"); TestMessageRecorder.AllProcessed.Each(x => { writer.Bullet("{0} received by {1}", x.Message.GetType().Name, x.Message.Source); }); } else { writer.WriteLine("No messages were received!"); } var unexpectedMessages = TestMessageRecorder.AllProcessed.Where(x => !_steps.Any(step => step.MatchesSentMessage(x.Message))) .ToArray(); if (unexpectedMessages.Any()) { writer.BlankLine(); writer.WriteLine("Found unexpected messages"); unexpectedMessages.Each(x => writer.Failure(x.ToString())); } } }