Beispiel #1
0
        public void ScalarAsync_LongCount_Test()
        {
            var parmsList = new List <SDataParameters>();
            var client    = CreateClientAsync(parmsList, CreateCollection <object>(null, 10));
            var executor  = new SDataQueryExecutor(client);
            var builder   = CreateQueryBuilder <Contact>(true);

            builder.AddResultOperator(new LongCountAsyncResultOperator(CancellationToken.None));
            var result = executor.ExecuteScalarAsync <long>(builder.Build(), CancellationToken.None).Result;

            Assert.That(parmsList[0].Count, Is.EqualTo(0));
            Assert.That(result, Is.EqualTo(10));
        }
Beispiel #2
0
        public void ScalarAsync_Any_Take_Zero_Test()
        {
            var parmsList = new List <SDataParameters>();
            var client    = CreateClientAsync(parmsList, CreateCollection <object>(null, 10));
            var executor  = new SDataQueryExecutor(client);
            var builder   = CreateQueryBuilder <Contact>(true);

            builder.AddResultOperator(new TakeResultOperator(Expression.Constant(0)));
            builder.AddResultOperator(new AnyAsyncResultOperator(CancellationToken.None));
            var result = executor.ExecuteScalarAsync <bool>(builder.Build(), CancellationToken.None).Result;

            Assert.That(parmsList, Is.Empty);
            Assert.That(result, Is.False);
        }
Beispiel #3
0
        public void ScalarAsync_ExtensionArgs_Test()
        {
            var parmsList = new List <SDataParameters>();
            var client    = CreateClientAsync(parmsList, CreateCollection <object>(null, 10));
            var executor  = new SDataQueryExecutor(client);
            var builder   = CreateQueryBuilder <Contact>(true);

            builder.AddResultOperator(new WithExtensionArgResultOperator("foo", "bar"));
            builder.AddResultOperator(new CountAsyncResultOperator(CancellationToken.None));
            executor.ExecuteScalarAsync <int>(builder.Build(), CancellationToken.None).Wait();

            Assert.That(parmsList[0].ExtensionArgs, Is.EqualTo(new Dictionary <string, string> {
                { "foo", "bar" }
            }));
        }
Beispiel #4
0
        public void ScalarAsync_All_Different_Test()
        {
            var parmsList = new List <SDataParameters>();
            var client    = CreateClientAsync(parmsList, CreateCollection <object>(null, 3), CreateCollection <object>(null, 2));
            var executor  = new SDataQueryExecutor(client);
            var builder   = CreateQueryBuilder <Contact>(true);

            builder.AddResultOperator(new AllAsyncResultOperator(Expression.Constant(true), CancellationToken.None));
            var result = executor.ExecuteScalarAsync <bool>(builder.Build(), CancellationToken.None).Result;

            Assert.That(parmsList[0].Count, Is.EqualTo(0));
            Assert.That(parmsList[1].Count, Is.EqualTo(0));
            Assert.That(parmsList[1].Where, Is.EqualTo("true"));
            Assert.That(result, Is.False);
        }