public async Task ApiQueryAsyncWithSingletonQueryReturnsResult() { var api = new TestApi(); var result = await api.QueryAsync( api.Source <string>("Test"), q => q.Single()); Assert.Equal("Test", result); }
public async Task ApiQueryAsyncWithQueryReturnsResults() { var api = new TestApi(); var results = await api.QueryAsync( api.Source <string>("Test")); Assert.True(results.SequenceEqual(new string[] { "Test" })); }
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" })); }
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); }
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" })); }
public async Task ApiQueryAsyncWithQueryReturnsResults() { var api = new TestApi(); var results = await api.QueryAsync( api.Source<string>("Test")); Assert.True(results.SequenceEqual(new string[] { "Test" })); }