示例#1
0
        public async Task ApiQueryAsyncWithSingletonQueryReturnsResult()
        {
            var api = new TestApi();

            var result = await api.QueryAsync(
                api.Source <string>("Test"), q => q.Single());

            Assert.Equal("Test", result);
        }
示例#2
0
        public async Task ApiQueryAsyncWithQueryReturnsResults()
        {
            var api = new TestApi();

            var results = await api.QueryAsync(
                api.Source <string>("Test"));

            Assert.True(results.SequenceEqual(new string[] { "Test" }));
        }
示例#3
0
        public async Task ApiQueryAsyncCorrectlyForwardsCall()
        {
            var api = new TestApi();

            var queryRequest = new QueryRequest(
                api.Source <string>("Test"), true);
            var queryResult = await api.QueryAsync(queryRequest);

            Assert.True(queryResult.Results.Cast <string>()
                        .SequenceEqual(new string[] { "Test" }));
        }
示例#4
0
        public async Task CanCallQueryAsync()
        {
            var api = new TestApi(serviceProvider);

            serviceProviderFixture.QueryExecutor
            .Setup(x => x.ExecuteQueryAsync <Test>(It.IsAny <QueryContext>(), It.IsAny <IQueryable <Test> >(), It.IsAny <CancellationToken>()))
            .Returns <QueryContext, IQueryable <Test>, CancellationToken>((qc, iq, c) =>
            {
                return(Task.FromResult(new QueryResult(iq)));
            });

            IQueryable <Test> queryable = new List <Test>()
            {
                new Test()
                {
                    Name = "The",
                },
                new Test()
                {
                    Name = "Quick",
                },
                new Test()
                {
                    Name = "Brown",
                },
                new Test()
                {
                    Name = "Fox",
                },
            }.AsQueryable();

            var source  = Expression.Constant(queryable);
            var request = new QueryRequest(new QueryableSource <Test>(source));

            var cancellationToken = CancellationToken.None;
            var result            = await api.QueryAsync(request, cancellationToken);

            result.Results.Should().BeEquivalentTo(queryable);
        }
示例#5
0
        public async Task ApiQueryAsyncCorrectlyForwardsCall()
        {
            var api = new TestApi();

            var queryRequest = new QueryRequest(
                api.Source<string>("Test"));
            var queryResult = await api.QueryAsync(queryRequest);
            Assert.True(queryResult.Results.Cast<string>()
                .SequenceEqual(new string[] { "Test" }));
        }
示例#6
0
        public async Task ApiQueryAsyncWithQueryReturnsResults()
        {
            var api = new TestApi();

            var results = await api.QueryAsync(
                api.Source<string>("Test"));
            Assert.True(results.SequenceEqual(new string[] { "Test" }));
        }