fix: ComplyWith with negated expectations#635
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes the negated expectation logic in the ComplyWith constraint by refining the error message and ensuring the negation is applied only once during evaluation.
- Update the failure message in tests to reflect the correct negation behavior.
- Introduce and utilize a new state flag (_isOnceNegated) to prevent multiple negations in the constraint evaluation.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| Tests/aweXpect.Tests/Collections/ThatEnumerable.All.ComplyWith.ImmutableTests.cs | Updated the error message in the negated expectation test scenario to accurately report failures. |
| Source/aweXpect/That/ThatGeneric.CompliesWith.cs | Added a new state flag (_isOnceNegated) and refactored the negation method to ensure a single negation is performed. |
Comments suppressed due to low confidence (2)
Tests/aweXpect.Tests/Collections/ThatEnumerable.All.ComplyWith.ImmutableTests.cs:69
- Please confirm that the updated error message 'but none of 7 were' clearly communicates the negated expectation failure, ensuring consistency with the intended behavior.
but none of 7 were
Source/aweXpect/That/ThatGeneric.CompliesWith.cs:105
- Verify that the introduction of '_isOnceNegated' and its handling in 'NegateOnceIfNegated' works correctly in all use cases. Consider whether the state should be reset between validations if the same instance is reused.
if (_isNegated && !_isOnceNegated)
|
Test Results 14 files - 24 14 suites - 24 2m 34s ⏱️ -2s Results for commit d203cf3. ± Comparison against base commit 589bbf9. This pull request removes 1377 and adds 1349 tests. Note that renamed tests count towards both. |
🚀 Benchmark ResultsDetails
|
👽 Mutation ResultsaweXpectDetails
The final mutation score is 80.00%Coverage Thresholds: high:80 low:60 break:0aweXpect.CoreDetails
The final mutation score is NaN%Coverage Thresholds: high:80 low:60 break:0 |
…ions (#635) by Valentin Breuß
…ions (#635) by Valentin Breuß
|
This is addressed in release v2.16.0. |



Fixes the negated expectation logic in the
ComplyWithconstraint by ensuring that the negation is applied only once during evaluation.Fixes #632