示例#1
0
        public void get_template_for_the_method_if_no_attribute_is_found()
        {
            var dooer = new Dooer();
            ActionMethodGrammar action = ActionMethodGrammar.Create(x => x.DoSomethingWith(null, 34), dooer);

            action.Template.ShouldEqual("DoSomethingWith {name}, {age}");
        }
        public void creates_grammar_structure()
        {
            var dooer = new Dooer();
            ActionMethodGrammar action = ActionMethodGrammar.Create(x => x.DoSomethingWith2(null, 34), dooer);
            MethodInfo method = ReflectionHelper.GetMethod<Dooer>(x => x.DoSomethingWith2(null, 34));

            var sentence = action.ToStructure(new FixtureLibrary()).ShouldBeOfType<Sentence>();
            sentence.ShouldEqual(Sentence.For(method.GetTemplate(), Cell.For<string>("name"), Cell.For<int>("age")));
        }
示例#3
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);
        }
示例#4
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);
        }
示例#5
0
        public void creates_grammar_structure()
        {
            var dooer = new Dooer();
            ActionMethodGrammar action = ActionMethodGrammar.Create(x => x.DoSomethingWith2(null, 34), dooer);
            MethodInfo          method = ReflectionHelper.GetMethod <Dooer>(x => x.DoSomethingWith2(null, 34));


            var sentence = action.ToStructure(new FixtureLibrary()).ShouldBeOfType <Sentence>();

            sentence.ShouldEqual(Sentence.For(method.GetTemplate(), Cell.For <string>("name"), Cell.For <int>("age")));
        }
示例#6
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);
        }
示例#7
0
        public void ignores_Testcontext_and_non_simple_types_when_building_a_grammar_structure()
        {
            var dooer = new Dooer();
            ActionMethodGrammar action = ActionMethodGrammar.Create(
                x => x.DoSomethingUsingContextAndAddress(null, null, null), dooer);
            MethodInfo method =
                ReflectionHelper.GetMethod <Dooer>(x => x.DoSomethingUsingContextAndAddress(null, null, null));

            var      sentence = action.ToStructure(new FixtureLibrary()).ShouldBeOfType <Sentence>();
            Sentence expected = Sentence.For(method.GetTemplate(), Cell.For <string>("name"));

            sentence.ShouldEqual(expected);
        }
示例#8
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");
        }
示例#9
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");
        }
        public void get_template_for_the_method_if_no_attribute_is_found()
        {
            var dooer = new Dooer();
            ActionMethodGrammar action = ActionMethodGrammar.Create(x => x.DoSomethingWith(null, 34), dooer);

            action.Template.ShouldEqual("DoSomethingWith {name}, {age}");
        }
        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);
        }
        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");
        }
        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");
        }
        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);
        }
        public void ignores_Testcontext_and_non_simple_types_when_building_a_grammar_structure()
        {
            var dooer = new Dooer();
            ReflectionAction action = ReflectionAction.Create(
                x => x.DoSomethingUsingContextAndAddress(null, null, null), dooer);
            MethodInfo method =
                ReflectionHelper.GetMethod<Dooer>(x => x.DoSomethingUsingContextAndAddress(null, null, null));

            var sentence = action.ToStructure(new FixtureLibrary()).ShouldBeOfType<Sentence>();
            Sentence expected = Sentence.For(method.GetTemplate(), Cell.For<string>("name"));
            sentence.ShouldEqual(expected);
        }
        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);
        }
        public void get_template_for_the_method_if_attribute_is_found()
        {
            var dooer = new Dooer();
            ReflectionAction action = ReflectionAction.Create(x => x.DoSomethingWith2(null, 34), dooer);

            action.Template.ShouldEqual("{name} is {age}");
        }