本文整理汇总了C#中Validator.CheckThat方法的典型用法代码示例。如果您正苦于以下问题:C# Validator.CheckThat方法的具体用法?C# Validator.CheckThat怎么用?C# Validator.CheckThat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Validator
的用法示例。
在下文中一共展示了Validator.CheckThat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: I_want_to_throw_the_first_exception_from_a_collection
public void I_want_to_throw_the_first_exception_from_a_collection()
{
var secondVariable = 45;
var validator = new Validator();
validator.CheckThat(() => _stringToTest).HasNoSpaces().LengthLessThan(4);
validator.CheckThat(() => secondVariable).IsBetween(56, 100);
validator.ThrowFirst();
}
示例2: I_want_to_throw_an_exception_of_a_given_type_when_checking_multiple_variables
public void I_want_to_throw_an_exception_of_a_given_type_when_checking_multiple_variables()
{
var secondVariable = 45;
var validator = new Validator();
validator.CheckThat(() => _stringToTest).HasNoSpaces().LengthLessThan(4);
validator.CheckThat(() => secondVariable).IsBetween(56, 100);
validator.Throw<ArgumentException>(new[]{"Please check the data entered and try again."});
}