For the complete documentation index, see llms.txt. This page is also available as Markdown.

OneOf

ShouldNotBeOneOf is the inverse of ShouldBeOneOf.

The candidates are passed as a single collection, not as individual arguments:

status.ShouldBeOneOf([Status.Active, Status.Pending]);

This was a params array in v4 — see the 4 to 5 upgrade guide.

ShouldBeOneOf

var apu = new Person { Name = "Apu" };
var homer = new Person { Name = "Homer" };
var skinner = new Person { Name = "Skinner" };
var barney = new Person { Name = "Barney" };
var theBeSharps = new List<Person> { homer, skinner, barney };
apu.ShouldBeOneOf(theBeSharps.ToArray());

snippet source | anchor

Exception

apu
    should be one of
[Homer, Skinner, Barney]
    but was
Apu

ShouldNotBeOneOf

snippet source | anchor

Exception

Last updated