public void ComplexPropertyValidator_does_not_return_errors_if_complex_type_validator_is_null()
        {
            var entity = new FlightSegmentWithNestedComplexTypesWithTypeLevelValidation
            {
                Departure = new DepartureArrivalInfoWithNestedComplexType
                {
                    Airport = new AirportDetails
                    {
                    },
                },
            };

            var mockInternalEntityEntry = Internal.MockHelper.CreateMockInternalEntityEntry(entity);
            var propertyValidator       = new ComplexPropertyValidator(
                "Departure", new ValidationAttributeValidator[0],
                null);

            var results = propertyValidator.Validate(
                MockHelper.CreateEntityValidationContext(mockInternalEntityEntry.Object),
                mockInternalEntityEntry.Object.Property("Departure"));

            Assert.False(results.Any());
        }
        public void ComplexPropertyValidator_does_not_return_errors_if_complex_type_validator_is_null()
        {
            var entity = new FlightSegmentWithNestedComplexTypesWithTypeLevelValidation
            {
                Departure = new DepartureArrivalInfoWithNestedComplexType
                {
                    Airport = new AirportDetails
                    {
                    },
                },
            };

            var mockInternalEntityEntry = Internal.MockHelper.CreateMockInternalEntityEntry(entity);
            var propertyValidator = new ComplexPropertyValidator(
                "Departure", new ValidationAttributeValidator[0],
                null);

            var results = propertyValidator.Validate(
                MockHelper.CreateEntityValidationContext(mockInternalEntityEntry.Object),
                mockInternalEntityEntry.Object.Property("Departure"));

            Assert.False(results.Any());
        }
        public void ValidatableObjectValidator_returns_errors_if_entity_IValidatableObject_validation_fails()
        {
            var entity = new FlightSegmentWithNestedComplexTypesWithTypeLevelValidation
            {
                Aircraft = new AircraftInfo
                {
                    Code = "A380"
                },
                FlightNumber = "QF0006"
            };

            var mockInternalEntityEntry = Internal.MockHelper.CreateMockInternalEntityEntry(entity);

            var validator = new ValidatableObjectValidator(null);

            var results = validator.Validate(MockHelper.CreateEntityValidationContext(mockInternalEntityEntry.Object), null);

            ValidationErrorHelper.VerifyResults(
                new[]
                    {
                        new Tuple<string, string>("Aircraft.Code", "Your trip may end in Singapore."),
                        new Tuple<string, string>("FlightNumber", "Your trip may end in Singapore.")
                    }, results);
        }
        public void ValidatableObjectValidator_returns_errors_if_entity_IValidatableObject_validation_fails()
        {
            var entity = new FlightSegmentWithNestedComplexTypesWithTypeLevelValidation
            {
                Aircraft = new AircraftInfo
                {
                    Code = "A380"
                },
                FlightNumber = "QF0006"
            };

            var mockInternalEntityEntry = Internal.MockHelper.CreateMockInternalEntityEntry(entity);

            var validator = new ValidatableObjectValidator(null);

            var results = validator.Validate(MockHelper.CreateEntityValidationContext(mockInternalEntityEntry.Object), null);

            ValidationErrorHelper.VerifyResults(
                new[]
            {
                new Tuple <string, string>("Aircraft.Code", "Your trip may end in Singapore."),
                new Tuple <string, string>("FlightNumber", "Your trip may end in Singapore.")
            }, results);
        }