示例#1
0
        public void ProduceEmptyStringForNoClauses()
        {
            var fakeQueryData = Builder.GetQueryData();

            var sut = new WhereGenerator(fakeQueryData);

            Assert.Equal("", sut.ToString());
        }
示例#2
0
        public void ProduceAnEqualStatementForSingleClause()
        {
            var clauses = Builder.DoublePack <Clause>(
                new EqualClause("Some_Good_Property", IGNORE_ME)
                );

            var fakeQueryData = Builder.GetQueryData(clauses);

            var queryData = fakeQueryData;
            var sut       = new WhereGenerator(queryData);

            Assert.Equal("WHERE [Some_Good_Property] = @Some_Good_Property_EQUAL", sut.ToString());
        }
示例#3
0
        public void ProduceAnAndOfOrStatementsForUnbalancedMultipleClauses()
        {
            var clauses1      = Builder.Pack <Clause>(new EqualClause("PropOne", IGNORE_ME), new NullClause("PropNull"));
            var clauses2      = Builder.Pack <Clause>(new BetweenClause("PropTwo", IGNORE_ME, IGNORE_ME));
            var fakeQueryData = Builder.GetQueryData(Builder.Pack(clauses1, clauses2));

            var sut = new WhereGenerator(fakeQueryData);

            Assert.Equal("WHERE ([PropOne] = @PropOne_EQUAL OR [PropNull] IS NULL) AND ([PropTwo] BETWEEN @PropTwo_START AND @PropTwo_END)", sut.ToString());
        }
示例#4
0
        public void ProduceAnOrStatementForMultipleClauses()
        {
            var clauses = Builder.DoublePack <Clause>(
                new EqualClause("PropOne", IGNORE_ME),
                new BetweenClause("PropTwo", IGNORE_ME, IGNORE_ME)
                );
            var fakeQueryData = Builder.GetQueryData(clauses);

            var sut = new WhereGenerator(fakeQueryData);

            Assert.Equal("WHERE [PropOne] = @PropOne_EQUAL OR [PropTwo] BETWEEN @PropTwo_START AND @PropTwo_END", sut.ToString());
        }
示例#5
0
        public void ProduceAnStatementForAnotherSingleClause()
        {
            var doublePack = Builder.DoublePack <Clause>(
                new EqualClause("Another_Good_Property", IGNORE_ME)
                );
            var fakeQueryData = Builder.GetQueryData(doublePack);

            var sut = new WhereGenerator(fakeQueryData);

            Assert.Equal("WHERE [Another_Good_Property] = @Another_Good_Property_EQUAL", sut.ToString());
        }