Class DictionaryContainsKeyConstraint
- Namespace
- NUnit.Framework.Constraints
- Assembly
- nunit.framework.dll
DictionaryContainsKeyConstraint is used to test whether a dictionary contains an expected object as a key.
public class DictionaryContainsKeyConstraint : CollectionItemsEqualConstraint, IConstraint, IResolveConstraint
- Inheritance
-
DictionaryContainsKeyConstraint
- Implements
- Inherited Members
Constructors
DictionaryContainsKeyConstraint(object)
Construct a DictionaryContainsKeyConstraint
public DictionaryContainsKeyConstraint(object expected)
Parameters
expected
object
Properties
Description
The Description of what this constraint tests, for use in messages and in the ConstraintResult.
public override string Description { get; }
Property Value
DisplayName
The display name of this Constraint for use by ToString(). The default value is the name of the constraint with trailing "Constraint" removed. Derived classes may set this to another name in their constructors.
public override string DisplayName { get; }
Property Value
Expected
Gets the expected object
protected object Expected { get; }
Property Value
Methods
ApplyTo<TActual>(TActual)
Test whether the constraint is satisfied by a given value
public override ConstraintResult ApplyTo<TActual>(TActual actual)
Parameters
actual
TActualThe value to be tested
Returns
Type Parameters
TActual
Matches(IEnumerable)
Test whether the expected key is contained in the dictionary
protected override bool Matches(IEnumerable collection)
Parameters
collection
IEnumerable
Returns
WithValue(object)
Returns a new DictionaryContainsKeyValuePairConstraint checking for the presence of a particular key-value-pair in the dictionary.
public DictionaryContainsKeyValuePairConstraint WithValue(object expectedValue)
Parameters
expectedValue
object