本文整理汇总了C#中NUnit.Framework.Constraints.Constraint类的典型用法代码示例。如果您正苦于以下问题:C# Constraint类的具体用法?C# Constraint怎么用?C# Constraint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Constraint类属于NUnit.Framework.Constraints命名空间,在下文中一共展示了Constraint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Matches
/// <summary>
/// Test whether the constraint is satisfied by a given value
/// </summary>
/// <param name="actual">The value to be tested</param>
/// <returns>True for if the base constraint fails, false if it succeeds</returns>
public override bool Matches(object actual)
{
this.actual = actual;
if ( this.caseInsensitive )
baseConstraint = baseConstraint.IgnoreCase;
return !baseConstraint.Matches(actual);
}
示例2: AttributeConstraint
/// <summary>
/// Constructs an AttributeConstraint for a specified attriute
/// Type and base constraint.
/// </summary>
/// <param name="type"></param>
/// <param name="baseConstraint"></param>
public AttributeConstraint(Type type, Constraint baseConstraint)
: base( baseConstraint )
{
this.expectedType = type;
if (!typeof(Attribute).IsAssignableFrom(expectedType))
throw new ArgumentException(string.Format(
"Type {0} is not an attribute", expectedType), "type");
}
示例3: PassModifiersToBase
/// <summary>
/// Set all modifiers applied to the prefix into
/// the base constraint before matching
/// </summary>
protected void PassModifiersToBase()
{
if ( this.caseInsensitive )
baseConstraint = baseConstraint.IgnoreCase;
if ( this.tolerance != null )
baseConstraint = baseConstraint.Within( tolerance );
if ( this.compareAsCollection )
baseConstraint = baseConstraint.AsCollection;
if ( this.compareWith != null )
baseConstraint = baseConstraint.Comparer( compareWith );
}
示例4: Matches
/// <summary>
/// Apply the item constraint to each item in the collection,
/// failing if any item fails.
/// </summary>
/// <param name="actual"></param>
/// <returns></returns>
public override bool Matches(object actual)
{
this.actual = actual;
if ( actual == null || !(actual is ICollection) )
return false;
if ( this.caseInsensitive )
itemConstraint = itemConstraint.IgnoreCase;
foreach(object item in (ICollection)actual)
if (!itemConstraint.Matches(item))
return false;
return true;
}
示例5: SetConstraint
public virtual Constraint SetConstraint(Constraint constraint)
{
baseConstraint = constraint;
return this;
}
示例6: ApplyOperator
/// <summary>
/// Abstract method that produces a constraint by applying
/// the operator to its left and right constraint arguments.
/// </summary>
public abstract Constraint ApplyOperator(Constraint left, Constraint right);
示例7: NotConstraint
/// <summary>
/// Initializes a new instance of the <see cref="T:NotConstraint"/> class.
/// </summary>
/// <param name="baseConstraint">The base constraint to be negated.</param>
public NotConstraint(Constraint baseConstraint)
: base( baseConstraint ) { }
示例8: IsOrderedBy
public void IsOrderedBy(IEnumerable collection, Constraint constraint)
{
Assert.That(collection, constraint);
}
示例9: ThrowsConstraint
/// <summary>
/// Initializes a new instance of the <see cref="T:ThrowsConstraint"/> class,
/// using a constraint to be applied to the exception.
/// </summary>
/// <param name="baseConstraint">A constraint to apply to the caught exception.</param>
public ThrowsConstraint(Constraint baseConstraint)
: base(baseConstraint) { }
示例10: NoItemConstraint
/// <summary>
/// Construct a SomeItemsConstraint on top of an existing constraint
/// </summary>
/// <param name="itemConstraint"></param>
public NoItemConstraint(Constraint itemConstraint)
: base( itemConstraint )
{
this.DisplayName = "none";
}
示例11: NoItemConstraint
/// <summary>
/// Construct a SomeItemsConstraint on top of an existing constraint
/// </summary>
/// <param name="itemConstraint"></param>
public NoItemConstraint(Constraint itemConstraint)
: base( itemConstraint ) { }
示例12: PrefixConstraint
/// <summary>
/// Construct given a base constraint
/// </summary>
/// <param name="baseConstraint"></param>
protected PrefixConstraint( Constraint baseConstraint )
{
this.baseConstraint = baseConstraint;
}
示例13: AllItemsConstraint
/// <summary>
/// Construct an AllItemsConstraint on top of an existing constraint
/// </summary>
/// <param name="itemConstraint"></param>
public AllItemsConstraint(Constraint itemConstraint)
: base( itemConstraint ) { }
示例14: SomeItemsConstraint
/// <summary>
/// Construct a SomeItemsConstraint on top of an existing constraint
/// </summary>
/// <param name="itemConstraint"></param>
public SomeItemsConstraint(Constraint itemConstraint)
: base( itemConstraint ) { }
示例15: ApplyPrefix
/// <summary>
/// Returns a constraint that will apply the argument
/// to the members of a collection, succeeding if
/// none of them succeed.
/// </summary>
public override Constraint ApplyPrefix(Constraint constraint)
{
return new ExactCountConstraint(expectedCount, constraint);
}