protected override void ProcessFalseResult(CommandCall commandCall, IResultRecorder resultRecorder) { resultRecorder.Failure("expected true but was false", commandCall.Element.ToXml()); string expected = commandCall.Element.Text; AnnounceFailure(commandCall.Element, expected, "== false"); }
public void Verify(CommandCall commandCall, IEvaluator evaluator, IResultRecorder resultRecorder) { var pattern = new Regex("(#.+?) *: *(.+)"); var matcher = pattern.Match(commandCall.Expression); if (!matcher.Success) { throw new InvalidOperationException("The expression for a \"verifyRows\" should be of the form: #var : collectionExpr"); } var loopVariableName = matcher.Groups[1].Value; var iterableExpression = matcher.Groups[2].Value; var obj = evaluator.Evaluate(iterableExpression); Check.NotNull(obj, "Expression returned null (should be an IEnumerable)."); Check.IsTrue(obj is IEnumerable, obj.GetType() + " is not IEnumerable"); Check.IsTrue(!(obj is IDictionary), obj.GetType() + " does not have a predictable iteration order"); var iterable = (IEnumerable)obj; var tableSupport = new TableSupport(commandCall); var detailRows = tableSupport.GetDetailRows(); AnnounceExpressionEvaluated(commandCall.Element); int index = 0; foreach (var loopVar in iterable) { evaluator.SetVariable(loopVariableName, loopVar); Row detailRow; if (detailRows.Count > index) { detailRow = detailRows[index]; } else { detailRow = tableSupport.AddDetailRow(); AnnounceSurplusRow(detailRow.RowElement); } tableSupport.CopyCommandCallsTo(detailRow); commandCall.Children.Verify(evaluator, resultRecorder); index++; } for (; index < detailRows.Count; index++) { Row detailRow = detailRows[index]; resultRecorder.Failure(string.Format("missing row {0}", detailRow), commandCall.Element.ToXml()); AnnounceMissingRow(detailRow.RowElement); } }
public override void Execute(CommandCall commandCall, IEvaluator evaluator, IResultRecorder resultRecorder) { Check.IsFalse(commandCall.HasChildCommands, "Nesting commands inside a 'run' is not supported"); var element = commandCall.Element; var href = element.GetAttributeValue("href"); Check.NotNull(href, "The 'href' attribute must be set for an element containing concordion:run"); var runnerType = commandCall.Expression; var expression = element.GetAttributeValue("params", "concordion"); if (expression != null) { evaluator.Evaluate(expression); } try { IRunner concordionRunner; Runners.TryGetValue(runnerType, out concordionRunner); // TODO - re-check this. Check.NotNull(concordionRunner, "The runner '" + runnerType + "' cannot be found. " + "Choices: (1) Use 'concordion' as your runner (2) Ensure that the 'concordion.runner." + runnerType + "' System property is set to a name of an IRunner implementation " + "(3) Specify an assembly fully qualified class name of an IRunner implementation"); var result = concordionRunner.Execute(evaluator.Fixture, commandCall.Resource, href).Result; if (result == Result.Success) { resultRecorder.Success(); AnnounceSuccess(element); } else if (result == Result.Ignored) { resultRecorder.Ignore(); AnnounceIgnored(element); } else { resultRecorder.Failure(string.Format("test {0} failed", href), commandCall.Element.ToXml()); AnnounceFailure(element); } } catch (Exception e) { resultRecorder.Error(e); AnnounceError(e, element, expression); } }
public override void Verify(CommandCall commandCall, IEvaluator evaluator, IResultRecorder resultRecorder) { Check.IsFalse(commandCall.HasChildCommands, "Nesting commands inside an 'assertEquals' is not supported"); Element element = commandCall.Element; object actual = evaluator.Evaluate(commandCall.Expression); string expected = element.Text; if (this.m_Comparer.Compare(actual, expected) == 0) { resultRecorder.Success(); AnnounceSuccess(element); } else { resultRecorder.Failure(string.Format("expected {0} but was {1}", expected, actual), element.ToXml()); AnnounceFailure(element, expected, actual); } }