Ejemplo n.º 1
0
        /// <summary>
        ///     Use to create a new paragraph grammar to configure an object stored on
        ///     the Context.State.CurrentObject with property
        ///     setter children grammars
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="title"></param>
        /// <param name="action"></param>
        /// <returns></returns>
        public static ParagraphGrammar CreateObject <T>(string title, Action <ObjectConstructionExpression <T> > action)
        {
            var grammar    = new ParagraphGrammar(title);
            var expression = new ObjectConstructionExpression <T>(grammar);

            action(expression);

            return(grammar);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Create a generic Paragraph grammar
        /// </summary>
        /// <param name="title"></param>
        /// <param name="configure"></param>
        /// <returns></returns>
        public static ParagraphGrammar Paragraph(string title, Action <ParagraphBuilder> configure)
        {
            var grammar    = new ParagraphGrammar(title);
            var expression = new ParagraphBuilder(grammar);

            configure(expression);

            return(grammar);
        }
        public void SetUp()
        {
            _theAddress = null;

            grammar = new ParagraphGrammar();
            expression = new ObjectConstructionExpression<Address>(grammar);

            theStep = new Step();
        }
Ejemplo n.º 4
0
        public void SetUp()
        {
            _theAddress = null;

            grammar    = new ParagraphGrammar();
            expression = new ObjectConstructionExpression <Address>(grammar);

            theStep = new Step();
        }
Ejemplo n.º 5
0
        /// <summary>
        ///     Create a paragraph grammar to verify values on an existing object
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="title"></param>
        /// <param name="action"></param>
        /// <returns></returns>
        public static ParagraphGrammar VerifyPropertiesOf <T>(string title,
                                                              Action <ObjectVerificationExpression <T> > action)
            where T : class
        {
            var grammar = new ParagraphGrammar(title);

            var builder = new ParagraphBuilder(grammar);

            builder.VerifyPropertiesOf(action);

            return(grammar);
        }
        public void sets_the_key_for_all_children()
        {
            var paragraph = new ParagraphGrammar("Something");
            paragraph.Do(c => { });
            paragraph.Do(c => { });
            paragraph.Do(c => { });

            paragraph.Key = "Foo";

            paragraph.Children[0].Key.ShouldBe("Foo:0");
            paragraph.Children[1].Key.ShouldBe("Foo:1");
            paragraph.Children[2].Key.ShouldBe("Foo:2");
        }
        public void sets_the_key_for_all_children()
        {
            var paragraph = new ParagraphGrammar("Something");

            paragraph.Do(c => { });
            paragraph.Do(c => { });
            paragraph.Do(c => { });

            paragraph.Key = "Foo";

            paragraph.Children[0].Key.ShouldBe("Foo:0");
            paragraph.Children[1].Key.ShouldBe("Foo:1");
            paragraph.Children[2].Key.ShouldBe("Foo:2");
        }
        public void do_adds_a_silent_grammar_at_the_right_position()
        {
            var paragraph = new ParagraphGrammar("Something");
            ShouldBeTestExtensions.ShouldBe(paragraph.Children.Any(), false);

            paragraph.Do(c => {});

            paragraph.Children[0].ShouldBeOfType<SilentGrammar>()
                .Position.ShouldBe(0);


            paragraph.Do(c => { });
            paragraph.Do(c => { });
            paragraph.Do(c => { });

            paragraph.Children[1].ShouldBeOfType<SilentGrammar>().Position.ShouldBe(1);
            paragraph.Children[2].ShouldBeOfType<SilentGrammar>().Position.ShouldBe(2);
            paragraph.Children[3].ShouldBeOfType<SilentGrammar>().Position.ShouldBe(3);

        }
        public void do_adds_a_silent_grammar_at_the_right_position()
        {
            var paragraph = new ParagraphGrammar("Something");

            ShouldBeTestExtensions.ShouldBe(paragraph.Children.Any(), false);

            paragraph.Do(c => {});

            paragraph.Children[0].ShouldBeOfType <SilentGrammar>()
            .Position.ShouldBe(0);


            paragraph.Do(c => { });
            paragraph.Do(c => { });
            paragraph.Do(c => { });

            paragraph.Children[1].ShouldBeOfType <SilentGrammar>().Position.ShouldBe(1);
            paragraph.Children[2].ShouldBeOfType <SilentGrammar>().Position.ShouldBe(2);
            paragraph.Children[3].ShouldBeOfType <SilentGrammar>().Position.ShouldBe(3);
        }
Ejemplo n.º 10
0
        public void SetUp()
        {
            var library = new FixtureLibrary();

            var grammar1 = MockRepository.GenerateMock <IGrammar>();
            var grammar2 = MockRepository.GenerateMock <IGrammar>();
            var grammar3 = MockRepository.GenerateMock <IGrammar>();

            structure1 = new StubGrammarStructure();
            structure2 = new StubGrammarStructure();
            structure3 = new StubGrammarStructure();

            grammar1.Expect(x => x.Description).Return("something");
            grammar1.Expect(x => x.ToStructure(library)).Return(structure1);
            grammar2.Expect(x => x.ToStructure(library)).Return(structure2);
            grammar3.Expect(x => x.ToStructure(library)).Return(structure3);

            grammar       = new ParagraphGrammar("the title").With(grammar1, grammar2, grammar3);
            grammar.Style = EmbedStyle.TitledAndIndented;
            theStructure  = grammar.ToStructure(library).ShouldBeOfType <Paragraph>();
        }
Ejemplo n.º 11
0
        IGrammar IGrammarSource.ToGrammar(MethodInfo method, Fixture fixture)
        {
            var databaseFixture = fixture.As <DatabaseFixture>();

            SetVerificationGrammar grammar = null;

            var comparison = new RowFieldComparison(databaseFixture, _fields.ToArray(), toCommandBuilder(method));

            grammar = new SetVerificationGrammar(_title, "rows", comparison);

            if (_ordered)
            {
                grammar.Ordered();
            }

            if (method.GetParameters().Any())
            {
                var line = new DbCommandGrammar(databaseFixture, method, _commandType, _sql);
                if (_fetchFormat.IsNotEmpty())
                {
                    line.Format(_fetchFormat);
                }

                line.Execution = new DbSetExecution(new BufferedReader(_fields));

                var paragraph = new ParagraphGrammar(_title);

                paragraph.Children.Add(line);
                paragraph.Children.Add(grammar);

                return(paragraph);
            }



            return(grammar);
        }
Ejemplo n.º 12
0
        public void SetUp()
        {
            var child1 = MockRepository.GenerateMock <LineGrammar>();
            var child2 = MockRepository.GenerateMock <LineGrammar>();
            var child3 = MockRepository.GenerateMock <LineGrammar>();

            var grammar = new ParagraphGrammar(child1, child2, child3);

            child1.Stub(x => x.GetCells()).Return(new List <Cell>
            {
                new Cell("name1", typeof(string))
            });
            child2.Stub(x => x.GetCells()).Return(new List <Cell>
            {
                new Cell("name2", typeof(string))
            });
            child3.Stub(x => x.GetCells()).Return(new List <Cell>
            {
                new Cell("name3", typeof(string)),
                new Cell("name4", typeof(string))
            });

            cells = grammar.GetCells();
        }
Ejemplo n.º 13
0
 public void SetUp()
 {
     grammar    = new ParagraphGrammar("an action");
     step       = new Step("some grammar");
     TheAddress = null;
 }
        public void SetUp()
        {
            grammars = new IGrammar[]
            {
                MockRepository.GenerateMock<IGrammar>(),
                MockRepository.GenerateMock<IGrammar>(),
                MockRepository.GenerateMock<IGrammar>()
            };
            ClassUnderTest = new ParagraphGrammar(grammars);

            step = MockRepository.GenerateMock<IStep>();

            context = MockRepository.GenerateMock<AutoPerformingTestContext>();
            counts = new Counts();
        }
        public void SetUp()
        {
            var child1 = MockRepository.GenerateMock<LineGrammar>();
            var child2 = MockRepository.GenerateMock<LineGrammar>();
            var child3 = MockRepository.GenerateMock<LineGrammar>();

            var grammar = new ParagraphGrammar(child1, child2, child3);

            child1.Stub(x => x.GetCells()).Return(new List<Cell>
            {
                new Cell("name1", typeof (string))
            });
            child2.Stub(x => x.GetCells()).Return(new List<Cell>
            {
                new Cell("name2", typeof (string))
            });
            child3.Stub(x => x.GetCells()).Return(new List<Cell>
            {
                new Cell("name3", typeof (string)),
                new Cell("name4", typeof (string))
            });

            cells = grammar.GetCells();
        }
        public void SetUp()
        {
            var library = new FixtureLibrary();

            var grammar1 = MockRepository.GenerateMock<IGrammar>();
            var grammar2 = MockRepository.GenerateMock<IGrammar>();
            var grammar3 = MockRepository.GenerateMock<IGrammar>();

            structure1 = new StubGrammarStructure();
            structure2 = new StubGrammarStructure();
            structure3 = new StubGrammarStructure();

            grammar1.Expect(x => x.Description).Return("something");
            grammar1.Expect(x => x.ToStructure(library)).Return(structure1);
            grammar2.Expect(x => x.ToStructure(library)).Return(structure2);
            grammar3.Expect(x => x.ToStructure(library)).Return(structure3);

            grammar = new ParagraphGrammar("the title").With(grammar1, grammar2, grammar3);
            grammar.Style = EmbedStyle.TitledAndIndented;
            theStructure = grammar.ToStructure(library).ShouldBeOfType<Paragraph>();
        }
 public void SetUp()
 {
     _paragraph = new ParagraphGrammar("the title");
 }
 public ObjectConstructionExpression(ParagraphGrammar grammar)
 {
     _grammar = grammar;
 }
 public ObjectVerificationExpression(ParagraphGrammar grammar)
 {
     _grammar = grammar;
 }
Ejemplo n.º 20
0
 public void SetUp()
 {
     _paragraph = new ParagraphGrammar("the title");
 }
 public void SetUp()
 {
     grammar = new ParagraphGrammar("an action");
     step = new Step("some grammar");
     TheAddress = null;
 }