public void Assert(IScenarioWriter writer) { if (!_completion.Wait(2000)) { writer.Failure("Did not get an acknowledgement in time"); } }
public void Assert(IScenarioWriter writer) { if (_completion.Wait(2000)) { var response = _completion.Result; if (response.Id != _request.Id) { writer.Failure("ResponseIdKey does not match the request"); } } else { writer.Failure("Did not get any response!"); } }
public void Assert(IScenarioWriter writer) { if (!_receiver.Received(new T { Id = _message.Message.Id })) { writer.Failure("Message {0} was not received by {1}", typeof(T).Name, _receiver.Name); } }
public void Assert(IScenarioWriter writer) { ReceivingNodes.Each(receiver => { if (!receiver.Received(Message)) { writer.Failure("Message {0} was not received by {1}", Message.GetType().Name, receiver.Name); } }); }
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())); } } }
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())); } } }