public void RegisterDefaultValidatableObjectAdapterFactoryGuardClauses()
        {
            var provider = new DataAnnotationsModelValidatorProvider();

            // Factory cannot be null
            Assert.ThrowsArgumentNull(
                () => provider.RegisterDefaultValidatableObjectAdapterFactory(null),
                "factory");
        }
        public void RegisterDefaultValidatableObjectAdapterFactory()
        {
            // Arrange
            var            provider  = new DataAnnotationsModelValidatorProvider();
            var            metadata  = _metadataProvider.GetMetadataForType(() => null, typeof(MyValidatableClass));
            ModelValidator validator = new Mock <ModelValidator>(metadata, _noValidatorProviders).Object;
            DataAnnotationsValidatableObjectAdapterFactory factory = delegate { return(validator); };

            provider.RegisterDefaultValidatableObjectAdapterFactory(factory);

            // Act
            var result = provider.GetValidators(metadata, _noValidatorProviders).Single();

            // Assert
            Assert.Same(validator, result);
        }
        public void RegisterDefaultValidatableObjectAdapterFactoryGuardClauses()
        {
            var provider = new DataAnnotationsModelValidatorProvider();

            // Factory cannot be null
            Assert.ThrowsArgumentNull(
                () => provider.RegisterDefaultValidatableObjectAdapterFactory(null),
                "factory");
        }
        public void RegisterDefaultValidatableObjectAdapterFactory()
        {
            // Arrange
            var provider = new DataAnnotationsModelValidatorProvider();
            var metadata = _metadataProvider.GetMetadataForType(() => null, typeof(MyValidatableClass));
            ModelValidator validator = new Mock<ModelValidator>(_noValidatorProviders).Object;
            DataAnnotationsValidatableObjectAdapterFactory factory = delegate { return validator; };
            provider.RegisterDefaultValidatableObjectAdapterFactory(factory);

            // Act
            var result = provider.GetValidators(metadata, _noValidatorProviders).Single();

            // Assert
            Assert.Same(validator, result);
        }