Skip to content

Conversation

@AtolagbeMuiz
Copy link
Contributor

@AtolagbeMuiz AtolagbeMuiz commented Oct 10, 2025

This Pull request fixes #6360

This implementation involves changes to the Analyzer to suggest a much cleaner approach to write Assertions that involves the use of Predicate functions. for example

Assert.IsTrue(_enumerable.Where(x => x == 1).Any());
Assert.IsTrue(_enumerable.Any(x => x == 1));
Assert.IsTrue(_enumerable.Count(x => x == 1) > 0);

Analyzer will suggest (Expected Behaviour)
Assert.Contains(x => x == 1, _enumerable);

Example 2:

Assert.IsFalse(_enumerable.Where(x => x == 1).Any());
Assert.IsFalse(_enumerable.Any(x => x == 1));
Assert.IsFalse(_enumerable.Count(x => x == 1) > 0);

Analyzer will suggest (Expected Behaviour)
Assert.DoesNotContain(x => x == 1, _enumerable);

…Null and Asset.IsNotNull using Single, SingleOrDefaut, WhereSingle and WhereSingleOrDefualt
@AtolagbeMuiz
Copy link
Contributor Author

@Youssef1313 @Evangelink Pls I need this pull request to be reviewed.. I don't really know how to request a review directly to a maintainer If they are not already part of the pull request reviewers

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.

MSTEST0037 analyzer should suggest Contains/DoesNotContain/ContainsSingle for overloads taking a predicate

3 participants