本文整理汇总了C#中ValidatableArgument.IsNotEqual方法的典型用法代码示例。如果您正苦于以下问题:C# ValidatableArgument.IsNotEqual方法的具体用法?C# ValidatableArgument.IsNotEqual怎么用?C# ValidatableArgument.IsNotEqual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ValidatableArgument
的用法示例。
在下文中一共展示了ValidatableArgument.IsNotEqual方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddNotEqualValidationPredicate
public void AddNotEqualValidationPredicate()
{
// Arrange.
ValidatableArgument<short> argument = new ValidatableArgument<short>("argument", 3);
// Act.
argument.IsNotEqual(5);
// Assert.
Assert.AreEqual(1, argument.ValidationPredicates.Count());
Assert.IsInstanceOfType(argument.ValidationPredicates.First(), typeof(NotEqualValidationPredicate<short>));
}
示例2: AddStringNotEqualValidationPredicate
public void AddStringNotEqualValidationPredicate()
{
// Arrange.
ValidatableArgument<string> argument =
new ValidatableArgument<string>("argument", "abc");
// Act.
argument.IsNotEqual("Abc", StringComparison.OrdinalIgnoreCase);
// Assert.
Assert.AreEqual(1, argument.ValidationPredicates.Count());
Assert.IsInstanceOfType(argument.ValidationPredicates.First(), typeof(StringNotEqualValidationPredicate));
}
示例3: ThrowArgumentException_WhenTheFirstMachingValidationRuleIsEqual
public void ThrowArgumentException_WhenTheFirstMachingValidationRuleIsEqual()
{
// Arrange.
IValidatableArgument<string> argument = new ValidatableArgument<string>("argument", "asdf");
argument.IsNotEqual("asdf").IsEqual("asdf").IsNotNull();
// Act & Assert.
Ensure.ArgumentExceptionIsThrown(
() =>
{
argument.Throw();
}, "argument");
}
示例4: RunInExpectedTime
public void RunInExpectedTime()
{
// Arrange.
ValidatableArgument<string> argument =
new ValidatableArgument<string>("argument", "abc");
// Act & Assert.
Ensure.ActionRunsInExpectedTime(
() =>
{
argument.IsNotEqual("Abc", StringComparison.OrdinalIgnoreCase);
},
PerformanceConstants.ValidationPredicateExecutionCount,
PerformanceConstants.ValidationPredicateTotalExecutionExpectedTime);
}
示例5: ReturnTrueAndCreatesArgumentException_WhenArgumentIsNotNullAndHasMatchesOfDefaultValidationType
public void ReturnTrueAndCreatesArgumentException_WhenArgumentIsNotNullAndHasMatchesOfDefaultValidationType()
{
// Arrange.
IValidatableArgument<string> validatableArgument = new ValidatableArgument<string>("validatableArgument", "xxx");
validatableArgument.IsNotEqual("asdf");
// Act.
ArgumentException argumentException;
bool result = validatableArgument.TryGetArgumentException(out argumentException);
// Assert.
Assert.IsTrue(result);
Assert.IsNotNull(argumentException);
Assert.IsInstanceOfType(argumentException, typeof(ArgumentException));
Assert.AreEqual("validatableArgument", argumentException.ParamName);
Assert.AreEqual("Argument value <xxx> is not equal to <asdf>.\r\nParameter name: validatableArgument", argumentException.Message);
}
示例6: AddNotEqualValidationPredicate_WhenArgumentIsDateTime
public void AddNotEqualValidationPredicate_WhenArgumentIsDateTime()
{
// Arrange.
ValidatableArgument<DateTime> argument = new ValidatableArgument<DateTime>("argument", DateTime.Now);
// Act.
argument.IsNotEqual(DateTime.Now);
// Assert.
Assert.AreEqual(1, argument.ValidationPredicates.Count());
Assert.IsInstanceOfType(argument.ValidationPredicates.First(), typeof(NotEqualValidationPredicate<DateTime>));
}