Skip to content

fix: Correctly handle Throws<T>().Which.Satisfies#714

Merged
vbreuss merged 1 commit intomainfrom
topic/fix-throws-which
Aug 11, 2025
Merged

fix: Correctly handle Throws<T>().Which.Satisfies#714
vbreuss merged 1 commit intomainfrom
topic/fix-throws-which

Conversation

@vbreuss
Copy link
Copy Markdown
Member

@vbreuss vbreuss commented Aug 11, 2025

This PR fixes the handling of Throws<T>().Which.Satisfies assertions by correctly implementing the constraint chain for typed exception throwing expectations. The fix ensures that when an exception of the expected type is thrown, the .Which continuation properly provides access to the exception for further assertions.


@vbreuss vbreuss self-assigned this Aug 11, 2025
Copilot AI review requested due to automatic review settings August 11, 2025 21:58
@vbreuss vbreuss added the bug Something isn't working label Aug 11, 2025
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes the handling of Throws<T>().Which.Satisfies assertions by correctly implementing the constraint chain for typed exception throwing expectations. The fix ensures that when an exception of the expected type is thrown, the .Which continuation properly provides access to the exception for further assertions.

Key Changes

  • Replaced generic DelegateIsNotNullWithinTimeoutConstraint with specialized DelegateThrowsWithinTimeoutConstraint<TException> for typed exception handling
  • Added proper processing strategy handling in WhichNode to respect constraint chain decisions
  • Enabled previously skipped test to validate the fix

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
Source/aweXpect.Core/Delegates/ThatDelegate.Throws.cs Implemented DelegateThrowsWithinTimeoutConstraint<TException> and DoNothingConstraint<T> to properly handle typed exception throwing with constraint chaining
Source/aweXpect.Core/Core/Nodes/WhichNode.cs Added check for FurtherProcessingStrategy.IgnoreCompletely to respect parent constraint decisions
Tests/aweXpect.Tests/Delegates/ThatDelegate.Throws.WhichTests.cs Re-enabled test by removing skip attribute to validate the fix

Comment thread Source/aweXpect.Core/Delegates/ThatDelegate.Throws.cs
@vbreuss vbreuss force-pushed the topic/fix-throws-which branch from f7a90e7 to 7b7407a Compare August 11, 2025 21:59
@vbreuss vbreuss enabled auto-merge (squash) August 11, 2025 22:00
@github-actions
Copy link
Copy Markdown
Contributor

Test Results

    14 files  +     7      14 suites  +7   2m 48s ⏱️ + 1m 48s
14 353 tests + 1 094  14 345 ✅ + 1 094   8 💤 ± 0  0 ❌ ±0 
39 756 runs  +26 497  39 736 ✅ +26 485  20 💤 +12  0 ❌ ±0 

Results for commit 7b7407a. ± Comparison against base commit c5477b0.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Aug 11, 2025

🚀 Benchmark Results

Details

BenchmarkDotNet v0.14.0, Ubuntu 24.04.2 LTS (Noble Numbat)
AMD EPYC 7763, 1 CPU, 4 logical and 2 physical cores
.NET SDK 8.0.413
[Host] : .NET 8.0.19 (8.0.1925.36514), X64 RyuJIT AVX2

Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15
LaunchCount=1 WarmupCount=10

Method Mean Error StdDev Gen0 Gen1 Allocated
Bool_aweXpect 191.3 ns 3.15 ns 2.94 ns 0.0281 - 472 B
Bool_FluentAssertions 274.6 ns 11.85 ns 11.09 ns 0.0567 - 952 B
Bool_TUnit 917.0 ns 8.56 ns 7.58 ns 0.1431 - 2408 B
Equivalency_aweXpect 293,812.2 ns 3,653.35 ns 3,417.34 ns 16.6016 0.4883 284940 B
Equivalency_FluentAssertions 2,305,844.5 ns 22,173.20 ns 20,740.83 ns 273.4375 46.8750 4584416 B
Equivalency_TUnit 674,363.4 ns 5,063.57 ns 4,736.46 ns 51.7578 2.9297 880545 B
Int_GreaterThan_aweXpect 219.9 ns 2.78 ns 2.46 ns 0.0467 - 784 B
Int_GreaterThan_FluentAssertions 263.9 ns 4.74 ns 4.20 ns 0.0730 - 1224 B
Int_GreaterThan_TUnit 1,213.8 ns 19.94 ns 18.65 ns 0.1774 - 2984 B
ItemsCount_AtLeast_aweXpect 504.2 ns 14.98 ns 14.01 ns 0.0854 - 1432 B
ItemsCount_AtLeast_FluentAssertions 515.9 ns 5.54 ns 5.18 ns 0.1192 - 2008 B
ItemsCount_AtLeast_TUnit 17,725.5 ns 158.31 ns 148.09 ns 1.6174 - 27480 B
String_aweXpect 363.7 ns 3.11 ns 2.91 ns 0.0672 - 1128 B
String_FluentAssertions 554.8 ns 22.99 ns 21.50 ns 0.1287 - 2168 B
String_TUnit 1,251.8 ns 13.50 ns 11.97 ns 0.1831 - 3072 B
StringArray_aweXpect 1,434.6 ns 27.20 ns 25.44 ns 0.1640 - 2744 B
StringArray_FluentAssertions 1,395.6 ns 34.44 ns 32.22 ns 0.2480 - 4152 B
StringArray_TUnit 3,305.4 ns 70.17 ns 65.64 ns 0.3128 - 5296 B
StringArrayInAnyOrder_aweXpect 1,578.4 ns 17.25 ns 16.13 ns 0.1736 - 2920 B
StringArrayInAnyOrder_FluentAssertions 146,386.0 ns 505.60 ns 448.20 ns 3.4180 - 63787 B
StringArrayInAnyOrder_TUnit 4,014.5 ns 115.85 ns 108.36 ns 0.3815 - 6488 B

@vbreuss vbreuss merged commit c5f6791 into main Aug 11, 2025
9 of 11 checks passed
@vbreuss vbreuss deleted the topic/fix-throws-which branch August 11, 2025 22:09
github-actions Bot added a commit that referenced this pull request Aug 11, 2025
github-actions Bot added a commit that referenced this pull request Aug 11, 2025
@github-actions
Copy link
Copy Markdown
Contributor

This is addressed in release v2.21.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working state: released The issue is released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

InvalidOperationException when verifying that an exception is thrown which satisfies a condition

2 participants