public UnmatchingScenarioStatementException(ScenarioStatements scenarioStatements, ScenarioStatements stepsStatements) : this(scenarioStatements, stepsStatements, string.Format( AlertMessages.StatamentXFromFeatureDoesNotMatchStatementYFromStepsType, scenarioStatements.Given, scenarioStatements.When, scenarioStatements.Then, stepsStatements.Given, stepsStatements.When, stepsStatements.Then)) { this.ScenarioStatements = scenarioStatements; }
public ScenarioStatements MakeTreatedStatements() { var statements = new ScenarioStatements() { Given = this.Statements.Given.ToStatementName(), When = this.Statements.When.ToStatementName(), Then = this.Statements.Then.ToStatementName(), }; return statements; }
private ScenarioStatements GetStatementsFromMethod(Type stepsType) { var allMethods = stepsType.GetMethods().ToArray(); var methodsGiven = null as MethodInfo; var methodsWhen = null as MethodInfo; var methodsThen = null as MethodInfo; try { methodsGiven = allMethods.Where(d => d.GetCustomAttribute<GivenAttribute>() != null).SingleOrDefault(); methodsWhen = allMethods.Where(d => d.GetCustomAttribute<WhenAttribute>() != null).SingleOrDefault(); methodsThen = allMethods.Where(d => d.GetCustomAttribute<ThenAttribute>() != null).SingleOrDefault(); } catch (Exception inner) { throw new MoreThanOneStatementOfAStatementTypeInScenarioStepsException( stepsType.Name, inner); } var scenario = new ScenarioStatements() { @Given = this.GetStatementFromExpressionAttribute(methodsGiven), @When = this.GetStatementFromExpressionAttribute(methodsWhen), @Then = this.GetStatementFromExpressionAttribute(methodsThen), }; return scenario; }
public UnmatchingScenarioStatementException(ScenarioStatements scenarioStatements, ScenarioStatements stepsStatements, string message, Exception inner) : base(message, inner) { this.ScenarioStatements = scenarioStatements; this.StepsStatements = stepsStatements; }
public UnmatchingScenarioStatementException(ScenarioStatements scenarioStatements, ScenarioStatements stepsStatements, string message) : this(scenarioStatements, stepsStatements, message, null) { }