本文整理汇总了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);
}
示例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"));
}
示例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);
}
示例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"));
}
示例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);
}
示例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);
}