当前位置: 首页>>代码示例>>C#>>正文


C# TestValidator.CreateDescriptor方法代码示例

本文整理汇总了C#中TestValidator.CreateDescriptor方法的典型用法代码示例。如果您正苦于以下问题:C# TestValidator.CreateDescriptor方法的具体用法?C# TestValidator.CreateDescriptor怎么用?C# TestValidator.CreateDescriptor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestValidator的用法示例。


在下文中一共展示了TestValidator.CreateDescriptor方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Should_store_comparison_type

		public void Should_store_comparison_type() {
			var validator = new TestValidator { v => v.RuleFor(x => x.Surname).Equal("Foo") };
			var descriptor = validator.CreateDescriptor();
			var propertyValidator = descriptor.GetValidatorsForMember("Surname").Cast<EqualValidator>().Single();

			propertyValidator.Comparison.ShouldEqual(Comparison.Equal);
		}
开发者ID:Rocketmakers,项目名称:FluentValidation,代码行数:7,代码来源:EqualValidatorTests.cs

示例2: Should_store_property_to_compare

		public void Should_store_property_to_compare() {
			var validator = new TestValidator { v => v.RuleFor(x => x.Forename).Equal(x => x.Surname) };
			var descriptor = validator.CreateDescriptor();
			var propertyValidator = descriptor.GetValidatorsForMember("Forename").Cast<EqualValidator>().Single();

			propertyValidator.MemberToCompare.ShouldEqual(typeof(Person).GetProperty("Surname"));
		}
开发者ID:Rocketmakers,项目名称:FluentValidation,代码行数:7,代码来源:EqualValidatorTests.cs

示例3: Should_store_comparison_type

		public void Should_store_comparison_type() {
			var validator = new TestValidator(v => v.RuleFor(x => x.Forename).NotEqual(x => x.Surname));
			var propertyValidator = validator.CreateDescriptor()
				.GetValidatorsForMember("Forename")
				.OfType<NotEqualValidator>()
				.Single();
			propertyValidator.Comparison.ShouldEqual(Comparison.NotEqual);
		}
开发者ID:Rocketmakers,项目名称:FluentValidation,代码行数:8,代码来源:NotEqualValidatorTests.cs

示例4: Extracts_property_from_expression

 public void Extracts_property_from_expression()
 {
     var validator = new TestValidator(v => v.RuleFor(x => x.Id).LessThan(x => x.AnotherInt));
     var propertyValidator = validator.CreateDescriptor().GetValidatorsForMember("Id").OfType<LessThanValidator>().Single();
     propertyValidator.MemberToCompare.ShouldEqual(typeof(Person).GetProperty("AnotherInt"));
 }
开发者ID:cjberg,项目名称:FluentValidation,代码行数:6,代码来源:LessThanValidatorTester.cs

示例5: Setting_global_resource_provider_propogates_to_metadata

        public void Setting_global_resource_provider_propogates_to_metadata()
        {
            ValidatorOptions.ResourceProviderType = typeof(TestMessages);
            var validator = new TestValidator();
            validator.RuleFor(x => x.Forename).NotNull();

            var descriptor = validator.CreateDescriptor();
            var resourceType = descriptor.GetMembersWithValidators().First().First().ErrorMessageSource.ResourceType;

            Assert.Equal(typeof (TestMessages), resourceType);
        }
开发者ID:xelossan,项目名称:FluentValidation,代码行数:11,代码来源:LocalisedMessagesTester.cs

示例6: Not_Setting_global_resource_provider_uses_default_messages_in_metadata

        public void Not_Setting_global_resource_provider_uses_default_messages_in_metadata()
        {
            var validator = new TestValidator();
            validator.RuleFor(x => x.Forename).NotNull();

            var descriptor = validator.CreateDescriptor();
            var resourceType = descriptor.GetMembersWithValidators().First().First().ErrorMessageSource.ResourceType;

            Assert.Equal(typeof(Messages), resourceType);
        }
开发者ID:xelossan,项目名称:FluentValidation,代码行数:10,代码来源:LocalisedMessagesTester.cs


注:本文中的TestValidator.CreateDescriptor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。