Ejemplo n.º 1
0
        public void Collection_WithoutTotalResults_Test()
        {
            var expected = CreateCollection(Enumerable.Range(0, 3).Select(i => new Contact()), null);
            var client   = CreateClient(null, expected, CreateCollection <Contact>(null, null));
            var executor = new SDataQueryExecutor(client);
            var builder  = CreateQueryBuilder <Contact>(true);
            var result   = executor.ExecuteCollection <Contact>(builder.Build());

            Assert.That(result, Is.EquivalentTo(expected));
        }
Ejemplo n.º 2
0
        public void Collection_Paging_Test()
        {
            var page1    = CreateCollection(Enumerable.Range(0, 3).Select(i => new Contact()), 6);
            var page2    = CreateCollection(Enumerable.Range(0, 3).Select(i => new Contact()), 6);
            var client   = CreateClient(null, page1, page2);
            var executor = new SDataQueryExecutor(client);
            var builder  = CreateQueryBuilder <Contact>(true);
            var result   = executor.ExecuteCollection <Contact>(builder.Build());

            Assert.That(result, Is.EquivalentTo(page1.Concat(page2)));
        }
Ejemplo n.º 3
0
        public void Collection_Take_Test()
        {
            var parmsList = new List <SDataParameters>();
            var expected  = CreateCollection(Enumerable.Range(0, 3).Select(i => new Contact()), 10);
            var client    = CreateClient(parmsList, expected);
            var executor  = new SDataQueryExecutor(client);
            var builder   = CreateQueryBuilder <Contact>(true);

            builder.AddResultOperator(new TakeResultOperator(Expression.Constant(3)));
            var result = executor.ExecuteCollection <Contact>(builder.Build());

            Assert.That(result, Is.EquivalentTo(expected));
            Assert.That(parmsList[0].Count, Is.EqualTo(3));
        }
Ejemplo n.º 4
0
        public void Collection_Take_Large_Test()
        {
            var parmsList = new List <SDataParameters>();
            var page1     = CreateCollection(Enumerable.Range(0, 100).Select(i => new Contact()), 200);
            var page2     = CreateCollection(Enumerable.Range(0, 100).Select(i => new Contact()), 200);
            var client    = CreateClient(parmsList, page1, page2);
            var executor  = new SDataQueryExecutor(client);
            var builder   = CreateQueryBuilder <Contact>(true);

            builder.AddResultOperator(new TakeResultOperator(Expression.Constant(150)));
            var result = executor.ExecuteCollection <Contact>(builder.Build());

            Assert.That(result, Is.EquivalentTo(page1.Concat(page2.Take(50))));
            Assert.That(parmsList[1].Count, Is.EqualTo(50));
        }
Ejemplo n.º 5
0
        public void Collection_Select_Test()
        {
            var parmsList = new List <SDataParameters>();
            var expected  = new[] { "one", "two", "three" };
            var list      = CreateCollection(expected.Select(lastName => new Contact {
                LastName = lastName
            }), 3);
            var client   = CreateClient(parmsList, list);
            var executor = new SDataQueryExecutor(client);
            var builder  = CreateQueryBuilder <Contact>(false);

            builder.AddClause(new SelectClause(
                                  Expression.Property(
                                      new QuerySourceReferenceExpression(builder.MainFromClause),
                                      "LastName")));
            var result = executor.ExecuteCollection <string>(builder.Build());

            Assert.That(result, Is.EquivalentTo(expected));
            Assert.That(parmsList[0].Select, Is.EqualTo("LastName"));
        }