public void PropertyValidator_Validate_DoesNotReadPropertyValue()
        {
            // Arrange
            ObservableModel model    = new ObservableModel();
            ModelMetadata   metadata = _metadataProvider.GetMetadataForProperty(
                () => model.TheProperty,
                typeof(ObservableModel),
                "TheProperty"
                );
            ControllerContext controllerContext = new ControllerContext();

            // Act
            ModelValidator[] validators = new DataErrorInfoModelValidatorProvider()
                                          .GetValidators(metadata, controllerContext)
                                          .ToArray();
            ModelValidationResult[] results = validators
                                              .SelectMany(o => o.Validate(model))
                                              .ToArray();

            // Assert
            Assert.Equal(
                new[]
            {
                typeof(DataErrorInfoModelValidatorProvider.DataErrorInfoPropertyModelValidator)
            },
                Array.ConvertAll(validators, o => o.GetType())
                );
            Assert.Equal(new[] { "TheProperty" }, model.GetColumnNamesPassed().ToArray());
            Assert.Empty(results);
            Assert.False(model.PropertyWasRead());
        }
        public void PropertyValidator_Validate_DoesNotReadPropertyValue()
        {
            // Arrange
            ObservableModel   model             = new ObservableModel();
            ModelMetadata     metadata          = _metadataProvider.GetMetadataForProperty(() => model.TheProperty, typeof(ObservableModel), "TheProperty");
            ControllerContext controllerContext = new ControllerContext();

            // Act
            ModelValidator[]        validators = new DataErrorInfoModelValidatorProvider().GetValidators(metadata, controllerContext).ToArray();
            ModelValidationResult[] results    = validators.SelectMany(o => o.Validate(model)).ToArray();

            // Assert
            CollectionAssert.AreEqual(new Type[] { typeof(DataErrorInfoModelValidatorProvider.DataErrorInfoPropertyModelValidator) }, Array.ConvertAll(validators, o => o.GetType()), "Provider did not return expected validator.");
            CollectionAssert.AreEquivalent(new string[] { "TheProperty" }, model.GetColumnNamesPassed(), "Model.get_Item() was not called as expected.");
            Assert.AreEqual(0, results.Length);
            Assert.IsFalse(model.PropertyWasRead(), "Property should not have been read by provider or validator.");
        }
        public void PropertyValidator_Validate_DoesNotReadPropertyValue()
        {
            // Arrange
            ObservableModel model = new ObservableModel();
            ModelMetadata metadata = _metadataProvider.GetMetadataForProperty(() => model.TheProperty, typeof(ObservableModel), "TheProperty");
            ControllerContext controllerContext = new ControllerContext();

            // Act
            ModelValidator[] validators = new DataErrorInfoModelValidatorProvider().GetValidators(metadata, controllerContext).ToArray();
            ModelValidationResult[] results = validators.SelectMany(o => o.Validate(model)).ToArray();

            // Assert
            Assert.Equal(new[] { typeof(DataErrorInfoModelValidatorProvider.DataErrorInfoPropertyModelValidator) }, Array.ConvertAll(validators, o => o.GetType()));
            Assert.Equal(new[] { "TheProperty" }, model.GetColumnNamesPassed().ToArray());
            Assert.Empty(results);
            Assert.False(model.PropertyWasRead());
        }
        public void PropertyValidator_Validate_DoesNotReadPropertyValue() {
            // Arrange
            ObservableModel model = new ObservableModel();
            ModelMetadata metadata = _metadataProvider.GetMetadataForProperty(() => model.TheProperty, typeof(ObservableModel), "TheProperty");
            ControllerContext controllerContext = new ControllerContext();

            // Act
            ModelValidator[] validators = new DataErrorInfoModelValidatorProvider().GetValidators(metadata, controllerContext).ToArray();
            ModelValidationResult[] results = validators.SelectMany(o => o.Validate(model)).ToArray();

            // Assert
            CollectionAssert.AreEqual(new Type[] { typeof(DataErrorInfoModelValidatorProvider.DataErrorInfoPropertyModelValidator) }, Array.ConvertAll(validators, o => o.GetType()), "Provider did not return expected validator.");
            CollectionAssert.AreEquivalent(new string[] { "TheProperty" }, model.GetColumnNamesPassed(), "Model.get_Item() was not called as expected.");
            Assert.AreEqual(0, results.Length);
            Assert.IsFalse(model.PropertyWasRead(), "Property should not have been read by provider or validator.");
        }