public void ClassValidator_Validate_IDataErrorInfoModelWithError()
        {
            // Arrange
            DataErrorInfo1 model = new DataErrorInfo1()
            {
                Error = "This is an error message."
            };
            ModelMetadata metadata = _metadataProvider.GetMetadataForType(
                () => model,
                typeof(DataErrorInfo1)
                );

            var validator =
                new DataErrorInfoModelValidatorProvider.DataErrorInfoClassModelValidator(
                    metadata,
                    new ControllerContext()
                    );

            // Act
            ModelValidationResult[] result = validator.Validate(null).ToArray();

            // Assert
            ModelValidationResult modelValidationResult = Assert.Single(result);

            Assert.Equal("This is an error message.", modelValidationResult.Message);
        }
        public void ClassValidator_Validate_NonIDataErrorInfoModelReturnsEmptyResults()
        {
            // Arrange
            object model = new object();
            ModelMetadata metadata = _metadataProvider.GetMetadataForType(() => model, typeof(object));

            var validator = new DataErrorInfoModelValidatorProvider.DataErrorInfoClassModelValidator(metadata, new ControllerContext());

            // Act
            ModelValidationResult[] result = validator.Validate(null).ToArray();

            // Assert
            Assert.Empty(result);
        }
        public void ClassValidator_Validate_IDataErrorInfoModelWithNoErrorReturnsEmptyResults()
        {
            // Arrange
            DataErrorInfo1 model    = new DataErrorInfo1();
            ModelMetadata  metadata = _metadataProvider.GetMetadataForType(() => model, typeof(DataErrorInfo1));

            var validator = new DataErrorInfoModelValidatorProvider.DataErrorInfoClassModelValidator(metadata, new ControllerContext());

            // Act
            ModelValidationResult[] result = validator.Validate(null).ToArray();

            // Assert
            Assert.AreEqual(0, result.Length);
        }
        public void ClassValidator_Validate_IDataErrorInfoModelWithError()
        {
            // Arrange
            DataErrorInfo1 model = new DataErrorInfo1()
            {
                Error = "This is an error message."
            };
            ModelMetadata metadata = _metadataProvider.GetMetadataForType(() => model, typeof(DataErrorInfo1));

            var validator = new DataErrorInfoModelValidatorProvider.DataErrorInfoClassModelValidator(metadata, new ControllerContext());

            // Act
            ModelValidationResult[] result = validator.Validate(null).ToArray();

            // Assert
            ModelValidationResult modelValidationResult = Assert.Single(result);
            Assert.Equal("This is an error message.", modelValidationResult.Message);
        }
        public void ClassValidator_Validate_NonIDataErrorInfoModelReturnsEmptyResults()
        {
            // Arrange
            object model = new object();
            ModelMetadata metadata = _metadataProvider.GetMetadataForType(() => model, typeof(object));

            var validator = new DataErrorInfoModelValidatorProvider.DataErrorInfoClassModelValidator(metadata, new ControllerContext());

            // Act
            ModelValidationResult[] result = validator.Validate(null).ToArray();

            // Assert
            Assert.Empty(result);
        }