Class DictionaryContainsKeyConstraint
DictionaryContainsKeyConstraint is used to test whether a dictionary
contains an expected object as a key.
Inheritance
DictionaryContainsKeyConstraint
Assembly: nunit.framework.dll
Syntax
public class DictionaryContainsKeyConstraint : CollectionItemsEqualConstraint, IConstraint, IResolveConstraint
Constructors
View Source
DictionaryContainsKeyConstraint(object)
Construct a DictionaryContainsKeyConstraint
Declaration
public DictionaryContainsKeyConstraint(object expected)
Parameters
Type |
Name |
Description |
object |
expected |
|
Properties
View Source
Description
The Description of what this constraint tests, for
use in messages and in the ConstraintResult.
Declaration
public override string Description { get; }
Property Value
Overrides
View Source
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.
Declaration
public override string DisplayName { get; }
Property Value
Overrides
View Source
Expected
Declaration
protected object Expected { get; }
Property Value
Methods
View Source
ApplyTo<TActual>(TActual)
Test whether the constraint is satisfied by a given value
Declaration
public override ConstraintResult ApplyTo<TActual>(TActual actual)
Parameters
Type |
Name |
Description |
TActual |
actual |
The value to be tested
|
Returns
Type Parameters
Overrides
View Source
Matches(IEnumerable)
Test whether the expected key is contained in the dictionary
Declaration
protected override bool Matches(IEnumerable collection)
Parameters
Returns
Overrides
View Source
WithValue(object?)
Returns a new DictionaryContainsKeyValuePairConstraint checking for the
presence of a particular key-value-pair in the dictionary.
Declaration
public DictionaryContainsKeyValuePairConstraint WithValue(object? expectedValue)
Parameters
Type |
Name |
Description |
object |
expectedValue |
|
Returns
Implements