Пример #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));
            }
        }
        public void GetChildManifestValuesShouldCombineApplicablePolymorphicValuesWithManifestValue([ManifestModel] ManifestValue value,
                                                                                                    [ManifestModel] ManifestPolymorphicType type1,
                                                                                                    [ManifestModel] ManifestPolymorphicType type2,
                                                                                                    [ManifestModel] ManifestPolymorphicType type3,
                                                                                                    [ManifestModel] ManifestValue child1,
                                                                                                    [ManifestModel] ManifestValue child2,
                                                                                                    [ManifestModel] ManifestValue child3,
                                                                                                    [ManifestModel] ManifestValue child4)
        {
            value.ValidatedType = typeof(Person);
            type1.ValidatedType = typeof(Employee);
            type2.ValidatedType = typeof(Manager);
            type3.ValidatedType = typeof(Cleaner);
            value.Children = new[] { child1 };
            type1.Children = new[] { child2 };
            type2.Children = new[] { child3 };
            type3.Children = new[] { child4 };
            value.PolymorphicTypes = new[] { type1, type2, type3 };
            var response = new SuccessfulGetValueToBeValidatedResponse(new Manager());
            var sut = new ValidatedValueBasis(value, response, null);

            Assert.That(() => sut.GetChildManifestValues(), Is.EquivalentTo(new[] { child1, child2, child3 }));
        }