Example #1
0
        public void NullableRootThingWorks()
        {
            Expression <Func <ThingWithNullable, bool> > pred = p => !p.Nullable.HasValue || p.Nullable > 3;
            var outerJoinDisjunctionTransformer = new OuterJoinDisjunctionTransformer(new CustomConfig());
            var result = outerJoinDisjunctionTransformer.AttemptGetOuterJoinDisjunctions(pred);

            Assert.False(result.ContainsOuterJoinDisjunction);
        }
Example #2
0
        public void RootUnaryDisjunctionReturnsSame()
        {
            Expression <Func <BoolClass, bool> > pred = p => p.IsFoo || p.BoolClassId == 1;
            var outerJoinDisjunctionTransformer       = new OuterJoinDisjunctionTransformer(new CustomConfig());
            var result = outerJoinDisjunctionTransformer.AttemptGetOuterJoinDisjunctions(pred);

            Assert.False(result.ContainsOuterJoinDisjunction);
        }
Example #3
0
        public void NoDisjunctionsReturnsSame()
        {
            Expression <Func <Post, bool> > pred = p => p.Author.UserId == 1;
            var outerJoinDisjunctionTransformer  = new OuterJoinDisjunctionTransformer(new CustomConfig());
            var result = outerJoinDisjunctionTransformer.AttemptGetOuterJoinDisjunctions(pred);

            Assert.False(result.ContainsOuterJoinDisjunction);
        }
Example #4
0
        public void RootForeignKeyJoinDisjunctionDoesnt()
        {
            Expression <Func <Post, bool> > pred = p => p.Author.UserId == 1 || p.Blog.BlogId == 2;
            var outerJoinDisjunctionTransformer  = new OuterJoinDisjunctionTransformer(new CustomConfig());
            var result = outerJoinDisjunctionTransformer.AttemptGetOuterJoinDisjunctions(pred);

            Assert.False(result.ContainsOuterJoinDisjunction);
        }
Example #5
0
        public void RootJoinDisjunctionDoesnt()
        {
            Expression <Func <Post, bool> > pred = p => p.Title == "Foo" || p.Rating == 5;
            var outerJoinDisjunctionTransformer  = new OuterJoinDisjunctionTransformer(new CustomConfig());
            var result = outerJoinDisjunctionTransformer.AttemptGetOuterJoinDisjunctions(pred);

            Assert.False(result.ContainsOuterJoinDisjunction);
        }
Example #6
0
        public void MultipleOrDisjunctionDoesnt()
        {
            Expression <Func <Post, bool> > pred = p => (p.Rating > 5 && (p.Author.Username == "Mark" || p.Blog.Title == "Bar")) || (p.Rating < 5 && (p.Author.Username == "Tom" || p.Blog.Title == "Car"));
            var outerJoinDisjunctionTransformer  = new OuterJoinDisjunctionTransformer(new CustomConfig());
            var result = outerJoinDisjunctionTransformer.AttemptGetOuterJoinDisjunctions(pred);

            Assert.False(result.ContainsOuterJoinDisjunction);
        }
Example #7
0
        public void RootForeignKeyEntityJoinDisjunctionDoesnt()
        {
            var author = new User {
                UserId = 1
            };
            var blog = new Blog {
                BlogId = 2
            };
            Expression <Func <Post, bool> > pred = p => p.Author == author || p.Blog == blog;
            var outerJoinDisjunctionTransformer  = new OuterJoinDisjunctionTransformer(new CustomConfig());
            var result = outerJoinDisjunctionTransformer.AttemptGetOuterJoinDisjunctions(pred);

            Assert.False(result.ContainsOuterJoinDisjunction);
        }
Example #8
0
        public void NonRootNullableJoinDisjunctionWorks()
        {
            Expression <Func <ReferencesThingWithNullable, bool> > pred = p => !p.Thing.Nullable.HasValue || p.Thing.Nullable > 3;
            var outerJoinDisjunctionTransformer = new OuterJoinDisjunctionTransformer(new CustomConfig());
            var result = outerJoinDisjunctionTransformer.AttemptGetOuterJoinDisjunctions(pred);

            Assert.True(result.ContainsOuterJoinDisjunction);
            Assert.Equal(2, result.UnionWhereClauses.Count());
            Assert.Equal(
                ((Expression <Func <ReferencesThingWithNullable, bool> >)(p => !p.Thing.Nullable.HasValue)).ToDebugString(),
                result.UnionWhereClauses.ElementAt(0)
                .ToDebugString());
            Assert.Equal(
                ((Expression <Func <ReferencesThingWithNullable, bool> >)(p => p.Thing.Nullable > 3)).ToDebugString(),
                result.UnionWhereClauses.ElementAt(1)
                .ToDebugString());
        }
Example #9
0
        public void NonRootJoinDisjunctionWorks()
        {
            Expression <Func <Post, bool> > pred = p => p.Author.Username == "Mark" || p.Blog.Title == "Foo";
            var outerJoinDisjunctionTransformer  = new OuterJoinDisjunctionTransformer(new CustomConfig());
            var result = outerJoinDisjunctionTransformer.AttemptGetOuterJoinDisjunctions(pred);

            Assert.True(result.ContainsOuterJoinDisjunction);
            Assert.Equal(2, result.UnionWhereClauses.Count());
            Assert.Equal(
                ((Expression <Func <Post, bool> >)(p => p.Author.Username == "Mark")).ToDebugString(),
                result.UnionWhereClauses.ElementAt(0)
                .ToDebugString());
            Assert.Equal(
                ((Expression <Func <Post, bool> >)(p => p.Blog.Title == "Foo")).ToDebugString(),
                result.UnionWhereClauses.ElementAt(1)
                .ToDebugString());
        }
Example #10
0
        public void NonRootBoolMemberAccessJoinDisjunctionWorks()
        {
            var user = new User {
                UserId = 1
            };
            Expression <Func <Comment, bool> > pred = p => p.Post.DoNotMap || p.User == user;
            var outerJoinDisjunctionTransformer     = new OuterJoinDisjunctionTransformer(new CustomConfig());
            var result = outerJoinDisjunctionTransformer.AttemptGetOuterJoinDisjunctions(pred);

            Assert.True(result.ContainsOuterJoinDisjunction);
            Assert.Equal(2, result.UnionWhereClauses.Count());
            Assert.Equal(
                ((Expression <Func <Comment, bool> >)(p => p.Post.DoNotMap)).ToDebugString(),
                result.UnionWhereClauses.ElementAt(0)
                .ToDebugString());
            Assert.Equal(
                ((Expression <Func <Comment, bool> >)(p => p.User == user)).ToDebugString(),
                result.UnionWhereClauses.ElementAt(1)
                .ToDebugString());
        }