本文整理汇总了C#中ValidatableArgument.IsEqual方法的典型用法代码示例。如果您正苦于以下问题:C# ValidatableArgument.IsEqual方法的具体用法?C# ValidatableArgument.IsEqual怎么用?C# ValidatableArgument.IsEqual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ValidatableArgument
的用法示例。
在下文中一共展示了ValidatableArgument.IsEqual方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddEqualValidationPredicate
public void AddEqualValidationPredicate()
{
// Arrange.
ValidatableArgument<short> argument = new ValidatableArgument<short>("argument", 3);
// Act.
argument.IsEqual(5);
// Assert.
Assert.AreEqual(1, argument.ValidationPredicates.Count());
Assert.IsInstanceOfType(argument.ValidationPredicates.First(), typeof(EqualValidationPredicate<short>));
}
示例2: AddStringEqualValidationPredicate
public void AddStringEqualValidationPredicate()
{
// Arrange.
ValidatableArgument<string> argument =
new ValidatableArgument<string>("argument", "abc");
// Act.
argument.IsEqual("Abc", StringComparison.OrdinalIgnoreCase);
// Assert.
Assert.AreEqual(1, argument.ValidationPredicates.Count());
Assert.IsInstanceOfType(argument.ValidationPredicates.First(), typeof(StringEqualValidationPredicate));
}
示例3: ThrowArgumentOutOfRangeException_WhenTheFirstMatchingValidationRuleIsRangeRule
public void ThrowArgumentOutOfRangeException_WhenTheFirstMatchingValidationRuleIsRangeRule()
{
// Arrange.
IValidatableArgument<int> argument = new ValidatableArgument<int>("argument", 5);
argument.IsEqual(3).IsLessThan(10);
// Act & Assert.
Ensure.ArgumentOutOfRangeExceptionIsThrown(
() =>
{
argument.Throw();
}, "argument");
}
示例4: ThrowArgumentNullException_WhenTheFirstMachingValidationRuleIsNull
public void ThrowArgumentNullException_WhenTheFirstMachingValidationRuleIsNull()
{
// Arrange.
IValidatableArgument<string> argument = new ValidatableArgument<string>("argument", null);
argument.IsEqual("asdf").IsNull();
// Act & Assert.
Ensure.ArgumentNullExceptionIsThrown(
() =>
{
argument.Throw();
}, "argument");
}
示例5: RunInExpectedTime
public void RunInExpectedTime()
{
// Arrange.
ValidatableArgument<string> argument =
new ValidatableArgument<string>("argument", "abc");
// Act & Assert.
Ensure.ActionRunsInExpectedTime(
() =>
{
argument.IsEqual("Abc", StringComparison.OrdinalIgnoreCase);
},
PerformanceConstants.ValidationPredicateExecutionCount,
PerformanceConstants.ValidationPredicateTotalExecutionExpectedTime);
}
示例6: AddEqualValidationPredicate_WhenArgumentIsDateTime
public void AddEqualValidationPredicate_WhenArgumentIsDateTime()
{
// Arrange.
ValidatableArgument<DateTime> argument = new ValidatableArgument<DateTime>("argument", DateTime.Now);
// Act.
argument.IsEqual(DateTime.Now);
// Assert.
Assert.AreEqual(1, argument.ValidationPredicates.Count());
Assert.IsInstanceOfType(argument.ValidationPredicates.First(), typeof(EqualValidationPredicate<DateTime>));
}