Ejemplo n.º 1
0
        public void the_test_is_available_in_the_test_context()
        {
            var test    = new Test("some test");
            var context = new TestContext(new Container(), test, new ConsoleListener());

            context.Retrieve <Test>().ShouldBeTheSameAs(test);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
        public void should_store_itself_on_the_fixture_as_the_fixture_context()
        {
            var context = new TestContext();
            var fixture = context.RetrieveFixture <SentenceFixture>();

            fixture.ShouldBeOfType <SentenceFixture>().Fixtures.ShouldBeTheSameAs(context);
        }
Ejemplo n.º 4
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>();
        }
Ejemplo n.º 5
0
        public void read_incorrectly_formatted_step_value_increments_syntax_error()
        {
            Step step = new Step().With("DistanceFromOffice:abc");
            var context = new TestContext();

            match.ReadExpected(context, step, new SetRow());

            context.Counts.ShouldEqual(0, 0, 0, 1);
        }
Ejemplo n.º 6
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));
        }
Ejemplo n.º 7
0
        public void store_and_retrieve()
        {
            var context = new TestContext();
            var data    = new SomeContext();

            context.Store(data);

            context.Retrieve <SomeContext>().ShouldBeTheSameAs(data);
        }
Ejemplo n.º 8
0
        public void increment_wrongs()
        {
            var test    = new Test("some test");
            var context = new TestContext(new Container(), test, new ConsoleListener());

            context.IncrementWrongs();

            context.Counts.ShouldEqual(0, 1, 0, 0);
        }
Ejemplo n.º 9
0
        public void increment_syntax_errors()
        {
            var test    = new Test("some test");
            var context = new TestContext(new Container(), test, new ConsoleListener());

            context.IncrementSyntaxErrors();

            context.Counts.ShouldEqual(0, 0, 0, 1);
        }
Ejemplo n.º 10
0
        public void execute_should_delegate()
        {
            var theStep    = new Step();
            var theContext = new TestContext();

            ClassUnderTest.Execute(theStep, theContext);

            MockFor <IGrammar>().AssertWasCalled(x => x.Execute(theStep, theContext));
        }
Ejemplo n.º 11
0
        public void read_incorrectly_formatted_step_value_increments_syntax_error()
        {
            Step step    = new Step().With("DistanceFromOffice:abc");
            var  context = new TestContext();

            match.ReadExpected(context, step, new SetRow());

            context.Counts.ShouldEqual(0, 0, 0, 1);
        }
Ejemplo n.º 12
0
        private void then()
        {
            var context = new TestContext();

            context.CurrentObject = TheAddress;

            grammar.Execute(step, context);

            TheCounts = context.Counts;
        }
        public void SetUp()
        {
            var context = new TestContext(x => { x.AddFixture<FixtureWithHiddenGrammarsFixture>(); });

            var observer = MockRepository.GenerateMock<IFixtureObserver>();
            var builder = new LibraryBuilder(observer, new CompositeFilter<Type>());
            builder.Build(context);

            library = builder.Library;
        }
Ejemplo n.º 14
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();

            tag.WriteResults(context);
        }
Ejemplo n.º 15
0
        public void SetUp()
        {
            grammar = CheckPropertyGrammar.For <CheckPropertyTarget>(x => x.Age);
            theStep = new Step("grammar");
            context = new TestContext();

            beforeEach();

            then();
        }
        public void SetUp()
        {
            grammar = CheckPropertyGrammar.For<CheckPropertyTarget>(x => x.Age);
            theStep = new Step("grammar");
            context = new TestContext();

            beforeEach();

            then();
        }
Ejemplo n.º 17
0
        public void SetUp()
        {
            context  = new TestContext();
            sentence = new FactFixture()["True"].ToStructure(new FixtureLibrary()).As <Sentence>();
            step     = new Step();

            sentence.ResultCell.RecordActual(true, step, context);

            tag = new SentenceTag(sentence, step);
            tag.WriteResults(context);
        }
Ejemplo n.º 18
0
        public void calls_the_action_upon_execute()
        {
            var address = new Address();
            var grammar = new DoGrammar((s, c) => c.CurrentObject = address);

            var context = new TestContext();

            grammar.Execute(new Step(), context);

            context.CurrentObject.ShouldBeTheSameAs(address);
        }
        public void SetUp()
        {
            grammar1 = new ConfigureObjectGrammar <ConfiguredObject, int>("age", (o, age) => o.Age = age);
            grammar2 = new ConfigureObjectGrammar <ConfiguredObject, string>("name", (o, name) => o.Name = name);
            grammar2.DefaultValue = "Han Solo";

            context = new TestContext();
            target  = new ConfiguredObject();

            context.CurrentObject = target;
        }
Ejemplo n.º 20
0
        public void verify_the_actual_when_the_expected_is_a_null_positive_case()
        {
            Step step = new Step().With("key1:NULL");
            var  cell = new Cell("key1", typeof(string));

            var context = new TestContext();

            cell.RecordActual(null, step, context);

            context.Counts.ShouldEqual(1, 0, 0, 0);
        }
Ejemplo n.º 21
0
        public static StepExecutionResult Execute(this IGrammar grammar, IStep step)
        {
            var context = new TestContext();

            grammar.Execute(step, context);

            return(new StepExecutionResult {
                Counts = context.Counts,
                Results = context.ResultsFor(step)
            });
        }
Ejemplo n.º 22
0
        public void set_argument_if_argument_is_itestcontext_just_uses_the_itestcontext()
        {
            var cell    = new Cell("context", typeof(ITestContext));
            var context = new TestContext();

            object argValue = null;

            cell.ReadArgument(context, new Step(), x => argValue = x);

            argValue.ShouldBeTheSameAs(context);
        }
Ejemplo n.º 23
0
        public void SetUp()
        {
            var context = new TestContext(x => { x.AddFixture <FixtureWithHiddenGrammarsFixture>(); });

            var observer = MockRepository.GenerateMock <IFixtureObserver>();
            var builder  = new LibraryBuilder(observer, new CompositeFilter <Type>());

            builder.Build(context);

            library = builder.Library;
        }
Ejemplo n.º 24
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());
        }
        public void SetUp()
        {
            grammar1 = new ConfigureObjectGrammar<ConfiguredObject, int>("age", (o, age) => o.Age = age);
            grammar2 = new ConfigureObjectGrammar<ConfiguredObject, string>("name", (o, name) => o.Name = name);
            grammar2.DefaultValue = "Han Solo";

            context = new TestContext();
            target = new ConfiguredObject();

            context.CurrentObject = target;
        }
Ejemplo n.º 26
0
        public void run_a_step()
        {
            var step = new Step("the step");

            var      context = new TestContext();
            IGrammar grammar = context.SetupMockGrammar(step.GrammarKey);

            context.RunStep(step);

            grammar.AssertWasCalled(x => x.Execute(step, context));
        }
Ejemplo n.º 27
0
        public void marks_the_testdata_with_wrong_if_the_actual_is_wrong()
        {
            MethodInfo method  = ReflectionHelper.GetMethod <ReflectionTarget>(x => x.GetNameAndAge("", 0));
            var        grammar = new ValueCheckMethod(method, new ReflectionTarget());

            Step step = new Step("a").With("name", "Jeremy").With("age", 34).With("theValue", "the wrong value");
            var  data = new TestContext();

            grammar.Execute(step, data);

            data.Counts.Wrongs.ShouldEqual(1);
        }
Ejemplo n.º 28
0
        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);
        }
Ejemplo n.º 29
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();
        }
Ejemplo n.º 30
0
        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);
        }
        public void SetUp()
        {
            string sectionName = typeof(ArithmeticFixture).GetFixtureAlias();

            step = new Step().WithChildren(sectionName, new Step("Adding").With("x:2,y:3,returnValue:5"));

            context = new TestContext();

            new EmbeddedSectionGrammar <ArithmeticFixture>()
            .Before((s, c) => { throw new NotImplementedException(); })
            .Execute(step, context);
        }
Ejemplo n.º 32
0
        public void get_startup_type_for_a_name()
        {
            var container = new Container(x =>
            {
                x.For <IStartupAction>().Add <SetUserAction>().Named("SetUser");
                x.For <IStartupAction>().Add <StartWebAppAction>().Named("StartWebApp");
            });

            var context = new TestContext(container);

            context.GetStartupType("SetUser").ShouldEqual(typeof(SetUserAction));
            context.GetStartupType("StartWebApp").ShouldEqual(typeof(StartWebAppAction));
        }
Ejemplo n.º 33
0
        public void SetUp()
        {
            var builder  = new LibraryBuilder(new NulloFixtureObserver(), new CompositeFilter <Type>());
            var registry = new FixtureRegistry();

            registry.AddFixturesFromAssemblyContaining <SetUserAction>();

            var container = registry.BuildContainer();
            var context   = new TestContext(container);


            library = builder.Build(context);
        }
Ejemplo n.º 34
0
        public void SetUp()
        {
            grammar = new CreateObjectGrammar <CreateObjectGrammarTarget, string>(
                "name",
                name => new CreateObjectGrammarTarget
            {
                Name = name
            });

            grammar.DefaultValue = "Case";

            context = new TestContext();
        }
Ejemplo n.º 35
0
        public void read_step_successfully_if_it_exists_and_is_formatted_correctly()
        {
            Step step = new Step().With("City:Dallas,Distance:189");
            var row = new SetRow();

            var context = new TestContext();

            _matchCity.As<ISetColumn>().ReadExpected(context, step, row);
            _matchDistance.As<ISetColumn>().ReadExpected(context, step, row);

            row.Values["City"].ShouldEqual("Dallas");
            row.Values["Distance"].ShouldEqual(189);
        }
Ejemplo n.º 36
0
        public void SetUp()
        {
            var container = new Container();
            var registry = new FixtureRegistry();
            registry.AddFixture<FixtureWithHiddenGrammarsFixture>();
            registry.AddFixturesToContainer(container);
            var context = new TestContext(container);

            var observer = MockRepository.GenerateMock<IFixtureObserver>();
            var builder = new LibraryBuilder(observer, new CompositeFilter<Type>(), new ObjectConverter());

            builder.Build(context);

            library = builder.Library;
        }
        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);
        }
        public void FixtureSetup()
        {
            var lifecycle = BrowserForTesting.Use<ChromeBrowser>();

            var context = new TestContext();

            var applicationUnderTest = new StubbedApplicationUnderTest
            {
                Browser = lifecycle
            };

            applicationUnderTest.Driver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromMilliseconds(1000));

            context.Store<IApplicationUnderTest>(applicationUnderTest);

            SetUp(context);
        }
Ejemplo n.º 39
0
        public void run_with_a_test_context_func()
        {
            var context = new TestContext();
            var service = new ServiceInContext(){
                Count = 2
            };
            context.Store(service);

            var fact = new FactGrammar(c => c.Retrieve<ServiceInContext>().Count == 2, "the count should be 2");

            fact.Execute(new Step(), context);
            context.Counts.ShouldEqual(1, 0, 0, 0);

            service.Count = 3;
            context.Counts.Reset();

            fact.Execute(new Step(), context);
            context.Counts.ShouldEqual(0, 1, 0, 0);
        }
Ejemplo n.º 40
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>();
        }
Ejemplo n.º 41
0
        public void increment_wrongs()
        {
            var test = new Test("some test");
            var context = new TestContext(new Container(), test, new ConsoleListener());

            context.IncrementWrongs();

            context.Counts.ShouldEqual(0, 1, 0, 0);
        }
Ejemplo n.º 42
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);
        }
Ejemplo n.º 43
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());
        }
Ejemplo n.º 44
0
        public void get_startup_type_for_a_name()
        {
            var container = new Container(x =>
            {
                x.For<IStartupAction>().Add<SetUserAction>().Named("SetUser");
                x.For<IStartupAction>().Add<StartWebAppAction>().Named("StartWebApp");
            });

            var context = new TestContext(container);

            context.GetStartupType("SetUser").ShouldEqual(typeof (SetUserAction));
            context.GetStartupType("StartWebApp").ShouldEqual(typeof (StartWebAppAction));
        }
Ejemplo n.º 45
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);
 }
Ejemplo n.º 46
0
        public void stop_test_if_the_test_observer_trips_off_the_cannot_continue_condition()
        {
            Test test = new Test("something").With(Section.For<SomethingFixture>()
                                                       .WithStep("DoSomething")
                                                       .WithStep("DoSomething")
                                                       .WithStep("DoSomething")
                                                       .WithStep("DoSomething")
                                                       .WithStep("DoSomething")
                                                       .WithStep("DoSomething")
                                                       .WithStep("DoSomething")
                                                       .WithStep("DoSomething")
                                                       .WithStep("DoSomething")
                                                       .WithStep("DoSomething")
                );

            var observer = new MockTestObserver
            {
                StepsAllowed = 3
            };
            var context = new TestContext(new Container(), test, observer);
            context.Execute();

            observer.StepsRun.ShouldEqual(3);
            observer.StepsRun = 0;

            observer.StepsAllowed = 2;

            context.Execute();
            observer.StepsRun.ShouldEqual(2);

            observer.StepsRun = 0;
            observer.StepsAllowed = 200;

            context.Execute();
            observer.StepsRun.ShouldEqual(10);
        }
Ejemplo n.º 47
0
 public void get_string_for_empty_string()
 {
     var context = new TestContext();
     context.GetDisplay(string.Empty).ShouldEqual(Step.BLANK);
 }
Ejemplo n.º 48
0
        public void store_and_retrieve()
        {
            var context = new TestContext();
            var data = new SomeContext();

            context.Store(data);

            context.Retrieve<SomeContext>().ShouldBeTheSameAs(data);
        }
 public void SetUp()
 {
     _testContext = new TestContext();
 }
Ejemplo n.º 50
0
        public void store_and_retrieve_backs_up_by_the_system()
        {
            var returnValue = new SomethingThatDoesNotExist();

            var context = new TestContext()
            {
                BackupResolver = t =>
                {
                    if (t == typeof(ISomethingThatDoesNotExist)) return returnValue;

                    throw new ApplicationException("Unexpected Type:  " + t.FullName);
                }
            };

            context.Retrieve(typeof (ISomethingThatDoesNotExist)).ShouldBeTheSameAs(returnValue);
            context.Retrieve<ISomethingThatDoesNotExist>().ShouldBeTheSameAs(returnValue);
        }
Ejemplo n.º 51
0
        public void capture_trace_and_debug_messages_to_the_Test_object()
        {
            var test = new TracedTest();
            test.ConsoleMessage("console1");
            test.DebugMessage("debug1");
            test.ConsoleMessage("console2");
            test.DebugMessage("debug2");

            var context = new TestContext(new Container(), test, new ConsoleListener());
            context.Execute();

            context.TraceText.ShouldContain("console1");
            context.TraceText.ShouldContain("console2");
            context.TraceText.ShouldContain("debug1");
            context.TraceText.ShouldContain("debug2");
        }
Ejemplo n.º 52
0
 public void should_store_itself_on_the_fixture_as_the_fixture_context()
 {
     var context = new TestContext();
     var fixture = context.RetrieveFixture<SentenceFixture>();
     fixture.ShouldBeOfType<SentenceFixture>().Fixtures.ShouldBeTheSameAs(context);
 }
Ejemplo n.º 53
0
        public void increment_syntax_errors()
        {
            var test = new Test("some test");
            var context = new TestContext(new Container(), test, new ConsoleListener());

            context.IncrementSyntaxErrors();

            context.Counts.ShouldEqual(0, 0, 0, 1);
        }
Ejemplo n.º 54
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);
        }
Ejemplo n.º 55
0
 public void get_string_for_null()
 {
     var context = new TestContext();
     context.GetDisplay(null).ShouldEqual(Step.NULL);
 }
Ejemplo n.º 56
0
        public void run_a_step()
        {
            var step = new Step("the step");

            var context = new TestContext();
            IGrammar grammar = context.SetupMockGrammar(step.GrammarKey);

            context.RunStep(step);

            grammar.AssertWasCalled(x => x.Execute(step, context));
        }
Ejemplo n.º 57
0
 public void get_string_for_DbNull()
 {
     var context = new TestContext();
     context.GetDisplay(DBNull.Value).ShouldEqual(Step.NULL);
 }
Ejemplo n.º 58
0
        public void running_a_step_logs_the_start_and_end_of_the_grammar()
        {
            var step = new Step("the step");

            var listener = MockRepository.GenerateMock<ITestObserver>();
            listener.Expect(x => x.CanContinue(null)).Return(true).IgnoreArguments().Repeat.Any();

            var context = new TestContext(new Container(), new Test("Fake"), listener);
            IGrammar grammar = context.SetupMockGrammar(step.GrammarKey);

            context.RunStep(step);

            listener.AssertWasCalled(x => x.StartStep(step));
            listener.AssertWasCalled(x => x.FinishStep(step));
        }
Ejemplo n.º 59
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>();
        }
Ejemplo n.º 60
0
        public void the_test_is_available_in_the_test_context()
        {
            var test = new Test("some test");
            var context = new TestContext(new Container(), test, new ConsoleListener());

            context.Retrieve<Test>().ShouldBeTheSameAs(test);
        }