本文整理汇总了C#中ValidatableArgument类的典型用法代码示例。如果您正苦于以下问题:C# ValidatableArgument类的具体用法?C# ValidatableArgument怎么用?C# ValidatableArgument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ValidatableArgument类属于命名空间,在下文中一共展示了ValidatableArgument类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ThrowArgumentException_WhenNameIsEmpty
public void ThrowArgumentException_WhenNameIsEmpty()
{
// Act & Assert.
Ensure.ArgumentExceptionIsThrown(() =>
{
ValidatableArgument<int> argument = new ValidatableArgument<int>(string.Empty, 3);
}, "name");
}
开发者ID:veskokolev,项目名称:Bytes2you.Validation,代码行数:8,代码来源:Constructors_Should.cs
示例2: ThrowArgumentNullException_WhenNameArgumentIsNull
public void ThrowArgumentNullException_WhenNameArgumentIsNull()
{
// Act & Assert.
Ensure.ArgumentNullExceptionIsThrown(() =>
{
ValidatableArgument<int> argument = new ValidatableArgument<int>(null, 3);
}, "name");
}
开发者ID:veskokolev,项目名称:Bytes2you.Validation,代码行数:8,代码来源:Constructors_Should.cs
示例3: ThrowArgumentNullException_WhenValidationPredicateArgumentIsNull
public void ThrowArgumentNullException_WhenValidationPredicateArgumentIsNull()
{
// Arrange.
IArgument<int> argument = new ValidatableArgument<int>("argument", 3);
// Act & Assert.
Ensure.ArgumentNullExceptionIsThrown(() =>
{
argument.AddValidationPredicate(null);
}, "validationPredicate");
}
开发者ID:veskokolev,项目名称:Bytes2you.Validation,代码行数:11,代码来源:AddValidationPredicate_Should.cs
示例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());
}
开发者ID:veskokolev,项目名称:Bytes2you.Validation,代码行数:11,代码来源:MatchValidationPredicates_Should.cs
示例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);
}
开发者ID:veskokolev,项目名称:Bytes2you.Validation,代码行数:11,代码来源:ToValidatableArgument_Should.cs
示例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);
}
开发者ID:veskokolev,项目名称:Bytes2you.Validation,代码行数:12,代码来源:Constructors_Should.cs
示例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>));
}
开发者ID:veskokolev,项目名称:Bytes2you.Validation,代码行数:12,代码来源:IsGreaterThan_Should.cs
示例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>));
}
开发者ID:veskokolev,项目名称:Bytes2you.Validation,代码行数:12,代码来源:IsNull_Should.cs
示例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>));
}
开发者ID:veskokolev,项目名称:Bytes2you.Validation,代码行数:12,代码来源:IsNotEqual_Should.cs
示例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>));
}
开发者ID:veskokolev,项目名称:Bytes2you.Validation,代码行数:12,代码来源:IsLessThan_Should.cs
示例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));
}
开发者ID:veskokolev,项目名称:Bytes2you.Validation,代码行数:12,代码来源:IsFalse_Should.cs
示例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>));
}
开发者ID:veskokolev,项目名称:Bytes2you.Validation,代码行数:12,代码来源:IsGreaterThanOrEqual_Should.cs
示例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>));
}
开发者ID:veskokolev,项目名称:Bytes2you.Validation,代码行数:12,代码来源:IsInstanceOfType_Should.cs
示例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>));
}
开发者ID:veskokolev,项目名称:Bytes2you.Validation,代码行数:12,代码来源:IsEqual_Should.cs
示例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");
}
开发者ID:veskokolev,项目名称:Bytes2you.Validation,代码行数:13,代码来源:Throw_Should.cs
示例16: 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));
}
开发者ID:veskokolev,项目名称:Bytes2you.Validation,代码行数:13,代码来源:IsNotEqual_Should.cs
示例17: AddValidationPredicateToValidationPredicatesCollection_WhenValidationPredicateArgumentIsNotNull
public void AddValidationPredicateToValidationPredicatesCollection_WhenValidationPredicateArgumentIsNotNull()
{
// Arrange.
IValidationPredicate<int> validationPredicate = new LessThanValidationPredicate<int>(5);
ValidatableArgument<int> argument = new ValidatableArgument<int>("argument", 5);
// Act.
argument.AddValidationPredicate(validationPredicate);
// Assert.
Assert.AreEqual(1, argument.ValidationPredicates.Count());
Assert.IsInstanceOfType(argument.ValidationPredicates.First(), typeof(LessThanValidationPredicate<int>));
}
开发者ID:veskokolev,项目名称:Bytes2you.Validation,代码行数:13,代码来源:AddValidationPredicate_Should.cs
示例18: 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");
}
开发者ID:veskokolev,项目名称:Bytes2you.Validation,代码行数:13,代码来源:Throw_Should.cs
示例19: AddDoubleNotInfinityValidationPredicate
public void AddDoubleNotInfinityValidationPredicate()
{
// Arrange.
ValidatableArgument<double> argument =
new ValidatableArgument<double>("argument", 5);
// Act.
argument.IsNotInfinity();
// Assert.
Assert.AreEqual(1, argument.ValidationPredicates.Count());
Assert.IsInstanceOfType(argument.ValidationPredicates.First(), typeof(DoubleNotInfinityValidationPredicate));
}
开发者ID:veskokolev,项目名称:Bytes2you.Validation,代码行数:13,代码来源:IsNotInfinity_Should.cs
示例20: AddEnumerableNullOrEmptyValidationPredicate
public void AddEnumerableNullOrEmptyValidationPredicate()
{
// Arrange.
ValidatableArgument<int[]> argument =
new ValidatableArgument<int[]>("argument", new int[] { 1, 2, 3 });
// Act.
argument.IsNullOrEmpty();
// Assert.
Assert.AreEqual(1, argument.ValidationPredicates.Count());
Assert.IsInstanceOfType(argument.ValidationPredicates.First(), typeof(EnumerableNullOrEmptyValidationPredicate<int[]>));
}
开发者ID:veskokolev,项目名称:Bytes2you.Validation,代码行数:13,代码来源:IsNullOrEmpty_Should.cs
注:本文中的ValidatableArgument类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论