Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xunit/xunit#2123: Analyzer to convert Assert.Collection to Assert.Single #168

Merged

Conversation

etherfield
Copy link
Contributor

Resolves #2123

@etherfield
Copy link
Contributor Author

I've added support for expression lambdas, statement lambdas, and parameter-methods as these cases are the most commonly used.

Assert.Collection(collection, item => Assert.NotNull(item));
==>
var item = Assert.Single(collection);
Assert.NotNull(item);
Assert.Collection(collection, item => { Assert.NotNull(item); });
==>
var item = Assert.Single(collection);
Assert.NotNull(item);
private void ElementInspector(object obj)
{ }

Assert.Collection(collection, ElementInspector);
==>
var item = Assert.Single(collection);
ElementInspector(item);

@etherfield etherfield marked this pull request as ready for review November 14, 2023 19:19
@bradwilson bradwilson changed the title #2123 Analyzer to convert Assert.Collection to Assert.Single xunit/xunit#2123: Analyzer to convert Assert.Collection to Assert.Single Nov 18, 2023
@bradwilson bradwilson merged commit 0a86d7e into xunit:main Nov 18, 2023
5 checks passed
@bradwilson
Copy link
Member

Thanks!

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.

Analyzer to convert Assert.Collection to Assert.Single
2 participants