public async Task Should_get_rules_from_index() { var rule = new RuleEntity(); A.CallTo(() => indexForRules.GetRulesAsync(app.Id, ct)) .Returns(new List <IRuleEntity> { rule }); var result = await sut.GetRulesAsync(app.Id, ct); Assert.Equal(rule, result.Single()); }
public Task <List <IRuleEntity> > GetRulesAsync(DomainId appId) { return(localCache.GetOrCreateAsync($"GetRulesAsync({appId})", async() => { return await indexRules.GetRulesAsync(appId); })); }
public async Task <IReadOnlyList <IEnrichedRuleEntity> > QueryAsync(Context context) { var rules = await rulesIndex.GetRulesAsync(context.App.Id); var enriched = await ruleEnricher.EnrichAsync(rules, context); return(enriched); }
public async Task <List <IRuleEntity> > GetRulesAsync(DomainId appId) { var rules = await localCache.GetOrCreateAsync($"GetRulesAsync({appId})", () => { return(indexRules.GetRulesAsync(appId)); }); return(rules.ToList()); }
public async Task <List <IRuleEntity> > GetRulesAsync(DomainId appId, CancellationToken ct = default) { var rules = await localCache.GetOrCreateAsync($"GetRulesAsync({appId})", () => { return(indexForRules.GetRulesAsync(appId, ct)); }); return(rules.ToList()); }
public async Task Should_get_rules_from_index_and_enrich() { var original = new List <IRuleEntity> { new RuleEntity() }; var enriched = new List <IEnrichedRuleEntity> { new RuleEntity() }; A.CallTo(() => rulesIndex.GetRulesAsync(appId.Id)) .Returns(original); A.CallTo(() => ruleEnricher.EnrichAsync(original, requestContext)) .Returns(enriched); var result = await sut.QueryAsync(requestContext); Assert.Same(enriched, result); }
public async Task <IReadOnlyList <IEnrichedRuleEntity> > QueryAsync(Context context, CancellationToken ct = default) { var rules = await rulesIndex.GetRulesAsync(context.App.Id, ct); if (rules.Count > 0) { var enriched = await ruleEnricher.EnrichAsync(rules, context, ct); return(enriched); } return(EmptyResults); }
public async Task <IReadOnlyList <IEnrichedRuleEntity> > QueryAsync(Context context) { var rules = await rulesIndex.GetRulesAsync(context.App.Id); rules.RemoveAll(x => x.IsDeleted); if (rules.Count > 0) { var enriched = await ruleEnricher.EnrichAsync(rules, context); return(enriched); } return(EmptyResults); }