MustNotContain for ImmutableArray
Context
The .NET library Light.GuardClauses already has several assertions for collections. They often rely on IEnumerable<T> or IEnumerable. However, these assertions would result in ImmutableArray<T> being boxed - we want to avoid that by providing dedicated assertions for this type which avoids boxing. For this issue, we implement the MustNotContain assertion for ImmutableArray<T>.
Tasks for this issue
Notes
- There are already plenty of other assertions and tests in this library. All overloads are placed in the same file in the production code project. The test projects has top-level folders for different groups of assertions, like
CollectionAssertions, StringAssertions, DateTimeAssertions and so on. Please take a look at them to follow a similar structure and code style.
- This assertion specifically targets
ImmutableArray<T> to avoid boxing that would occur with generic IEnumerable<T> extensions.
- The assertion should verify that the
ImmutableArray<T> does not contain the specified item.
- If you have any questions or suggestions, please ask me about them.
MustNotContain for ImmutableArray
Context
The .NET library Light.GuardClauses already has several assertions for collections. They often rely on
IEnumerable<T>orIEnumerable. However, these assertions would result inImmutableArray<T>being boxed - we want to avoid that by providing dedicated assertions for this type which avoids boxing. For this issue, we implement theMustNotContainassertion forImmutableArray<T>.Tasks for this issue
Check.MustNotContain.csalready exists in the root folder of the project - extend this existing file.MustNotContainforImmutableArray<T>. It should be placed in the classCheckwhich is marked aspartial.parameterNameandmessagearguments and throw the default exception. The actual exception is thrown in theThrowclass - use the existingThrow.ExistingItemmethod which is located inExceptionFactory/Throw.ExistingItem.cs.Throw.CustomExceptionmethod and pass the delegate, the erroneousImmutableArray<T>instance and the unwanted item.Should()for assertions).Notes
CollectionAssertions,StringAssertions,DateTimeAssertionsand so on. Please take a look at them to follow a similar structure and code style.ImmutableArray<T>to avoid boxing that would occur with genericIEnumerable<T>extensions.ImmutableArray<T>does not contain the specified item.