feat: support negated expectation on sort order#625
Conversation
## Sort order You can now also verify whether the collection is not sorted in ascending or descending order: ```csharp await Expect.That([1, 3, 2]).IsNotInAscendingOrder(); await Expect.That(["c", "a", "b"]).IsNotInDescendingOrder(); ```
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for negated expectations on collection sort order by introducing new APIs and corresponding tests for both synchronous and asynchronous collections. Key changes include:
- New methods: IsNotInAscendingOrder and IsNotInDescendingOrder with optional member accessor overloads.
- Comprehensive test coverage for various collection types and scenarios.
- Documentation updates to include examples of negated sort order expectations.
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| Tests/aweXpect.Tests/Collections/ThatEnumerable.IsNotInDescendingOrder.Tests.cs | Added tests for negated descending order expectation. |
| Tests/aweXpect.Tests/Collections/ThatEnumerable.IsNotInAscendingOrder.Tests.cs | Added tests for negated ascending order expectation. |
| Tests/aweXpect.Tests/Collections/ThatAsyncEnumerable.*.Tests.cs | Added similar tests for asynchronous collections. |
| Tests/aweXpect.Api.Tests/Expected/aweXpect_netstandard2.0.txt Tests/aweXpect.Api.Tests/Expected/aweXpect_net8.0.txt |
Updated API definitions to include negated order methods. |
| Source/aweXpect/That/Collections/ThatEnumerable.IsInDescendingOrder.cs ThatEnumerable.IsInAscendingOrder.cs ThatAsyncEnumerable.IsInDescendingOrder.cs ThatAsyncEnumerable.IsInAscendingOrder.cs |
Implemented new negated order methods using the inversion of existing constraints. |
| Docs/pages/docs/expectations/07-collections.md | Revised documentation to include examples for negated order expectations. |
Comments suppressed due to low confidence (2)
Source/aweXpect/That/Collections/ThatEnumerable.IsInDescendingOrder.cs:58
- [nitpick] Enhance the XML documentation to mention that this method works by inverting the standard descending order check, which can help users understand its behavior better.
/// Verifies that the collection is not in descending order.
Source/aweXpect/That/Collections/ThatEnumerable.IsInAscendingOrder.cs:58
- [nitpick] Consider expanding the XML comment to clarify that this method inverts the ascending order check, providing users with additional context on the implementation.
/// Verifies that the collection is not in ascending order.
Test Results 14 files - 24 14 suites - 24 2m 14s ⏱️ -1s Results for commit b650ebf. ± Comparison against base commit c665913. This pull request removes 1368 and adds 1420 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
🚀 Benchmark ResultsDetails
|
👽 Mutation ResultsaweXpectDetails
The final mutation score is 100.00%Coverage Thresholds: high:80 low:60 break:0aweXpect.CoreDetails
The final mutation score is NaN%Coverage Thresholds: high:80 low:60 break:0 |
|
…rt order (#625) by Valentin Breuß
…rt order (#625) by Valentin Breuß
|
This is addressed in release v2.14.0. |



This PR adds support for negated expectations on collection sort order by introducing new APIs and corresponding tests for both synchronous and asynchronous collections. Key changes include:
Sort order
You can now also verify whether the collection is not sorted in ascending or descending order: