-
Notifications
You must be signed in to change notification settings - Fork 158
CollectionContainsConstraint
Charlie Poole edited this page Jan 31, 2016
·
6 revisions
CollectionContainsConstraint tests that an IEnumerable
contains an object. If the actual value passed does not implement IEnumerable
, an exception is thrown.
CollectionContainsConstraint( object )
Has.Member( object )
Contains.Item( object )
Does.Contain( object )
...Using(IComparer comparer)
...Using<t>(IComparer<T> comparer)
...Using<t>(Comparison<T> comparer)
int[] iarray = new int[] { 1, 2, 3 };
string[] sarray = new string[] { "a", "b", "c" };
Assert.That( iarray, Has.Member(3) );
Assert.That( sarray, Has.Member("b") );
Assert.That( sarray, Contains.Item("c") );
Assert.That( sarray, Has.No.Member("x") );
Assert.That( iarray, Does.Contain(3) );
- For references, Has.Member uses object equality to find a member in a collection. To check for an object equal to an item the collection, use Has.Some.EqualTo(...).
Copyright (c) 2018 The NUnit Project - Licensed under CC BY-NC-SA 4.0
-
NUnit
-
Release Notes
-
License
- Getting Started
- Writing Tests
- Running Tests
- Extending NUnit
- Technical Notes
-
Release Notes
- NUnit Xamarin Runners
- VS Test Adapter
- VS Test Generator
- NUnit Analyzers