/// <summary>
        /// エラーメッセージの設定
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public override string FormatErrorMessage(string name)
        {
            Attr.ErrorMessage             = this.ErrorMessage;
            Attr.ErrorMessageResourceType = this.ErrorMessageResourceType;
            Attr.ErrorMessageResourceName = this.ErrorMessageResourceName;

            return(Attr.FormatErrorMessage(name));
        }
Ejemplo n.º 2
0
        public void GetClientValidationRules_ReturnsEmailValidationRule()
        {
            IServiceProvider       services = Substitute.For <IServiceProvider>();
            IModelMetadataProvider provider = new EmptyModelMetadataProvider();
            ModelMetadata          metadata = provider.GetMetadataForProperty(typeof(AdaptersModel), "EmailAddress");

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

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