コード例 #1
0
        public void load_and_revert_fixtures()
        {
            var context = new TestContext();

            context.LoadFixture <ArithmeticFixture>(new StubTestPart());
            context.CurrentFixture.ShouldBeOfType <ArithmeticFixture>();

            context.LoadFixture <SomethingFixture>(new StubTestPart());
            context.CurrentFixture.ShouldBeOfType <SomethingFixture>();

            context.RevertFixture(new StubTestPart());

            context.CurrentFixture.ShouldBeOfType <ArithmeticFixture>();
        }
コード例 #2
0
        public void throw_argument_not_null_exception_when_the_log_action_is_null()
        {
            var fixture = MockRepository.GenerateMock <IFixture>();
            var context = new TestContext();

            context.LoadFixture(fixture, null);
        }
コード例 #3
0
        public void load_fixture_directly_and_find_object_off_of_it()
        {
            var context = new TestContext();

            context.LoadFixture(new SomethingElseFixture(), new StubTestPart());

            context.FindGrammar("Go").ShouldBeOfType <ValueCheckMethod>();
        }
コード例 #4
0
        public void call_fixture_setup_when_loading_a_fixture()
        {
            var fixture = MockRepository.GenerateMock <IFixture>();
            var context = new TestContext();

            context.LoadFixture(fixture, new StubTestPart());

            fixture.AssertWasCalled(x => x.SetUp(context));
        }
コード例 #5
0
        public void ending_a_section_should_tell_the_previous_fixture_to_finish()
        {
            var fixture1 = MockRepository.GenerateMock <IFixture>();
            var context  = new TestContext();

            context.LoadFixture(fixture1, new StubTestPart());

            ((ITestVisitor)context).EndSection(new Section("something"));

            fixture1.AssertWasCalled(x => x.TearDown());
        }
コード例 #6
0
        public void context_should_tell_a_fixture_that_it_is_finished_at_the_end()
        {
            var fixture1 = MockRepository.GenerateMock <IFixture>();
            var fixture2 = MockRepository.GenerateMock <IFixture>();

            var context = new TestContext();

            context.LoadFixture(fixture1, new StubTestPart());
            fixture1.AssertWasNotCalled(x => x.TearDown());

            context.LoadFixture(fixture2, new StubTestPart());
            fixture1.AssertWasNotCalled(x => x.TearDown());
            fixture2.AssertWasNotCalled(x => x.TearDown());


            context.RevertFixture(new StubTestPart());
            fixture1.AssertWasNotCalled(x => x.TearDown());
            fixture2.AssertWasCalled(x => x.TearDown());

            context.RevertFixture(new StubTestPart());
            fixture1.AssertWasCalled(x => x.TearDown());
        }
コード例 #7
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());
        }
コード例 #8
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);
        }
コード例 #9
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");
        }
コード例 #10
0
        public void sets_the_context_on_the_fixture_when_loading_a_fixture()
        {
            var fixture = MockRepository.GenerateMock<IFixture>();
            var context = new TestContext();
            context.LoadFixture(fixture, new StubTestPart());

            fixture.AssertWasCalled(x => x.Context = context);
        }
コード例 #11
0
        public void context_should_tell_a_fixture_that_it_is_finished_at_the_end()
        {
            var fixture1 = MockRepository.GenerateMock<IFixture>();
            var fixture2 = MockRepository.GenerateMock<IFixture>();

            var context = new TestContext();
            context.LoadFixture(fixture1, new StubTestPart());
            fixture1.AssertWasNotCalled(x => x.TearDown());

            context.LoadFixture(fixture2, new StubTestPart());
            fixture1.AssertWasNotCalled(x => x.TearDown());
            fixture2.AssertWasNotCalled(x => x.TearDown());

            context.RevertFixture(new StubTestPart());
            fixture1.AssertWasNotCalled(x => x.TearDown());
            fixture2.AssertWasCalled(x => x.TearDown());

            context.RevertFixture(new StubTestPart());
            fixture1.AssertWasCalled(x => x.TearDown());
        }
コード例 #12
0
        public void ending_a_section_should_tell_the_previous_fixture_to_finish()
        {
            var fixture1 = MockRepository.GenerateMock<IFixture>();
            var context = new TestContext();
            context.LoadFixture(fixture1, new StubTestPart());

            ((ITestVisitor)context).EndSection(new Section("something"));

            fixture1.AssertWasCalled(x => x.TearDown());
        }
コード例 #13
0
        public void load_and_revert_fixtures()
        {
            var context = new TestContext();

            context.LoadFixture<ArithmeticFixture>(new StubTestPart());
            context.CurrentFixture.ShouldBeOfType<ArithmeticFixture>();

            context.LoadFixture<SomethingFixture>(new StubTestPart());
            context.CurrentFixture.ShouldBeOfType<SomethingFixture>();

            context.RevertFixture(new StubTestPart());

            context.CurrentFixture.ShouldBeOfType<ArithmeticFixture>();
        }
コード例 #14
0
        public void load_fixture_directly_and_find_object_off_of_it()
        {
            var context = new TestContext();

            context.LoadFixture(new SomethingElseFixture(), new StubTestPart());

            context.FindGrammar("Go").ShouldBeOfType<ValueCheckMethod>();
        }
コード例 #15
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());
        }
コード例 #16
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");
        }
コード例 #17
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);
        }
コード例 #18
0
 public void throw_argument_not_null_exception_when_the_log_action_is_null()
 {
     var fixture = MockRepository.GenerateMock<IFixture>();
     var context = new TestContext();
     context.LoadFixture(fixture, null);
 }
コード例 #19
0
        public void call_fixture_setup_when_loading_a_fixture()
        {
            var fixture = MockRepository.GenerateMock<IFixture>();
            var context = new TestContext();
            context.LoadFixture(fixture, new StubTestPart());

            fixture.AssertWasCalled(x => x.SetUp(context));
        }