Exemplo n.º 1
0
        public void GivenNullRoot_WhenValidateRecursively_ThenCorrectValidationResults()
        {
            RecursiveValidator      validator = new RecursiveValidator(null);
            List <ValidationResult> results   = validator.ValidateObjectRecursively(null);

            Assert.Empty(results);
        }
Exemplo n.º 2
0
        public void GivenNullChild_WhenValidateRecursively_ThenCorrectValidationResults(object instance)
        {
            RecursiveValidator      validator = new RecursiveValidator(null);
            List <ValidationResult> results   = validator.ValidateObjectRecursively(instance);

            Assert.Empty(results);
        }
Exemplo n.º 3
0
        public void GivenValidNestedStructure_WhenValidateRecursively_ThenCorrectValidationResults()
        {
            RecursiveValidator      validator = new RecursiveValidator(null);
            List <ValidationResult> results   = validator.ValidateObjectRecursively(NestedList.Valid());

            Assert.Empty(results);
        }
Exemplo n.º 4
0
        public void GivenValidCyclicObjectGraph_WhenValidateRecursively_ThenCorrectValidationResults()
        {
            RecursiveValidator      validator = new RecursiveValidator(null);
            List <ValidationResult> results   = validator.ValidateObjectRecursively(CyclicObjectGraph.Valid());

            Assert.Empty(results);
        }
        public void GivenValidNullablePrimitives_WhenValidateRecursively_ThenCorrectValidationResults()
        {
            RecursiveValidator      validator = new RecursiveValidator(null);
            List <ValidationResult> results   = validator.ValidateObjectRecursively(NullablePrimitives.Valid());

            Assert.Empty(results);
        }
Exemplo n.º 6
0
        public void GivenValidObject_WhenValidateObjectRecursively_ThenNoValidationResults()
        {
            RecursiveValidator      validator = new RecursiveValidator(null);
            List <ValidationResult> results   = validator.ValidateObjectRecursively(TestStructure.Valid());

            Assert.Empty(results);
        }
Exemplo n.º 7
0
        public void GivenInvalidParent_WhenValidateRecursively_ThenCorrectValidationResults()
        {
            RecursiveValidator      validator = new RecursiveValidator(null);
            List <ValidationResult> results   = validator.ValidateObjectRecursively(CyclicObjectGraph.WithInvalidParent());

            Assert.Single(results);
            ValidationResultUtility.AssertValidationResultEquals(results[0], "The RequiredString field is required.", "RequiredString");
        }
Exemplo n.º 8
0
        public void GivenInvalidObject_WhenValidateObjectRecursively_ThenCorrectValidationResults()
        {
            RecursiveValidator      validator = new RecursiveValidator(null);
            List <ValidationResult> results   = validator.ValidateObjectRecursively(TestStructure.Invalid());

            Assert.Single(results);
            ValidationResultUtility.AssertValidationResultEquals(results[0], "The SomeString field has to be lower cased.", "SomeString");
        }
        public void GivenInvalidChild_WhenValidateRecursively_ThenCorrectValidationResults(object dictionary, string key)
        {
            RecursiveValidator      validator = new RecursiveValidator(null);
            List <ValidationResult> results   = validator.ValidateObjectRecursively(dictionary);

            Assert.Single(results);
            ValidationResultUtility.AssertValidationResultEquals(results[0], "The RequiredString field is required.", $"Child.{key}.RequiredString");
        }
Exemplo n.º 10
0
        public void GivenInvalidGenericType_WithMissingChildValue_ThenCorrectValidationResults()
        {
            RecursiveValidator      validator = new RecursiveValidator(null);
            List <ValidationResult> results   = validator.ValidateObjectRecursively(GenericType.WithMissingChildValue());

            Assert.Single(results);
            ValidationResultUtility.AssertValidationResultEquals(results[0], "The Value field is required.", "Child.Value");
        }
Exemplo n.º 11
0
        public void GivenInvalidFuncs_WhenValidateRecursively_ThenCorrectValidationResults()
        {
            RecursiveValidator      validator = new RecursiveValidator(null);
            List <ValidationResult> results   = validator.ValidateObjectRecursively(Funcs.Invalid());

            Assert.Single(results);
            ValidationResultUtility.AssertValidationResultEquals(results[0], "The SomeFunc field is required.", "SomeFunc");
        }
Exemplo n.º 12
0
        public void GivenInvalidChild_WhenValidateRecursively_ThenCorrectValidationResults()
        {
            RecursiveValidator      validator = new RecursiveValidator(null);
            List <ValidationResult> results   = validator.ValidateObjectRecursively(NestedList.WithInvalidChild());

            Assert.Equal(3, results.Count);
            ValidationResultUtility.AssertValidationResultEquals(results[0], "The RequiredString field is required.", "Child[0].RequiredString");
            ValidationResultUtility.AssertValidationResultEquals(results[1], "The RequiredLong field is required.", "Child[0].RequiredLong");
            ValidationResultUtility.AssertValidationResultEquals(results[2], "The RequiredUnsignedLong field is required.", "Child[0].RequiredUnsignedLong");
        }
        public void GivenInvalidNullablePrimitives_WhenValidateRecursively_ThenCorrectValidationResults()
        {
            RecursiveValidator      validator = new RecursiveValidator(null);
            List <ValidationResult> results   = validator.ValidateObjectRecursively(new NullablePrimitives());

            Assert.Equal(17, results.Count);
            ValidationResultUtility.AssertValidationResultEquals(results[0], "The RequiredString field is required.", "RequiredString");
            ValidationResultUtility.AssertValidationResultEquals(results[1], "The RequiredLong field is required.", "RequiredLong");
            ValidationResultUtility.AssertValidationResultEquals(results[2], "The RequiredUnsignedLong field is required.", "RequiredUnsignedLong");
            ValidationResultUtility.AssertValidationResultEquals(results[3], "The RequiredInt field is required.", "RequiredInt");
            ValidationResultUtility.AssertValidationResultEquals(results[4], "The RequiredUnsignedInt field is required.", "RequiredUnsignedInt");
            ValidationResultUtility.AssertValidationResultEquals(results[5], "The RequiredShort field is required.", "RequiredShort");
            ValidationResultUtility.AssertValidationResultEquals(results[6], "The RequiredUnsignedShort field is required.", "RequiredUnsignedShort");
            ValidationResultUtility.AssertValidationResultEquals(results[7], "The RequiredByte field is required.", "RequiredByte");
            ValidationResultUtility.AssertValidationResultEquals(results[8], "The RequiredChar field is required.", "RequiredChar");
            ValidationResultUtility.AssertValidationResultEquals(results[9], "The RequiredBool field is required.", "RequiredBool");
            ValidationResultUtility.AssertValidationResultEquals(results[10], "The RequiredFloat field is required.", "RequiredFloat");
            ValidationResultUtility.AssertValidationResultEquals(results[11], "The RequiredDouble field is required.", "RequiredDouble");
            ValidationResultUtility.AssertValidationResultEquals(results[12], "The RequiredDecimal field is required.", "RequiredDecimal");
            ValidationResultUtility.AssertValidationResultEquals(results[13], "The RequiredDateTime field is required.", "RequiredDateTime");
            ValidationResultUtility.AssertValidationResultEquals(results[14], "The RequiredDateTimeOffset field is required.", "RequiredDateTimeOffset");
            ValidationResultUtility.AssertValidationResultEquals(results[15], "The RequiredTimeSpan field is required.", "RequiredTimeSpan");
            ValidationResultUtility.AssertValidationResultEquals(results[16], "The RequiredGuid field is required.", "RequiredGuid");
        }