Shouldly
Search…
OneOf
ShouldNotBeOneOf is the inverse of ShouldBeOneOf.

ShouldBeOneOf

1
var apu = new Person { Name = "Apu" };
2
var homer = new Person { Name = "Homer" };
3
var skinner = new Person { Name = "Skinner" };
4
var barney = new Person { Name = "Barney" };
5
var theBeSharps = new List<Person> { homer, skinner, barney };
6
apu.ShouldBeOneOf(theBeSharps.ToArray());
Copied!
Exception
1
apu
2
should be one of
3
[Homer, Skinner, Barney]
4
but was
5
Apu
Copied!

ShouldNotBeOneOf

1
var apu = new Person { Name = "Apu" };
2
var homer = new Person { Name = "Homer" };
3
var skinner = new Person { Name = "Skinner" };
4
var barney = new Person { Name = "Barney" };
5
var wiggum = new Person { Name = "Wiggum" };
6
var theBeSharps = new List<Person> { apu, homer, skinner, barney, wiggum };
7
wiggum.ShouldNotBeOneOf(theBeSharps.ToArray());
Copied!
Exception
1
wiggum
2
should not be one of
3
[Apu, Homer, Skinner, Barney, Wiggum]
4
but was
5
Wiggum
Copied!