> For the complete documentation index, see [llms.txt](https://docs.shouldly.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.shouldly.org/documentation/equality/oneof.md).

# OneOf

`ShouldNotBeOneOf` is the inverse of `ShouldBeOneOf`.

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

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

This was a `params` array in v4 — see the [4 to 5 upgrade guide](/documentation/4to5.md).

## ShouldBeOneOf

```cs
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());
```

[<sup>snippet source</sup>](https://github.com/shouldly/shouldly/tree/master/src/DocumentationExamples/CodeExamples/ShouldBeOneOfExamples.ShouldBeOneOf.codeSample.approved.cs#L1-L6) <sup>|</sup> [<sup>anchor</sup>](#snippet-ShouldBeOneOfExamples.ShouldBeOneOf.codeSample.approved.cs)

**Exception**

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

## ShouldNotBeOneOf

```cs
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 wiggum = new Person { Name = "Wiggum" };
var theBeSharps = new List<Person> { apu, homer, skinner, barney, wiggum };
wiggum.ShouldNotBeOneOf(theBeSharps.ToArray());
```

[<sup>snippet source</sup>](https://github.com/shouldly/shouldly/tree/master/src/DocumentationExamples/CodeExamples/ShouldBeOneOfExamples.ShouldNotBeOneOf.codeSample.approved.cs#L1-L7) <sup>|</sup> [<sup>anchor</sup>](#snippet-ShouldBeOneOfExamples.ShouldNotBeOneOf.codeSample.approved.cs)

**Exception**

```
wiggum
    should not be one of
[Apu, Homer, Skinner, Barney, Wiggum]
    but was
Wiggum
```
