コード例 #1
0
        public void SetUp()
        {
            grammar =
                Fixture.VerifyStringList(() => { throw new NotImplementedException(); }).Titled(
                    "The list of strings should be").LeafNameIs("row").Grammar();

            step = new Step("anything").WithChildren("row", new Step(), new Step(), new Step());

            var context = new TestContext();

            grammar.Execute(step, context);
            counts = context.Counts;

            rowResults = context.ResultsFor(step).GetResult<IList<SetRow>>(grammar.LeafName);
            stepResults = context.ResultsFor(step);
        }
コード例 #2
0
        public void execute_successfully()
        {
            ReflectionAssertion assertion = ReflectionAssertion.Create(x => x.Success(), new AssertionFixture());
            var step = new Step();

            var context = new TestContext();

            assertion.Execute(step, context);
            context.Counts.ShouldEqual(1, 0, 0, 0);

            step.Get("returnValue").Parse<bool>().ShouldBeTrue();
            context.ResultsFor(step).ActualDisplay<bool>("returnValue").ShouldBeTrue();
        }
コード例 #3
0
        public void SetUp()
        {
            sentence = Sentence.For("{name} is {age}", Cell.For<string>("name"), Cell.For<int>("age"));
            step = new Step().With("name:Max,age:6");
            tag = new SentenceTag(sentence, step);

            context = new TestContext();
            StepResults results = context.ResultsFor(step);
            results.CaptureException("bad stuff");
            results.ExceptionText.ShouldEqual("bad stuff");

            tag.WriteResults(context);
        }
コード例 #4
0
ファイル: CellTester.cs プロジェクト: adymitruk/storyteller
        public void SetUp()
        {
            step = new Step("a").With("key1", "abc");
            cell = new Cell("key1", typeof (int));

            var context = new TestContext();
            cell.ReadArgument(context, step, x => Assert.Fail("should not have called me"));

            counts = context.Counts;
            results = context.ResultsFor(step);
        }
コード例 #5
0
ファイル: CellTester.cs プロジェクト: adymitruk/storyteller
        public void record_actual_stores_the_data()
        {
            MethodInfo method = ReflectionHelper.GetMethod<CellTarget>(x => x.Add(0, 0));
            Step step = new Step("a").With("returnValue", "10");

            Cell cell = method.GetReturnCell();
            var data = new TestContext();

            cell.RecordActual(32.0, step, data);

            data.ResultsFor(step).ActualDisplay<double>("returnValue").ShouldEqual(32);
        }
コード例 #6
0
ファイル: CellTester.cs プロジェクト: adymitruk/storyteller
        public void record_actual_calls_mark_missing_value_when_the_expected_value_is_missing()
        {
            MethodInfo method = ReflectionHelper.GetMethod<CellTarget>(x => x.Add(0, 0));
            Cell cell = method.GetReturnCell();
            var step = new Step();

            var data = new TestContext();
            cell.RecordActual(32.0, step, data);

            data.ResultsFor(step).GetActual("returnValue").ShouldEqual(32.0);
            data.Counts.SyntaxErrors.ShouldEqual(1);
        }
コード例 #7
0
ファイル: CellTester.cs プロジェクト: adymitruk/storyteller
        public void read_expected_value_from_step_that_is_boolean_missing_and_input_should_still_log_error()
        {
            var cell = new Cell("success", typeof (bool))
            {
                IsResult = false
            };
            var step = new Step();

            var context = new TestContext();
            cell.ReadArgument(context, step, o => Assert.Fail("should not have called back"));

            context.ResultsFor(step).IsInException("success").ShouldBeTrue();
        }
コード例 #8
0
ファイル: CellTester.cs プロジェクト: adymitruk/storyteller
        public void read_expected_value_from_step_for_a_boolean_result_cell()
        {
            var cell = new Cell("success", typeof (bool))
            {
                IsResult = true
            };
            bool returnValue = false;
            var step = new Step();
            var context = new TestContext();
            cell.ReadArgument(context, step, o => returnValue = (bool) o);

            returnValue.ShouldBeTrue();
            context.ResultsFor(step).IsInException("success").ShouldBeFalse();
        }
コード例 #9
0
ファイル: CellTester.cs プロジェクト: adymitruk/storyteller
        public void read_argument_with_a_format_exception()
        {
            Step step = new Step("a").With("age", "abc");
            var cell = new Cell("age", typeof (int));

            var context = new TestContext();
            cell.ReadArgument(context, step, x => Assert.Fail("should not have been called"));

            context.Counts.SyntaxErrors.ShouldEqual(1);

            context.ResultsFor(step).ExceptionText.ShouldContain("Format exception for 'age'");
        }
コード例 #10
0
        public void reverting_a_fixture_with_an_exception_in_teardown_increments_exceptions_and_captures_the_exception()
        {
            var fixture = MockRepository.GenerateMock<IFixture>();
            var exception = new NotImplementedException();
            fixture.Expect(x => x.TearDown()).Throw(exception);

            var context = new TestContext();
            var section = new Section("something");

            context.LoadFixture(fixture, section);
            context.RevertFixture(section);

            context.ResultsFor(section).ExceptionText.ShouldEqual(exception.ToString());

            context.Counts.Exceptions.ShouldEqual(1);
        }
コード例 #11
0
        public void log_exception_from_section_setup()
        {
            var fixture = MockRepository.GenerateMock<IFixture>();
            var context = new TestContext();

            var exception = new NotImplementedException();
            fixture.Expect(x => x.SetUp(context)).Throw(exception);

            var step = new Step();
            context.LoadFixture(fixture, step);

            context.Counts.Exceptions.ShouldEqual(1);
            context.ResultsFor(step).ExceptionText.ShouldContain(exception.ToString());
        }
コード例 #12
0
        public void catch_the_storyteller_exception_on_grammar_adds_exception_count_and_exception_message_only()
        {
            var step = new Step("the step");

            var grammar = new GrammarThatAssertsFailure();
            var fixture = MockRepository.GenerateMock<IFixture>();
            fixture.Stub(x => x[step.GrammarKey]).Return(grammar);

            var context = new TestContext();
            context.LoadFixture(fixture, new StubTestPart());

            context.RunStep(step);

            context.Counts.ShouldEqual(0, 0, 1, 0);

            context.ResultsFor(step).ExceptionText.ShouldEqual("I don't want to run");
        }
コード例 #13
0
        public void catch_all_exception_on_grammar_adds_exception_count_and_exception_text()
        {
            var step = new Step("the step");
            var context = new TestContext();
            IGrammar grammar = context.SetupMockGrammar(step.GrammarKey);

            grammar.Expect(x => x.Execute(step, context))
                .Throw(new NotImplementedException());

            context.RunStep(step);

            context.Counts.ShouldEqual(0, 0, 1, 0);

            context.ResultsFor(step).ExceptionText.ShouldContain("NotImplementedException");
        }
コード例 #14
0
        public void execute_with_exception()
        {
            ReflectionAssertion assertion = ReflectionAssertion.Create(x => x.Exception(), new AssertionFixture());
            var step = new Step();

            var context = new TestContext();

            assertion.Execute(step, context);
            context.Counts.ShouldEqual(0, 0, 1, 0);

            step.Get("returnValue").Parse<bool>().ShouldBeTrue();
            context.ResultsFor(step).ActualDisplay<bool>("returnValue").ShouldBeFalse();
            context.ResultsFor(step).ExceptionText.ShouldContain("NotImplementedException");
        }
コード例 #15
0
        public void execute_with_false()
        {
            FactAssertion assertion = FactAssertion.Create(x => x.Failure(), new AssertionFixture());
            var step = new Step();
            var context = new TestContext();

            assertion.Execute(step, context);
            context.Counts.ShouldEqual(0, 1, 0, 0);

            step.Get("returnValue").Parse<bool>().ShouldBeTrue();
            context.ResultsFor(step).ActualDisplay<bool>("returnValue").ShouldBeFalse();
        }