Skip to content

feat: add AndWhoseResult for delegates DoesNotThrow and DoesNotThrowExactly#660

Merged
vbreuss merged 2 commits intomainfrom
topic/add-andwhoseresult-for-delegate-doesnotthrow
Jun 26, 2025
Merged

feat: add AndWhoseResult for delegates DoesNotThrow and DoesNotThrowExactly#660
vbreuss merged 2 commits intomainfrom
topic/add-andwhoseresult-for-delegate-doesnotthrow

Conversation

@vbreuss
Copy link
Copy Markdown
Member

@vbreuss vbreuss commented Jun 26, 2025

Adds support for chaining a "does not throw" assertion with further checks on the delegate’s return value.

  • Introduces DelegateWithValueResult<T> with an AndWhoseResult property for inspecting the returned value.
  • Updates DoesNotThrow overloads to return the new result type.
  • Adds comprehensive tests covering exception and return-value scenarios.

Example:

Func<int> @delegate = () => 42;

await That(@delegate).DoesNotThrow().AndWhoseResult.IsGreaterThan(40);

Support chaining a delegate expectation that it `DoesNotThrow` with expectations on the result value, e.g.:

```csharp
Func<int> @DeleGate = () => 42;

await That(@DeleGate).DoesNotThrow().AndWhoseResult.IsGreaterThan(40);
```
@vbreuss vbreuss self-assigned this Jun 26, 2025
Copilot AI review requested due to automatic review settings June 26, 2025 18:43
@vbreuss vbreuss added the enhancement New feature or request label Jun 26, 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

Adds support for chaining a "does not throw" assertion with further checks on the delegate’s return value.

  • Introduces DelegateWithValueResult<T> with an AndWhoseResult property for inspecting returned values.
  • Updates DoesNotThrow overloads to return the new result type.
  • Adds comprehensive tests covering exception and return-value scenarios.

Reviewed Changes

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

Show a summary per file
File Description
Tests/aweXpect.Tests/Delegates/ThatDelegate…AndWhoseResult.Tests.cs New tests for combining DoesNotThrow with result assertions
Tests/aweXpect.Core.Api.Tests/Expected/aweXpect.Core_netstandard2.0.txt Updated API contract to use DelegateWithValueResult<T>
Tests/aweXpect.Core.Api.Tests/Expected/aweXpect.Core_net8.0.txt Updated API contract to use DelegateWithValueResult<T>
Source/aweXpect.Core/Results/DelegateWithValueResult.cs Implements new result type and AndWhoseResult logic
Source/aweXpect.Core/Delegates/ThatDelegate.WithValue.DoesNotThrow.cs Changes DoesNotThrow overloads to return new result type
Pipeline/Build.cs Adjusts build scope
Comments suppressed due to low confidence (1)

Source/aweXpect.Core/Results/DelegateWithValueResult.cs:21

  • Add an XML doc comment for AndWhoseResult to explain its purpose and usage, e.g.: /// <summary>Continues assertions on the value returned by the delegate.</summary>
	public IThat<T> AndWhoseResult

Comment thread Source/aweXpect.Core/Results/DelegateWithValueResult.cs
@vbreuss vbreuss changed the title feat: add AndWhoseResult for delegates DoesNotThrow feat: add AndWhoseResult for delegates DoesNotThrow and DoesNotThrowExactly Jun 26, 2025
@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown
Contributor

Test Results

    4 files   -     34      4 suites   - 34   22s ⏱️ - 2m 9s
  897 tests  - 12 763    896 ✅  - 12 762  1 💤  - 1  0 ❌ ±0 
2 577 runs   - 35 442  2 576 ✅  - 35 441  1 💤  - 1  0 ❌ ±0 

Results for commit 4375665. ± Comparison against base commit 6f36cdd.

This pull request removes 12817 and adds 54 tests. Note that renamed tests count towards both.
aweXpect.Analyzers.Tests.AwaitExpectationAnalyzerTests ‑ WhenAwaited_ShouldNotBeFlagged
aweXpect.Analyzers.Tests.AwaitExpectationAnalyzerTests ‑ WhenAwaited_WithoutReturnValue_ShouldNotBeFlagged
aweXpect.Analyzers.Tests.AwaitExpectationAnalyzerTests ‑ WhenNotAwaited_ShouldBeFlagged
aweXpect.Analyzers.Tests.AwaitExpectationAnalyzerTests ‑ WhenNotAwaited_WithoutReturnValue_ShouldBeFlagged
aweXpect.Analyzers.Tests.AwaitExpectationAnalyzerTests ‑ WhenNotAwaited_WithoutReturnValue_WithVerifyInMethod_ShouldStillBeFlagged
aweXpect.Analyzers.Tests.AwaitExpectationAnalyzerTests ‑ WhenVerifiedStatically_ShouldNotBeFlagged
aweXpect.Analyzers.Tests.AwaitExpectationAnalyzerTests ‑ WhenVerifiedStatically_WithoutReturnValue_ShouldNotBeFlagged
aweXpect.Analyzers.Tests.AwaitExpectationAnalyzerTests ‑ WhenVerifiedWithStaticUsing_ShouldNotBeFlagged
aweXpect.Analyzers.Tests.AwaitExpectationAnalyzerTests ‑ WhenVerifiedWithStaticUsing_WithoutReturnValue_ShouldNotBeFlagged
aweXpect.Analyzers.Tests.AwaitExpectationAnalyzerTests ‑ WhenVerified_ShouldNotBeFlagged
…
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "message351c114a-5477-4e75-8beb-46364e1b710f")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "message36ca2205-4235-4f0d-b387-b098f562a204")
aweXpect.Core.Tests.Core.Exceptions.FailExceptionTests ‑ Message_ShouldBeSet(message: "message683b2df8-6beb-46b9-93a0-0c5f133fbd67")
aweXpect.Core.Tests.Core.Exceptions.SkipExceptionTests ‑ Message_ShouldBeSet(message: "message95c4c000-3383-4c3b-9079-fd12abeb9d76")
aweXpect.Core.Tests.Core.Exceptions.SkipExceptionTests ‑ Message_ShouldBeSet(message: "messagea7a34ed6-013e-4449-95ef-fb8fcc8785b3")
aweXpect.Core.Tests.Core.Exceptions.SkipExceptionTests ‑ Message_ShouldBeSet(message: "messagec0e89371-a43f-4e22-bdd7-dedaba3ff093")
aweXpect.Core.Tests.Equivalency.EquivalencyOptionsExtensionsTests ‑ Generic_For_IgnoringMember_ShouldSetOptionForType(memberToIgnore: "memberToIgnore2263cab9-6097-4f4e-942a-22f8fbc58571")
aweXpect.Core.Tests.Equivalency.EquivalencyOptionsExtensionsTests ‑ Generic_For_IgnoringMember_ShouldSetOptionForType(memberToIgnore: "memberToIgnore2e7f3aae-94c4-4f2f-b763-9706adc28a91")
aweXpect.Core.Tests.Equivalency.EquivalencyOptionsExtensionsTests ‑ Generic_For_IgnoringMember_ShouldSetOptionForType(memberToIgnore: "memberToIgnore5f4c67d6-5352-4fd9-b40b-cf73f2e82ad4")
aweXpect.Core.Tests.FailTests ‑ Test_ShouldThrowException(reason: "reason1905290e-88e2-4b07-9fe9-c0eba5b4f91d")
…

@vbreuss vbreuss merged commit 6c23d3d into main Jun 26, 2025
13 checks passed
@vbreuss vbreuss deleted the topic/add-andwhoseresult-for-delegate-doesnotthrow branch June 26, 2025 19:10
@github-actions
Copy link
Copy Markdown
Contributor

This is addressed in release v2.18.0.

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

Labels

enhancement New feature or request state: released The issue is released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants