public void ComplexPropertyValidator_does_not_run_complex_type_validation_if_property_is_null() { var entity = new EntityWithOptionalNestedComplexType { ID = 1 }; var mockInternalEntityEntry = Internal.MockHelper.CreateMockInternalEntityEntry(entity); var propertyValidator = new ComplexPropertyValidator( "AirportDetails", new ValidationAttributeValidator[0], new ComplexTypeValidator( new[] { new PropertyValidator( "AirportCode", new[] { new ValidationAttributeValidator(new RequiredAttribute(), null) }) }, new ValidationAttributeValidator[0])); var results = propertyValidator.Validate( MockHelper.CreateEntityValidationContext(mockInternalEntityEntry.Object), mockInternalEntityEntry.Object.Property("AirportDetails")); Assert.False(results.Any()); }
public void ComplexPropertyValidator_does_not_run_complex_type_validation_if_property_is_null() { var entity = new EntityWithOptionalNestedComplexType { ID = 1 }; var mockInternalEntityEntry = Internal.MockHelper.CreateMockInternalEntityEntry(entity); var propertyValidator = new ComplexPropertyValidator( "AirportDetails", new ValidationAttributeValidator[0], new ComplexTypeValidator( new[] { new PropertyValidator( "AirportCode", new[] { new ValidationAttributeValidator(new RequiredAttribute(), null) }) }, new ValidationAttributeValidator[0])); var results = propertyValidator.Validate( MockHelper.CreateEntityValidationContext(mockInternalEntityEntry.Object), mockInternalEntityEntry.Object.Property("AirportDetails")); Assert.False(results.Any()); }