示例#1
0
        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());
        }
示例#2
0
 public Task <List <IRuleEntity> > GetRulesAsync(DomainId appId)
 {
     return(localCache.GetOrCreateAsync($"GetRulesAsync({appId})", async() =>
     {
         return await indexRules.GetRulesAsync(appId);
     }));
 }
示例#3
0
        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);
        }
示例#4
0
        public async Task <List <IRuleEntity> > GetRulesAsync(DomainId appId)
        {
            var rules = await localCache.GetOrCreateAsync($"GetRulesAsync({appId})", () =>
            {
                return(indexRules.GetRulesAsync(appId));
            });

            return(rules.ToList());
        }
示例#5
0
        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());
        }
示例#6
0
        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);
        }
示例#7
0
        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);
        }
示例#8
0
        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);
        }