IEnumerable<T> Assertions

			IEnumerable<int> actual;

			actual.Should().Contain(expected);

			actual.Should().Have.SameValuesAs(new[] {3, 2, 1});
			actual.Should().Have.SameValuesAs(3, 2, 1);

			actual.Should().Have.UniqueValues();

			actual.Should().Have.SameSequenceAs(new[] {1, 2, 3});
			actual.Should().Have.SameSequenceAs(1, 2, 3);

			actual.Should().Have.Count.EqualTo(3)

			actual.Should().Be.Null();
			actual.Should().Be.Empty();
			actual.Should().Be.SameInstanceAs(expected);

			actual.Should().Be.SubsetOf(new[] {1, 2, 3, 4});
			actual.Should().Be.SubsetOf(1, 2, 3, 4);

			actual.Should().Be.Ordered();
			actual.Should().Be.OrderedAscending();
			actual.Should().Be.OrderedDescending();
			addresses.Should().Be.OrderedBy(a => a.Number);

Example with negation and chain

			var ints = new[] {1, 2, 3};

			ints.Should()
				.Not.Be.Null()
				.And.Not.Be.Empty()
				.And.Not.Have.SameSequenceAs(new[] {3, 2, 1})
				.And.Have.UniqueValues();

			ints.Should().Contain(2).And.Not.Contain(4);

			ints.Should().Contain(3).And.Not.Have.Count.LessThan(2);

Last edited Dec 21, 2009 at 7:43 PM by fabiomaulo, version 3

Comments

MatFiz Jun 18, 2011 at 5:59 PM 
Is there any way to do the following:

ints.Should().Not.Contain(i => i % 2 == 0)

?