Ejemplo n.º 1
0
        void FindAndAddChildrenToOpenList(ValidatedValueBasis currentBasis,
                                          ValidatedValue currentValue,
                                          Queue <ValidatedValueBasis> openList,
                                          ResolvedValidationOptions options)
        {
            if (!currentValue.ValueResponse.IsSuccess)
            {
                return;
            }

            var actualValue = currentValue.GetActualValue();

            if (!(currentBasis.ManifestValue.CollectionItemValue is null || actualValue is null))
            {
                openList.Enqueue(new ValidatedValueBasis(currentBasis.ManifestValue.CollectionItemValue,
                                                         currentValue.ValueResponse,
                                                         currentValue));
            }

            foreach (var childManifestValue in currentBasis.GetChildManifestValues())
            {
                var valueResponse = valueProvider.GetValueToBeValidated(childManifestValue, actualValue, options);
                openList.Enqueue(new ValidatedValueBasis(childManifestValue, valueResponse, currentValue));
            }
        }
Ejemplo n.º 2
0
        public async Task ExecuteRuleAsyncShouldExecuteRuleLogicWithCorrectValidatedInstances([Frozen] IGetsRuleContext contextFactory,
                                                                                              [RuleContext] RuleContext context,
                                                                                              [ExecutableModel] ExecutableRule rule,
                                                                                              SingleRuleExecutor sut,
                                                                                              ValidatedValue validatedValue,
                                                                                              ValidatedValue parentValue,
                                                                                              [RuleResult] RuleResult expectedResult)
        {
            rule.ValidatedValue        = validatedValue;
            validatedValue.ParentValue = parentValue;

            Mock.Get(contextFactory).Setup(x => x.GetRuleContext(rule)).Returns(context);
            Mock.Get(rule.RuleLogic)
            .Setup(x => x.GetResultAsync(It.IsAny <object>(), It.IsAny <object>(), It.IsAny <RuleContext>(), It.IsAny <CancellationToken>()))
            .Returns(() => Task.FromResult(expectedResult));

            await sut.ExecuteRuleAsync(rule);

            Mock.Get(rule.RuleLogic)
            .Verify(x => x.GetResultAsync(validatedValue.GetActualValue(), parentValue.GetActualValue(), It.IsAny <RuleContext>(), It.IsAny <CancellationToken>()), Times.Once);
        }