public 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) { OnSuccessfulRunReported(element); } else if (result == Result.Ignored) { OnIgnoredRunReported(element); } else { OnFailedRunReported(element); } resultRecorder.Record(result); } catch { OnFailedRunReported(element); resultRecorder.Record(Result.Failure); } }
private void AddToTestResults(IResultSummary singleResult, IResultRecorder resultSummary) { if (resultSummary == null) return; if (singleResult.HasExceptions) { resultSummary.Record(Result.Exception); } else if (singleResult.HasFailures) { resultSummary.Record(Result.Failure); } else { resultSummary.Record(Result.Success); } }
public 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 (m_comparer.Compare(actual, expected) == 0) { resultRecorder.Record(Result.Success); OnSuccessReported(element); } else { resultRecorder.Record(Result.Failure); OnFailureReported(element, actual, expected); } }
public override void Setup(CommandCall commandCall, IEvaluator evaluator, IResultRecorder resultRecorder) { try { m_command.Setup(commandCall, evaluator, resultRecorder); } catch (Exception e) { resultRecorder.Record(Result.Exception); AnnounceThrowableCaught(commandCall.Element, e, commandCall.Expression); } }
public override void Verify(CommandCall commandCall, IEvaluator evaluator, IResultRecorder resultRecorder) { try { m_command.Verify(commandCall, evaluator, resultRecorder); } catch (Exception e) { resultRecorder.Record(Result.Exception); OnExceptionCaught(commandCall.Element, e, commandCall.Expression); } }
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(); 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(); OnSurplusRow(detailRow.RowElement); } tableSupport.CopyCommandCallsTo(detailRow); commandCall.Children.Verify(evaluator, resultRecorder); index++; } for (; index < detailRows.Count; index++) { Row detailRow = detailRows[index]; resultRecorder.Record(Result.Failure); OnMissingRow(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) { AnnounceSuccess(element); } else if (result == Result.Ignored) { AnnounceIgnored(element); } else { AnnounceFailure(element); } resultRecorder.Record(result); } catch { AnnounceFailure(element); resultRecorder.Record(Result.Failure); } }
protected override void ProcessTrueResult(CommandCall commandCall, IResultRecorder resultRecorder) { resultRecorder.Record(Result.Success); AnnounceSuccess(commandCall.Element); }
protected override void ProcessFalseResult(CommandCall commandCall, IResultRecorder resultRecorder) { resultRecorder.Record(Result.Failure); string expected = commandCall.Element.Text; AnnounceFailure(commandCall.Element, expected, "== false"); }