public AssetQueryServiceTests() { requestContext = new Context(Mocks.FrontendUser(), Mocks.App(appId)); SetupEnricher(); A.CallTo(() => queryParser.ParseAsync(requestContext, A <Q> ._)) .ReturnsLazily(c => Task.FromResult(c.GetArgument <Q>(1) !)); sut = new AssetQueryService(assetEnricher, assetRepository, assetLoader, assetFolderRepository, queryParser); }
public async Task <IResultList <IEnrichedAssetEntity> > QueryAsync(Context context, DomainId?parentId, Q q) { Guard.NotNull(context, nameof(context)); if (q == null) { return(EmptyAssets); } using (Profiler.TraceMethod <AssetQueryService>()) { q = await queryParser.ParseAsync(context, q); var assets = await assetRepository.QueryAsync(context.App.Id, parentId, q); if (q.Ids != null && q.Ids.Count > 0) { assets = assets.SortSet(x => x.Id, q.Ids); } return(await TransformAsync(context, assets)); } }
public async Task <IResultList <IEnrichedAssetEntity> > QueryAsync(Context context, DomainId?parentId, Q q, CancellationToken ct = default) { Guard.NotNull(context, nameof(context)); if (q == null) { return(EmptyAssets); } using (Telemetry.Activities.StartActivity("AssetQueryService/QueryAsync")) { q = await queryParser.ParseAsync(context, q); var assets = await QueryCoreAsync(context, parentId, q, ct); if (q.Ids != null && q.Ids.Count > 0) { assets = assets.SortSet(x => x.Id, q.Ids); } return(await TransformAsync(context, assets, ct)); } }
public async Task Should_skip_total_if_set_in_context() { var q = await sut.ParseAsync(requestContext.Clone(b => b.WithoutTotal()), Q.Empty); Assert.True(q.NoTotal); }