本文整理汇总了C#中ValidatableArgument类的典型用法代码示例。如果您正苦于以下问题:C# ValidatableArgument类的具体用法?C# ValidatableArgument怎么用?C# ValidatableArgument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ValidatableArgument类属于命名空间,在下文中一共展示了ValidatableArgument类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ThrowArgumentException_WhenNameIsEmpty
public void ThrowArgumentException_WhenNameIsEmpty()
{
// Act & Assert.
Ensure.ArgumentExceptionIsThrown(() =>
{
ValidatableArgument<int> argument = new ValidatableArgument<int>(string.Empty, 3);
}, "name");
}
示例2: ThrowArgumentNullException_WhenNameArgumentIsNull
public void ThrowArgumentNullException_WhenNameArgumentIsNull()
{
// Act & Assert.
Ensure.ArgumentNullExceptionIsThrown(() =>
{
ValidatableArgument<int> argument = new ValidatableArgument<int>(null, 3);
}, "name");
}
示例3: ThrowArgumentNullException_WhenValidationPredicateArgumentIsNull
public void ThrowArgumentNullException_WhenValidationPredicateArgumentIsNull()
{
// Arrange.
IArgument<int> argument = new ValidatableArgument<int>("argument", 3);
// Act & Assert.
Ensure.ArgumentNullExceptionIsThrown(() =>
{
argument.AddValidationPredicate(null);
}, "validationPredicate");
}
示例4: ReturnEnumerableEmpty_WhenValidationPredicatesCollectionIsEmpty
public void ReturnEnumerableEmpty_WhenValidationPredicatesCollectionIsEmpty()
{
// Arrange.
ValidatableArgument<int> argument = new ValidatableArgument<int>("argument", 5);
// Act.
IEnumerable<IValidationPredicateResult> validationPredicateResults = argument.MatchValidationPredicates();
// Assert.
Assert.IsFalse(validationPredicateResults.Any());
}
示例5: ReturnTheSameInstance_WhenArgumentIsValidatableArgument
public void ReturnTheSameInstance_WhenArgumentIsValidatableArgument()
{
// Arrange.
IArgument<int> argument = new ValidatableArgument<int>("argument", 3);
// Act.
IValidatableArgument<int> validatableArgument = argument.ToValidatableArgument();
// Assert.
Assert.AreSame(argument, validatableArgument);
}
示例6: CopiesAllProperties_FromTheGivenIArgument
public void CopiesAllProperties_FromTheGivenIArgument()
{
// Arrange.
IArgument<int> argument = new ValidatableArgument<int>("name", 5);
// Act.
ValidatableArgument<int> validatableArgument = new ValidatableArgument<int>(argument);
// Assert.
Assert.AreEqual(argument.Name, validatableArgument.Name);
Assert.AreEqual(argument.Value, validatableArgument.Value);
}
示例7: AddGreaterThanValidationPredicate
public void AddGreaterThanValidationPredicate()
{
// Arrange.
ValidatableArgument<byte> argument = new ValidatableArgument<byte>("argument", 3);
// Act.
argument.IsGreaterThan(5);
// Assert.
Assert.AreEqual(1, argument.ValidationPredicates.Count());
Assert.IsInstanceOfType(argument.ValidationPredicates.First(), typeof(GreaterThanValidationPredicate<byte>));
}
示例8: AddNullableNullValidationPredicate
public void AddNullableNullValidationPredicate()
{
// Arrange.
ValidatableArgument<int?> argument = new ValidatableArgument<int?>("argument", 5);
// Act.
argument.IsNull();
// Assert.
Assert.AreEqual(1, argument.ValidationPredicates.Count());
Assert.IsInstanceOfType(argument.ValidationPredicates.First(), typeof(NullableNullValidationPredicate<int>));
}
示例9: AddNotEqualValidationPredicate_WhenArgumentIsDouble
public void AddNotEqualValidationPredicate_WhenArgumentIsDouble()
{
// Arrange.
ValidatableArgument<double> argument = new ValidatableArgument<double>("argument", 3);
// Act.
argument.IsNotEqual(5);
// Assert.
Assert.AreEqual(1, argument.ValidationPredicates.Count());
Assert.IsInstanceOfType(argument.ValidationPredicates.First(), typeof(NotEqualValidationPredicate<double>));
}
示例10: AddLessThanValidationPredicate_WhenArgumentIsFloat
public void AddLessThanValidationPredicate_WhenArgumentIsFloat()
{
// Arrange.
ValidatableArgument<float> argument = new ValidatableArgument<float>("argument", 3);
// Act.
argument.IsLessThan(5);
// Assert.
Assert.AreEqual(1, argument.ValidationPredicates.Count());
Assert.IsInstanceOfType(argument.ValidationPredicates.First(), typeof(LessThanValidationPredicate<float>));
}
示例11: AddFalseValidationPredicate
public void AddFalseValidationPredicate()
{
// Arrange.
ValidatableArgument<bool> argument = new ValidatableArgument<bool>("argument", true);
// Act.
argument.IsFalse();
// Assert.
Assert.AreEqual(1, argument.ValidationPredicates.Count());
Assert.IsInstanceOfType(argument.ValidationPredicates.First(), typeof(FalseValidationPredicate));
}
示例12: AddGreaterThanOrEqualValidationPredicate_WhenArgumentIsDecimal
public void AddGreaterThanOrEqualValidationPredicate_WhenArgumentIsDecimal()
{
// Arrange.
ValidatableArgument<decimal> argument = new ValidatableArgument<decimal>("argument", 3);
// Act.
argument.IsGreaterThanOrEqual(5);
// Assert.
Assert.AreEqual(1, argument.ValidationPredicates.Count());
Assert.IsInstanceOfType(argument.ValidationPredicates.First(), typeof(GreaterThanOrEqualValidationPredicate<decimal>));
}
示例13: AddInstanceOfTypeValidationPredicate
public void AddInstanceOfTypeValidationPredicate()
{
// Arrange.
ValidatableArgument<object> argument = new ValidatableArgument<object>("argument", new object());
// Act.
argument.IsInstanceOfType(typeof(string));
// Assert.
Assert.AreEqual(1, argument.ValidationPredicates.Count());
Assert.IsInstanceOfType(argument.ValidationPredicates.First(), typeof(InstanceOfTypeValidationPredicate<object>));
}
示例14: 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>));
}
示例15: 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");
}