public async Task Should_return_multiple_assets_with_total_when_querying_assets_with_total() { var query = @" query { queryAssetsWithTotal(filter: ""my-query"", top: 30, skip: 5) { total items { <FIELDS> } } }".Replace("<FIELDS>", TestAsset.AllFields); var asset = TestAsset.Create(appId, DomainId.NewGuid()); A.CallTo(() => assetQuery.QueryAsync(MatchsAssetContext(), null, A <Q> .That.Matches(x => x.ODataQuery == "?$top=30&$skip=5&$filter=my-query" && x.NoTotal == false))) .Returns(ResultList.CreateFrom(10, asset)); var result = await ExecuteAsync(new ExecutionOptions { Query = query }); var expected = new { data = new { queryAssetsWithTotal = new { total = 10, items = new dynamic[] { TestAsset.Response(asset) } } } }; AssertResult(expected, result); }
public async Task Should_return_multiple_assets_with_total_if_querying_assets_with_total() { var query = CreateQuery(@" query { queryAssetsWithTotal(filter: 'my-query', top: 30, skip: 5) { total items { <FIELDS_ASSET> } } }"); var asset = TestAsset.Create(DomainId.NewGuid()); A.CallTo(() => assetQuery.QueryAsync(MatchsAssetContext(), null, A <Q> .That.Matches(x => x.QueryAsOdata == "?$top=30&$skip=5&$filter=my-query" && !x.NoTotal), A <CancellationToken> ._)) .Returns(ResultList.CreateFrom(10, asset)); var result = await ExecuteAsync(new ExecutionOptions { Query = query }); var expected = new { data = new { queryAssetsWithTotal = new { total = 10, items = new[] { TestAsset.Response(asset) } } } }; AssertResult(expected, result); }