示例#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");
        }
        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);
        }
        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());
        }
        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());
        }
        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>();
        }
        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>();
        }
        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());
        }
        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");
        }
        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);
        }
 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);
 }
        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));
        }