MustHaveLength for immutable array #123
Merged
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.
Closes #117
This pull request introduces a new
MustHaveLengthassertion forImmutableArray<T>to the Light.GuardClauses library. The changes include the implementation of the assertion, the corresponding exception handling, and unit tests to validate the functionality. Additionally, documentation has been added to describe the context and tasks associated with this enhancement.New Assertion for
ImmutableArray<T>:Implementation of
MustHaveLengthmethods: Added two extension methods to theCheckclass inCheck.MustHaveLength.csto validate the length ofImmutableArray<T>. One method throws the defaultInvalidCollectionCountException, while the other allows custom exceptions via a delegate.Exception handling: Introduced
InvalidImmutableArrayLengthinThrow.ImmutableArray.csto handle invalid lengths forImmutableArray<T>. This method ensures descriptive error messages and integrates seamlessly with the new assertion.Unit Tests:
MustHaveLengthTests.csto verify the behavior of theMustHaveLengthassertion under various scenarios, including valid lengths, invalid lengths, custom exceptions, and default arrays.Documentation:
issue-117-must-have-length-for-immutable-array.mdto document the context, tasks, and implementation details for the newMustHaveLengthassertion. This file provides a clear guide for understanding the purpose and design of the feature.