public void GetClientValidationRules_ReturnsIntegerValidationRule()
        {
            ModelMetadata metadata = new DataAnnotationsModelMetadataProvider().GetMetadataForProperty(null, typeof(AdaptersModel), "Integer");
            IntegerAdapter adapter = new IntegerAdapter(metadata, new ControllerContext(), new IntegerAttribute());

            String expectedMessage = new IntegerAttribute().FormatErrorMessage(metadata.GetDisplayName());
            ModelClientValidationRule actual = adapter.GetClientValidationRules().Single();

            Assert.Equal(expectedMessage, actual.ErrorMessage);
            Assert.Equal("integer", actual.ValidationType);
            Assert.Empty(actual.ValidationParameters);
        }
        public void GetClientValidationRules_ReturnsIntegerValidationRule()
        {
            ModelMetadata  metadata = new DataAnnotationsModelMetadataProvider().GetMetadataForProperty(null, typeof(AdaptersModel), "Integer");
            IntegerAdapter adapter  = new IntegerAdapter(metadata, new ControllerContext(), new IntegerAttribute());

            String expectedMessage           = new IntegerAttribute().FormatErrorMessage(metadata.GetDisplayName());
            ModelClientValidationRule actual = adapter.GetClientValidationRules().Single();

            Assert.Equal(expectedMessage, actual.ErrorMessage);
            Assert.Equal("integer", actual.ValidationType);
            Assert.Empty(actual.ValidationParameters);
        }
Exemple #3
0
        public void GetClientValidationRules_ReturnsIntegerValidationRule()
        {
            IServiceProvider       services = Substitute.For <IServiceProvider>();
            IModelMetadataProvider provider = new EmptyModelMetadataProvider();
            IntegerAdapter         adapter  = new IntegerAdapter(new IntegerAttribute());
            ModelMetadata          metadata = provider.GetMetadataForProperty(typeof(AdaptersModel), "Integer");

            ClientModelValidationContext context = new ClientModelValidationContext(metadata, provider, services);
            ModelClientValidationRule    actual  = adapter.GetClientValidationRules(context).Single();
            String expectedMessage = new IntegerAttribute().FormatErrorMessage("Integer");

            Assert.Equal(expectedMessage, actual.ErrorMessage);
            Assert.Equal("integer", actual.ValidationType);
            Assert.Empty(actual.ValidationParameters);
        }