示例#1
0
 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;
 }
示例#2
0
        public ScenarioStatements MakeTreatedStatements()
        {
            var statements = new ScenarioStatements()
            {
                Given = this.Statements.Given.ToStatementName(),
                When = this.Statements.When.ToStatementName(),
                Then = this.Statements.Then.ToStatementName(),
            };

            return statements;
        }
示例#3
0
        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;
        }
示例#4
0
 public UnmatchingScenarioStatementException(ScenarioStatements scenarioStatements, ScenarioStatements stepsStatements, string message, Exception inner)
     : base(message, inner)
 {
     this.ScenarioStatements = scenarioStatements;
     this.StepsStatements = stepsStatements;
 }
示例#5
0
 public UnmatchingScenarioStatementException(ScenarioStatements scenarioStatements, ScenarioStatements stepsStatements, string message)
     : this(scenarioStatements, stepsStatements, message, null)
 {
 }