Skip to content

Clarify CollectionAssert.Contains parameters and failure message - #1272

Open
SeanKilleen wants to merge 2 commits into
masterfrom
672_collectionassert-contains-parameters
Open

SeanKilleen wants to merge 2 commits into
masterfrom
672_collectionassert-contains-parameters

Conversation

@SeanKilleen

Copy link
Copy Markdown
Member

CollectionAssert.Contains and DoesNotContain were listed with (IEnumerable expected, object actual), but the real parameter names are (IEnumerable collection, object actual). Fixes the signatures and adds a short section explaining that the second argument is the item being looked for, why it appears on the Expected line of the failure message, that passing a collection as the second argument looks for it as a single element, and that the constraint-based Does.Contain/Has.Member read more naturally.

Fixes #672

🤖 Generated with Claude Code

`CollectionAssert.Contains` and `DoesNotContain` were listed with `(IEnumerable expected, object actual)`, but the real parameter names are `(IEnumerable collection, object actual)`. Fixes the signatures and adds a short section explaining that the second argument is the item being looked for, why it appears on the **Expected** line of the failure message, that passing a collection as the second argument looks for it as a single element, and that the constraint-based `Does.Contain`/`Has.Member` read more naturally.

Fixes #672

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

📖 Docs preview: https://pr-1272.nunit-docs.pages.dev

Built from 48422fd. This link always shows the latest build for this PR; the build for this exact commit is at https://11622bb3.nunit-docs.pages.dev.

Previews are hosted on Cloudflare Pages, are not indexed by search engines, and are removed when the PR is closed. They omit the archived NUnit 2.x documentation (the /2.x/ pages), which never changes; use the live site for those.

@SeanKilleen
SeanKilleen requested a review from stevenaw October 22, 2026 15:07
IComparer comparer, string message, params object[] args);
```

## Contains and DoesNotContain

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for putting a PR up for this one @SeanKilleen

I'll have to reacquaint myself with the issue before reviewing. Hopefully soon. I had thought we supported subset-style contains through this API too, but perhaps that's just at constraint level

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CollectionAssert.Contains has misleading parameters and/or output

2 participants