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 MustContain 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.
- 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.
- The assertion should verify that the
ImmutableArray<T> contains the specified item.
- If you have any questions or suggestions, please ask me about them.
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 theMustContainassertion forImmutableArray<T>.Tasks for this issue
Check.MustContain.csin the root folder of the project.MustContainforImmutableArray<T>. They should be placed in the existing classCheckwhich is marked aspartial.parameterNameandmessagearguments and throws the default exception (in this case the existingMissingItemException). The actual exception is thrown in theThrowclass, you need to call the existing method for it in this class.Throw.CustomExceptionmethod and pass the delegate, the erroneousImmutableArray<T>instance and the missing 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.CollectionAssertions,StringAssertions,DateTimeAssertionsand so on. Please take a look at them to follow a similar structure and code style.ImmutableArray<T>contains the specified item.