public void CanRightOuterJoinCollectionWithRevealAndLambdas()
        {
            Reveal.SetDefaultConvention(x => x);

            UserGroupLinkEntity     link         = null;
            GroupEntity             group        = null;
            CustomerGroupLinkEntity customerLink = null;
            CustomerEntity          customer     = null;

            FlowQuerySelection <string> groups1 = Query <UserEntity>()
                                                  .RightOuter.Join(u => u.Groups, () => link)
                                                  .RightOuter.Join(u => link.Group, () => group)
                                                  .RightOuter.Join(u => group.Customers, () => customerLink)
                                                  .RightOuter.Join(u => customerLink.Customer, () => customer)
                                                  .Distinct()
                                                  .Select(u => customer.Name);

            Assert.That(groups1.Count(), Is.EqualTo(4));

            FlowQuerySelection <string> groups2 = Query <UserEntity>()
                                                  .RightOuter.Join(u => u.Groups, () => link, () => link.Id == null)
                                                  .RightOuter.Join(u => link.Group, () => group, () => group.Id == null)
                                                  .RightOuter.Join(u => group.Customers, () => customerLink, () => customerLink.Id == null)
                                                  .RightOuter.Join(u => customerLink.Customer, () => customer, () => customer.Id == null)
                                                  .Distinct()
                                                  .Select(u => customer.Name);

            Assert.That(groups2.Count(), Is.EqualTo(4));

            Reveal.ClearDefaultConvention();
        }
Exemple #2
0
        public void SetDefaultConventionThrowsIfConventionIsNull()
        {
            IRevealConvention c = null;

            // ReSharper disable once ExpressionIsAlwaysNull
            Assert.That(() => Reveal.SetDefaultConvention(c), Throws.InstanceOf <ArgumentNullException>());

            Func <string, string> d = null;

            // ReSharper disable once ExpressionIsAlwaysNull
            Assert.That(() => Reveal.SetDefaultConvention(d), Throws.InstanceOf <ArgumentNullException>());
        }
        public void CanJoinWithRevealAndLambdas()
        {
            Reveal.SetDefaultConvention(x => x);

            UserGroupLinkEntity link  = null;
            GroupEntity         group = null;

            var groups = Query <UserEntity>()
                         .Inner.Join(u => u.Groups, () => link)
                         .Inner.Join(u => link.Group, () => group)
                         .Distinct()
                         .Select(u => new { group.Id });

            Assert.That(groups.Count(), Is.EqualTo(2));

            Reveal.ClearDefaultConvention();
        }
Exemple #4
0
        public void CanSetDefaultConventionToConventionDelegate()
        {
            Reveal.SetDefaultConvention(s => "L" + s);

            Assert.That(Reveal.ByConvention <UserEntity>(x => x.Password), Is.EqualTo("LPassword"));

            UserEntity u = null;

            Assert.That(Reveal.ByConvention(() => u.Password), Is.EqualTo("u.LPassword"));
            Assert.That(Reveal.ByConvention(() => u, x => x.Password), Is.EqualTo("u.LPassword"));

            IRevealer revealer = Reveal.CreateRevealer();

            Assert.That(revealer.Reveal <UserEntity>(x => x.Password), Is.EqualTo("LPassword"));

            IRevealer <UserEntity> revealerOfUser = Reveal.CreateRevealer <UserEntity>();

            Assert.That(revealerOfUser.Reveal(x => x.Password), Is.EqualTo("LPassword"));
        }
Exemple #5
0
        public void CanRightOuterJoinWithRevealAndLambdas()
        {
            Reveal.SetDefaultConvention(x => x);

            UserGroupLinkEntity link  = null;
            GroupEntity         group = null;

            IDetachedFlowQuery <UserEntity> query = DetachedQuery <UserEntity>()
                                                    .RightOuter.Join(u => u.Groups, () => link)
                                                    .RightOuter.Join(u => link.Group, () => group)
                                                    .Select(u => group.Id);

            FlowQuerySelection <GroupEntity> groups = Query <GroupEntity>()
                                                      .Where(g => g.Id, FqIs.In(query))
                                                      .Select();

            Assert.That(groups.Count(), Is.EqualTo(2));

            Reveal.ClearDefaultConvention();
        }
Exemple #6
0
        public void CanRightOuterJoinCollectionWithRevealAndLambdas()
        {
            Reveal.SetDefaultConvention(x => x);

            UserGroupLinkEntity     link         = null;
            GroupEntity             group        = null;
            CustomerGroupLinkEntity customerLink = null;
            CustomerEntity          customer     = null;

            IDetachedFlowQuery <UserEntity> query = DetachedQuery <UserEntity>()
                                                    .RightOuter.Join(u => u.Groups, () => link)
                                                    .RightOuter.Join(u => link.Group, () => group)
                                                    .RightOuter.Join(u => group.Customers, () => customerLink)
                                                    .RightOuter.Join(u => customerLink.Customer, () => customer)
                                                    .Distinct()
                                                    .Select(u => customer.Name);

            FlowQuerySelection <CustomerEntity> customers = Query <CustomerEntity>()
                                                            .Where(g => g.Name, FqIs.In(query))
                                                            .Select();

            Assert.That(customers.Count(), Is.EqualTo(4));

            IDetachedFlowQuery <UserEntity> query2 = DetachedQuery <UserEntity>()
                                                     .RightOuter.Join(u => u.Groups, () => link, () => link.Id == 0)
                                                     .RightOuter.Join(x => link.Group, () => group, () => group.Id == 0)
                                                     .RightOuter.Join(u => group.Customers, () => customerLink, () => customerLink.Id == 0, null)
                                                     .RightOuter.Join(u => customerLink.Customer, () => customer, () => customer.Id == 0)
                                                     .Distinct()
                                                     .Select(u => customer.Name);

            FlowQuerySelection <CustomerEntity> customers2 = Query <CustomerEntity>()
                                                             .Where(g => g.Name, FqIs.In(query2))
                                                             .Select();

            Assert.That(customers2.Count(), Is.EqualTo(4));

            Reveal.ClearDefaultConvention();
        }
        public void CanRightOuterJoinWithRevealAndLambdas()
        {
            Reveal.SetDefaultConvention(x => x);

            UserGroupLinkEntity link  = null;
            GroupEntity         group = null;

            var groups1 = Query <UserEntity>()
                          .RightOuter.Join(u => u.Groups, () => link)
                          .RightOuter.Join(u => link.Group, () => group)
                          .Select(u => new { group.Id });

            Assert.That(groups1.Count(), Is.EqualTo(5));

            var groups2 = Query <UserEntity>()
                          .RightOuter.Join(u => u.Groups, () => link, () => link.Id == null)
                          .RightOuter.Join(u => link.Group, () => group, () => group.Id == null)
                          .Select(u => new { group.Id });

            Assert.That(groups2.Count(), Is.EqualTo(2));

            Reveal.ClearDefaultConvention();
        }
Exemple #8
0
        public void CanSetDefaultConvention()
        {
            Reveal.SetDefaultConvention(new CustomConvention(s => "ere" + s + "::-"));

            Assert.That(Reveal.ByConvention <UserEntity>(x => x.Username), Is.EqualTo("ereUsername::-"));
        }