internal void Preview(IScenarioWriter writer) { _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)); } writer.BlankLine(); writer.WriteLine("Assertions"); using (writer.Indent()) { _steps.Each(x => x.PreviewAssert(writer)); } } }
public void PreviewAssert(IScenarioWriter writer) { if (_message.Description.IsEmpty()) { writer.WriteLine("Expecting message of type {0} to be received by node {1} as a result of message of type {2} being handled", typeof(T).Name, _receiver.Name, _message.Message.GetType().Name); } else { writer.WriteLine("Expecting message of type {0} to be received by node {1} as a result of message of type {2} ({3}) being handled", typeof(T).Name, _receiver.Name, _message.Message.GetType().Name, _message.Description); } }
public void PreviewAct(IScenarioWriter writer) { if (_description.IsEmpty()) { writer.WriteLine("Node {0} sends new message of type {1}", _sender.Name, typeof(T).Name); } else { writer.WriteLine("Node {0} sends new message of type {1} ({2})", _sender.Name, typeof(T).Name, _description); } }
public void Describe(IScenarioWriter writer) { writer.WriteLine(Key); using (writer.Indent()) { if (Incoming) { writer.WriteLine("Listens to {0} with {1}", Uri, Scheduler); } Rules.Each(x => x.Describe()); } }
public void PreviewAssert(IScenarioWriter writer) { ReceivingNodes.Each(receiver => { if (_description.IsEmpty()) { writer.WriteLine("Message of type {0} should be received by {1}", typeof(T).Name, receiver.Name); } else { writer.WriteLine("Message of type {0} ({1}) should be received by {2}", typeof(T).Name, _description, receiver.Name); } }); }
internal void Describe(IScenarioWriter writer) { if (!_registry.IsValueCreated) { return; } writer.WriteLine(Name); var channels = _runtime.Factory.Get <ChannelGraph>(); using (writer.Indent()) { channels.Where(x => x.Incoming) .Each(x => writer.WriteLine("Listens to {0} with ", x.Uri, x.Scheduler)); //writer.BlankLine(); channels.Where(x => x.Rules.Any()).Each(x => { writer.WriteLine("Publishes to {0}", x.Key); using (writer.Indent()) { x.Rules.Each(rule => writer.Bullet(rule.Describe())); } }); var handlers = _runtime.Factory.Get <HandlerGraph>(); var inputs = handlers.Select(x => x.InputType()).Where(x => x != typeof(object[])); if (inputs.Any()) { writer.WriteLine("Handles " + inputs.Select(x => x.Name).Join(", ")); } _info.Each(x => writer.WriteLine(x)); writer.BlankLine(); } }
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())); } } }
public void PreviewAssert(IScenarioWriter writer) { writer.WriteLine("Expecting an acknowledgement for the message"); }
public void PreviewAct(IScenarioWriter writer) { writer.WriteLine("Node {0} sends and awaits an ack for request '{1}'", _sender.Name, typeof(TRequest).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())); } } }
public void PreviewAssert(IScenarioWriter writer) { writer.WriteLine("Expecting a reply of type {0} from node {1}", typeof(TReply).Name, _receiver.Name); }
public void PreviewAct(IScenarioWriter writer) { writer.WriteLine("Node {0} sends request '{1}' ({2}), expecting a matching response {3}", _sender.Name, _description, typeof(TRequest).Name, typeof(TReply).Name); }