Table of Contents

Class Has

Namespace
NUnit.Framework
Assembly
nunit.framework.dll

Helper class with properties and methods that supply a number of constraints used in Asserts.

public abstract class Has
Inheritance
Has
Inherited Members

Constructors

Has()

protected Has()

Properties

All

Returns a ConstraintExpression, which will apply the following constraint to all members of a collection, succeeding if all of them succeed.

public static ConstraintExpression All { get; }

Property Value

ConstraintExpression

Count

Returns a new ConstraintExpression, which will apply the following constraint to the Count property of the object being tested.

public static ResolvableConstraintExpression Count { get; }

Property Value

ResolvableConstraintExpression

InnerException

Returns a new ConstraintExpression, which will apply the following constraint to the InnerException property of the object being tested.

public static ResolvableConstraintExpression InnerException { get; }

Property Value

ResolvableConstraintExpression

Length

Returns a new ConstraintExpression, which will apply the following constraint to the Length property of the object being tested.

public static ResolvableConstraintExpression Length { get; }

Property Value

ResolvableConstraintExpression

Message

Returns a new ConstraintExpression, which will apply the following constraint to the Message property of the object being tested.

public static ResolvableConstraintExpression Message { get; }

Property Value

ResolvableConstraintExpression

No

Returns a ConstraintExpression that negates any following constraint.

public static ConstraintExpression No { get; }

Property Value

ConstraintExpression

None

Returns a ConstraintExpression, which will apply the following constraint to all members of a collection, succeeding if all of them fail.

public static ConstraintExpression None { get; }

Property Value

ConstraintExpression

One

Returns a ItemsConstraintExpression which will apply the following constraint to only one member of the collection, and fail if none or more than one match occurs.

public static ItemsConstraintExpression One { get; }

Property Value

ItemsConstraintExpression

Some

Returns a ConstraintExpression, which will apply the following constraint to all members of a collection, succeeding if at least one of them succeeds.

public static ConstraintExpression Some { get; }

Property Value

ConstraintExpression

Methods

Attribute(Type)

Returns a new AttributeConstraint checking for the presence of a particular attribute on an object.

public static ResolvableConstraintExpression Attribute(Type expectedType)

Parameters

expectedType Type

Returns

ResolvableConstraintExpression

Attribute<T>()

Returns a new AttributeConstraint checking for the presence of a particular attribute on an object.

public static ResolvableConstraintExpression Attribute<T>()

Returns

ResolvableConstraintExpression

Type Parameters

T

Exactly(int)

Returns a ConstraintExpression, which will apply the following constraint to all members of a collection, succeeding only if a specified number of them succeed.

public static ItemsConstraintExpression Exactly(int expectedCount)

Parameters

expectedCount int

Returns

ItemsConstraintExpression

ItemAt(params object[])

Returns a new IndexerConstraintExpression, which will apply any following constraint to that indexer value.

public static ConstraintExpression ItemAt(params object[] indexArgs)

Parameters

indexArgs object[]

Index accessor values.

Returns

ConstraintExpression

Member(object?)

Returns a new SomeItemsConstraint checking for the presence of a particular object in the collection.

public static SomeItemsConstraint Member(object? expected)

Parameters

expected object

Returns

SomeItemsConstraint

Property(string)

Returns a new PropertyConstraintExpression, which will either test for the existence of the named property on the object being tested or apply any following constraint to that property.

public static ResolvableConstraintExpression Property(string name)

Parameters

name string

Returns

ResolvableConstraintExpression