Exemple #1
0
        public void executing_with_an_exception_in_the_target_method_increments_the_exception_count()
        {
            var dooer = new Dooer();
            ActionMethodGrammar action = ActionMethodGrammar.Create(x => x.MethodThatThrowsException(), dooer);
            var step = new Step("a");

            action.Execute(step, _testContext);

            theCounts.Exceptions.ShouldEqual(1);
        }
Exemple #2
0
        public void execute_the_void_action_that_would_catch_an_exception()
        {
            var dooer = new Dooer();
            ActionMethodGrammar action = ActionMethodGrammar.Create(x => x.MethodThatThrowsException(), dooer);

            var step    = new Step();
            var results = action.Execute(step);

            results.Results.ExceptionText.ShouldContain("NotImplementedException");
            results.Counts.ShouldEqual(0, 0, 1, 0);
        }
Exemple #3
0
        public void execute_the_void_action_and_missing_an_argument()
        {
            var dooer = new Dooer();
            ActionMethodGrammar action = ActionMethodGrammar.Create(x => x.DoSomethingWith(null, 34), dooer);

            var step = new Step("something", x => { x.Set("name", "Josh"); });

            action.Execute(step, _testContext);

            _testContext.ResultsFor(step).ExceptionText.Contains("\"age\" is not defined.");
            theCounts.SyntaxErrors.ShouldEqual(1);
        }
Exemple #4
0
        public void execute_the_void_action_with_all_the_arguments()
        {
            var dooer = new Dooer();
            ActionMethodGrammar action = ActionMethodGrammar.Create(x => x.DoSomethingWith(null, 34), dooer);

            var step = new Step("something", x =>
            {
                x.Set("name", "Josh");
                x.Set("age", "32");
            });

            action.Execute(step, _testContext);

            dooer.Age.ShouldEqual(32);
            dooer.Name.ShouldEqual("Josh");
        }
Exemple #5
0
        public void execute_the_void_action_with_a_parse_error()
        {
            var dooer = new Dooer();
            ActionMethodGrammar action = ActionMethodGrammar.Create(x => x.DoSomethingWith(null, 34), dooer);

            var step = new Step("something", x =>
            {
                x.Set("name", "Josh");
                x.Set("age", "not a number");
            });

            action.Execute(step, _testContext);
            var results = _testContext.ResultsFor(step);

            results.ExceptionText.Contains("System.FormatException : Input string was not in a correct format");
            results.ExceptionText.Contains("\"age\" is malformed or invalid");
        }