Ejemplo n.º 1
0
        public void ShouldConcatMultipleWhereCallsWithLogicalAnd()
        {
            var builder = new StringBuilder();
            var context = new TextContext <Book>(new StringWriter(builder));

            var query = context.Where(x => x.Id == 1).Where(x => x.Author == "Scott");

            query.FirstOrDefault();

            Assert.AreEqual(Expected(), Source(builder));
        }
Ejemplo n.º 2
0
        public void ShouldAssertObjectNameAsSpecifiedInNameAttribute()
        {
            var builder = new StringBuilder();
            var context = new TextContext <Library>(new StringWriter(builder));

            var query = from libary in context
                        select libary;

            query.Count();

            Assert.AreEqual(Expected(), Source(builder));
        }
Ejemplo n.º 3
0
        public void ShouldAssertSimpleSelect()
        {
            var builder = new StringBuilder();
            var context = new TextContext <Book>(new StringWriter(builder));

            var query = from book in context
                        select book;

            query.Count();

            Assert.AreEqual(Expected(), Source(builder));
        }
Ejemplo n.º 4
0
        public void ShouldAssertSimpleWhereThatHasMethodCall()
        {
            var builder = new StringBuilder();
            var context = new TextContext <Book>(new StringWriter(builder));

            var query = from book in context
                        where book.Author == GetAuthor(1)
                        select book;

            query.Count();

            Assert.AreEqual(Expected(), Source(builder));
        }
Ejemplo n.º 5
0
        public void ShouldAssertOrderByDescending()
        {
            var builder = new StringBuilder();
            var context = new TextContext <Book>(new StringWriter(builder));

            var query = from book in context
                        orderby book.Author descending
                        select book;

            query.Count();

            Assert.AreEqual(Expected(), Source(builder));
        }
Ejemplo n.º 6
0
        public void ShouldAssertWhereWithNestedLeftAndRightLogicaExpression()
        {
            var builder = new StringBuilder();
            var context = new TextContext <Book>(new StringWriter(builder));

            var query = from book in context
                        where (book.Id == 10 && book.Author == "Plarosi") || (book.Id == 1 && book.Author == "Charlie")
                        select book;


            query.Count();

            Assert.AreEqual(Expected(), Source(builder));
        }
Ejemplo n.º 7
0
        public void ShouldAssertSimpleWhereWithLogicalExpression()
        {
            var builder = new StringBuilder();
            var context = new TextContext <Book>(new StringWriter(builder));

            var query = from book in context
                        where book.Id == 1 && book.Author == "Charlie"
                        select book;


            query.Count();

            Assert.AreEqual(Expected(), Source(builder));
        }
Ejemplo n.º 8
0
        public void ShouldJoinWhereUsingAndWhenNextCallHavingLogicalExpr()
        {
            var builder = new StringBuilder();
            var context = new TextContext <Book>(new StringWriter(builder));

            var query = context
                        .Where(x => x.ISBN == "111")
                        .Where(x => x.Id == 1 || x.Author == "Scott" || x.IsAvailable);


            query.FirstOrDefault();

            Assert.AreEqual(Expected(), Source(builder));
        }