DictionaryContainsValue Constraint
DictionaryContainsValueConstraint
is used to test whether a dictionary
contains an expected object as a value.
Constructor
DictionaryContainsValueConstraint(object)
Syntax
Contains.Value(object)
Does.ContainValue(object)
Does.Not.ContainValue(object)
Modifiers
...Using(IComparer comparer)
...Using(IEqualityComparer comparer)
...Using<T>(IComparer<T> comparer)
...Using<T>(Comparison<T> comparer)
...Using<T>(Func<T, T, bool> comparer)
...Using<T>(IEqualityComparer<T> comparer)
...Using<TActualValueElement, TExpected>(Func<TActualValueElement, TExpected, bool> comparison)
...UsingPropertiesComparer() // From version 4.1
Examples of Use
IDictionary<int, int> idict = new IDictionary<int, int> { { 1, 4 }, { 2, 5 } };
Assert.That(idict, Contains.Value(4));
Assert.That(idict, Does.ContainValue(5));
Assert.That(idict, Does.Not.ContainValue(3));
Assert.That(mydict, Contains.Value(myOwnObject).Using(myComparer));