Skip to content

Conversation

AtolagbeMuiz
Copy link
Contributor

This Pull Request fixes Assert.ContainsSingle should accept non-generic collections #6732

This Implementation involves an overload being added to the Assert.ContainsSingle which allows non-generic collections like ArrayList.

Current Behaviour

Assert.ContainsSingle throws compile time error because it only accepts generic collections.
Screenshot 2025-10-12 230729

Expected Behaviour

With this Implementation, Assert.ContainsSingle will allow non-generic collection as seen below;

image image

@AtolagbeMuiz
Copy link
Contributor Author

@Youssef1313 do we need to hndle AssertSingleInterpolatedStringHandler for non-generic collection as well

public static object ContainsSingle(IEnumerable collection, [InterpolatedStringHandlerArgument(nameof(collection))] ref AssertSingleInterpolatedStringHandler message, [CallerArgumentExpression(nameof(collection))] string collectionExpression = "") => message.ComputeAssertion(collectionExpression);

…rpolationStringHandler based off Assert.HasCount
@AtolagbeMuiz
Copy link
Contributor Author

removed the AssertSingleInterpolatedStringHandler for non-generic implemnation based because we didnt implement if for Assert.Count as well....

@Youssef1313

@Youssef1313 Youssef1313 self-assigned this Oct 17, 2025
@Youssef1313 Youssef1313 self-requested a review October 17, 2025 23:36
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.

Assert.ContainsSingle should accept non-generic collections

2 participants