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

Analyzer to convert Assert.Collection to Assert.Single #2123

Closed
bradwilson opened this issue Jul 25, 2020 · 11 comments · Fixed by xunit/xunit.analyzers#168
Closed

Analyzer to convert Assert.Collection to Assert.Single #2123

bradwilson opened this issue Jul 25, 2020 · 11 comments · Fixed by xunit/xunit.analyzers#168

Comments

@bradwilson
Copy link
Member

While updating the xUnit.net source, I noticed that I did this a lot:

Assert.Collection(
    collection,
    item => // assertion(s) for the single item
);

This could/should be converted to this:

var item = Assert.Single(collection);
// assertion(s) for the single item
@netchkin
Copy link

Can you please include an example for // assertion(s) for the single item in Assert.Collection example?

@adison88
Copy link
Contributor

adison88 commented Jan 9, 2021

@bradwilson I see most of these usages in unit tests in xUnit.net source. I can pick this one up to update the source. Please let me know if there're any other places which needs an update.

@adison88
Copy link
Contributor

Hello @bradwilson , created #2230 for review.

@vb2ae
Copy link

vb2ae commented Oct 8, 2023

@bradwilson did pr #2230 fix the issue? Wondering if this ticket should be closed

@bradwilson
Copy link
Member Author

It did. Thanks for pointing it out.

@bradwilson
Copy link
Member Author

Oops, I jumped the gun. That PR fixed the usage in xUnit.net, but did not create the analyzer.

@bradwilson bradwilson reopened this Oct 8, 2023
@adison88
Copy link
Contributor

@bradwilson what other changes are needed to close this ticket?

@bradwilson
Copy link
Member Author

@bradwilson what other changes are needed to close this ticket?

This issue is to create a new analyzer and fixer.

@etherfield
Copy link

@adison88, do you still want to do this? I can help with the analyzer and fixer if you don't mind.

@adison88
Copy link
Contributor

@etherfield go ahead.

@bradwilson
Copy link
Member Author

Available in 1.6.0-pre.8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants