public void GetValidators_ReturnsExpectedValidatorTypes() {
            // Arrange
            ClientDataTypeModelValidatorProvider validatorProvider = new ClientDataTypeModelValidatorProvider();

            Action<string, bool> checkPropertyIsNumeric = (propertyName, shouldBeNumeric) => {
                ModelValidator[] validators = validatorProvider.GetValidators(_metadataProvider.GetMetadataForProperty(null, typeof(SampleModel), propertyName), new ControllerContext()).ToArray();

                bool isNumeric = validators.OfType<ClientDataTypeModelValidatorProvider.NumericModelValidator>().Any();
                if (isNumeric && !shouldBeNumeric) {
                    Assert.Fail("Property '{0}' shouldn't have returned a numeric validator but did.", propertyName);
                }
                else if (!isNumeric && shouldBeNumeric) {
                    Assert.Fail("Property '{0}' should've returned a numeric validator but didn't.", propertyName);
                }
            };

            // Act & assert
            checkPropertyIsNumeric("Byte", true);
            checkPropertyIsNumeric("SByte", true);
            checkPropertyIsNumeric("Int16", true);
            checkPropertyIsNumeric("UInt16", true);
            checkPropertyIsNumeric("Int32", true);
            checkPropertyIsNumeric("UInt32", true);
            checkPropertyIsNumeric("Int64", true);
            checkPropertyIsNumeric("UInt64", true);
            checkPropertyIsNumeric("Single", true);
            checkPropertyIsNumeric("Double", true);
            checkPropertyIsNumeric("Decimal", true);
            checkPropertyIsNumeric("NullableInt32", true);
            checkPropertyIsNumeric("String", false);
            checkPropertyIsNumeric("Object", false);
        }
        public void GetValidators_ThrowsIfMetadataIsNull() {
            // Arrange
            ClientDataTypeModelValidatorProvider validatorProvider = new ClientDataTypeModelValidatorProvider();

            // Act & assert
            ExceptionHelper.ExpectArgumentNullException(
                delegate {
                    validatorProvider.GetValidators(null, new ControllerContext());
                }, "metadata");
        }
        public void GetValidators_ThrowsIfContextIsNull() {
            // Arrange
            ClientDataTypeModelValidatorProvider validatorProvider = new ClientDataTypeModelValidatorProvider();
            ModelMetadata metadata = _metadataProvider.GetMetadataForType(null, typeof(SampleModel));

            // Act & assert
            ExceptionHelper.ExpectArgumentNullException(
                delegate {
                    validatorProvider.GetValidators(metadata, null);
                }, "context");
        }