Skip to content

feat: support null in WithParamName#678

Merged
vbreuss merged 1 commit intomainfrom
topic/support-null-for-withparamname
Jul 10, 2025
Merged

feat: support null in WithParamName#678
vbreuss merged 1 commit intomainfrom
topic/support-null-for-withparamname

Conversation

@vbreuss
Copy link
Copy Markdown
Member

@vbreuss vbreuss commented Jul 10, 2025

This PR enhances the WithParamName and HasParamName APIs to accept a nullable expected parameter name, treating null as “do not verify”.

@vbreuss vbreuss self-assigned this Jul 10, 2025
Copilot AI review requested due to automatic review settings July 10, 2025 14:34
@vbreuss vbreuss added the enhancement New feature or request label Jul 10, 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 enhances the WithParamName and HasParamName APIs to accept a nullable expected parameter name, treating null as “do not verify”—and adds tests and API signature updates to cover that behavior.

  • Allow string? expected and skip verification when expected is null.
  • Add unit tests in both exception-based and delegate-based lives to assert that null expectations pass.
  • Update expected API snapshots to reflect the nullable string? expected signatures.

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/Exceptions/ThatException.HasParamName.Tests.cs Add tests for HasParamName(null) scenarios
Tests/aweXpect.Tests/Delegates/ThatDelegate.Throws.WithParamNameTests.cs Add tests for Throws…().WithParamName(null) scenarios
Tests/aweXpect.Api.Tests/Expected/aweXpect_netstandard2.0.txt Change WithParamName(string)WithParamName(string?)
Tests/aweXpect.Api.Tests/Expected/aweXpect_net8.0.txt Change WithParamName(string)WithParamName(string?)
Source/aweXpect/That/Exceptions/ThatException.HasParamName.cs Update signature to string? expected and constraint logic
Source/aweXpect/That/Delegates/ThatDelegateThrows.WithParamName.cs Update signature, add a null‐skip branch in WithParamName
Comments suppressed due to low confidence (2)

Tests/aweXpect.Tests/Exceptions/ThatException.HasParamName.Tests.cs:11

  • [nitpick] The test name says ‘ParamNameIsEmpty’ but the default ArgumentException constructor sets ParamName to null, not an empty string. Consider renaming to ParamNameIsNull for clarity.
			public async Task WhenExpectedIsNull_AndParamNameIsEmpty_ShouldSucceed(string message)

Tests/aweXpect.Tests/Delegates/ThatDelegate.Throws.WithParamNameTests.cs:11

  • [nitpick] Similar to the exception-based test, this delegate test name implies an empty string but ParamName is null by default. Renaming to ParamNameIsNull would be more accurate.
			public async Task WhenExpectedIsNull_AndParamNameIsEmpty_ShouldSucceed(string message)

Comment thread Source/aweXpect/That/Delegates/ThatDelegateThrows.WithParamName.cs
@sonarqubecloud
Copy link
Copy Markdown

@vbreuss vbreuss enabled auto-merge (squash) July 10, 2025 14:39
@github-actions
Copy link
Copy Markdown
Contributor

Test Results

    14 files   - 24      14 suites   - 24   2m 52s ⏱️ +10s
13 839 tests  - 11  13 837 ✅  - 11  2 💤 ±0  0 ❌ ±0 
38 394 runs   - 60  38 392 ✅  - 60  2 💤 ±0  0 ❌ ±0 

Results for commit e900ad8. ± Comparison against base commit 53a8dd1.

@vbreuss vbreuss merged commit 5c5e19b into main Jul 10, 2025
13 checks passed
@vbreuss vbreuss deleted the topic/support-null-for-withparamname branch July 10, 2025 14:44
@github-actions
Copy link
Copy Markdown
Contributor

🚀 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.412
[Host] : .NET 8.0.18 (8.0.1825.31117), X64 RyuJIT AVX2

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

Method Mean Error StdDev Gen0 Gen1 Allocated
Bool_aweXpect 187.8 ns 7.58 ns 7.09 ns 0.0281 - 472 B
Bool_FluentAssertions 268.2 ns 4.87 ns 4.32 ns 0.0567 - 952 B
Bool_TUnit 983.0 ns 14.72 ns 13.77 ns 0.1440 - 2416 B
Equivalency_aweXpect 294,803.1 ns 827.40 ns 690.92 ns 16.6016 0.4883 284940 B
Equivalency_FluentAssertions 2,237,106.2 ns 36,859.17 ns 34,478.09 ns 273.4375 46.8750 4584416 B
Equivalency_TUnit 708,781.3 ns 1,413.19 ns 1,252.76 ns 51.7578 2.9297 866777 B
Int_GreaterThan_aweXpect 229.0 ns 7.00 ns 6.55 ns 0.0467 - 784 B
Int_GreaterThan_FluentAssertions 264.4 ns 10.40 ns 9.73 ns 0.0730 - 1224 B
Int_GreaterThan_TUnit 1,306.7 ns 5.22 ns 4.63 ns 0.1774 - 2992 B
ItemsCount_AtLeast_aweXpect 493.5 ns 13.61 ns 12.73 ns 0.0849 - 1432 B
ItemsCount_AtLeast_FluentAssertions 536.3 ns 10.53 ns 9.85 ns 0.1192 - 2008 B
ItemsCount_AtLeast_TUnit 16,509.7 ns 311.50 ns 291.38 ns 1.6174 - 27488 B
String_aweXpect 385.3 ns 8.16 ns 7.63 ns 0.0672 - 1128 B
String_FluentAssertions 508.0 ns 19.18 ns 17.94 ns 0.1287 - 2168 B
String_TUnit 1,354.2 ns 4.58 ns 4.06 ns 0.1850 - 3096 B
StringArray_aweXpect 1,437.0 ns 16.25 ns 14.41 ns 0.1640 - 2744 B
StringArray_FluentAssertions 1,391.9 ns 21.13 ns 19.77 ns 0.2480 - 4152 B
StringArray_TUnit 3,037.0 ns 12.23 ns 10.85 ns 0.2708 - 4576 B
StringArrayInAnyOrder_aweXpect 1,652.9 ns 14.13 ns 13.22 ns 0.1736 - 2920 B
StringArrayInAnyOrder_FluentAssertions 154,560.6 ns 597.35 ns 529.53 ns 3.4180 - 63787 B
StringArrayInAnyOrder_TUnit 4,811.5 ns 16.38 ns 15.32 ns 0.3967 - 6744 B

@github-actions
Copy link
Copy Markdown
Contributor

👽 Mutation Results

Mutation testing badge

aweXpect

Details
File Score Killed Survived Timeout No Coverage Ignored Compile Errors Total Detected Total Undetected Total Mutants
That/Delegates/ThatDelegateThrows.WithParamName.cs 75.00% 3 1 0 0 1 0 3 1 5
That/Exceptions/ThatException.HasParamName.cs 46.43% 13 0 0 15 12 15 13 15 55

The final mutation score is 50.00%

Coverage Thresholds: high:80 low:60 break:0

aweXpect.Core

Details
File Score Killed Survived Timeout No Coverage Ignored Compile Errors Total Detected Total Undetected Total Mutants

The final mutation score is NaN%

Coverage Thresholds: high:80 low:60 break:0

github-actions Bot added a commit that referenced this pull request Jul 10, 2025
github-actions Bot added a commit that referenced this pull request Jul 10, 2025
@github-actions
Copy link
Copy Markdown
Contributor

This is addressed in release v2.19.1.

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