Repository navigation
Generic overloads for CollectionAssert - #990
Closed
Daniel Lerch (daniel-lerch) wants to merge 1 commit into
Closed
Daniel Lerch (daniel-lerch) wants to merge 1 commit into
Daniel Lerch (daniel-lerch) wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request aimed to implement generic overloads for
CollectionAssertto fix #989.IEnumerable<T>vsIReadOnlyCollection<T>New assertions use
IEnumerable<T>instead ofICollection. This enables users to easily combine inline LINQ statements withCollectionAssert. Compared toIReadOnlyCollection<T>this is slightly slower to fail but I don't believe that failing unit tests are a major performance concern.Pattern of multiple overloads
Assertions with
IEnumerable<T>offer the same overloads as theirICollectionpredecessors. This pull request would give the opportunity to omit some overloads but as this pattern of arguments is consistent withinAssertandCollectionAssertI see no reason for changing it.Ambiguous calls
Adding overloads causes problems when users call assertions with parameters which implement both
ICollectionandIEnumerable<T>. Casting to one of these interfaces would lead to extremely ugly code and would be a breaking change.In order to resolve this conflict I would introduce another class
EnumerableAssert. Another option would be to use different names for the existing methods likeCollectionAssert.AreEqualGeneric.Medeni Baykal (@Haplois) So far I have only implemented overloads for
AreEqualandAreNotEqual. Please take a look on my design decisions and tell me whether I should continue like this.