public void when_writing_the_grammar_structure()
        {
            SetVerificationGrammar grammar = Fixture.VerifySetOf(c => new ValidationError[0])
                                             .Titled("the title")
                                             .LeafNameIs("group1")
                                             .MatchOn(x => x.Field, x => x.Message);


            var setVerification = grammar.ToStructure(null).ShouldBeOfType <SetVerification>();
            var expected        = new SetVerification("the title", "group1", Cell.For <string>("Field"),
                                                      Cell.For <string>("Message"));

            setVerification.ShouldEqual(expected);
        }
Example #2
0
        public SetVerificationGrammar Grammar()
        {
            var grammar = new SetVerificationGrammar(_leafName, _title, _comparer)
            {
                Description = _description,
                Ordered     = _ordered
            };

            if (_dataSource != null)
            {
                grammar.Before((step, context) => { context.CurrentObject = _dataSource(context); });
            }

            return(grammar);
        }
Example #3
0
        public SetVerificationGrammar Columns(Action <IDataRowComparer> action)
        {
            var comparer = new DataRowComparer();

            action(comparer);

            var grammar = new SetVerificationGrammar(_leafName, _title, comparer)
            {
                Description = _description
            };

            if (_dataSource != null)
            {
                grammar.Before((step, context) => { context.CurrentObject = _dataSource(context).Rows; });
            }

            return(grammar);
        }
Example #4
0
        public SetVerificationGrammar MatchOn(params Expression <Func <T, object> >[] properties)
        {
            var comparer = new ObjectComparer <T>();

            foreach (var property in properties)
            {
                comparer.MatchOn(property);
            }

            var grammar = new SetVerificationGrammar(_leafName, _title, comparer)
            {
                Description = _description,
                Ordered     = _ordered
            };

            grammar.Before((step, context) => { context.CurrentObject = _dataSource(context); });

            return(grammar);
        }
Example #5
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);
        }