예제 #1
0
        public void CollectionAsync_WithoutTotalResults_Test()
        {
            var expected = CreateCollection(Enumerable.Range(0, 3).Select(i => new Contact()), null);
            var client   = CreateClientAsync(null, expected, CreateCollection <Contact>(null, null));
            var executor = new SDataQueryExecutor(client);
            var builder  = CreateQueryBuilder <Contact>(true);
            var result   = executor.ExecuteCollectionAsync <Contact>(builder.Build(), CancellationToken.None).Result;

            Assert.That(result, Is.EquivalentTo(expected));
        }
예제 #2
0
        public void CollectionAsync_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   = CreateClientAsync(null, page1, page2);
            var executor = new SDataQueryExecutor(client);
            var builder  = CreateQueryBuilder <Contact>(true);
            var result   = executor.ExecuteCollectionAsync <Contact>(builder.Build(), CancellationToken.None).Result;

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

            builder.AddResultOperator(new TakeResultOperator(Expression.Constant(3)));
            var result = executor.ExecuteCollectionAsync <Contact>(builder.Build(), CancellationToken.None).Result;

            Assert.That(result, Is.EquivalentTo(expected));
            Assert.That(parmsList[0].Count, Is.EqualTo(3));
        }
예제 #4
0
        public void CollectionAsync_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   = CreateClientAsync(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.ExecuteCollectionAsync <string>(builder.Build(), CancellationToken.None).Result;

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