Conversation
## Between
You can verify that the `TimeSpan` is between two values:
```csharp
TimeSpan subject = TimeSpan.FromSeconds(42);
await Expect.That(subject).IsBetween(TimeSpan.FromSeconds(40)).And(TimeSpan.FromSeconds(50));
```
You can also specify a tolerance:
```csharp
TimeSpan subject = TimeSpan.FromSeconds(42);
await Expect.That(subject)
.IsBetween(43.Seconds())
.And(45.Seconds())
.Within(1.Seconds())
.Because("it should expand the interval by 1 second");
```
There was a problem hiding this comment.
Pull Request Overview
Adds support for “between” assertions on TimeSpan (and nullable) with optional tolerance.
- Introduces
IsBetweenandIsNotBetweenAPIs and their constraint implementations - Adds comprehensive unit tests covering edge cases and tolerance behavior
- Updates API surface expectations and documentation to reflect new methods
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| Source/aweXpect/That/TimeSpans/ThatTimeSpan.IsBetween.cs | Implements IsBetween/IsNotBetween for TimeSpan |
| Source/aweXpect/That/TimeSpans/ThatNullableTimeSpan.IsBetween.cs | Implements nullable overloads for the same APIs |
| Tests/aweXpect.Tests/TimeSpans/ThatTimeSpan.Nullable.IsNotBetween.Tests.cs | New tests for nullable IsNotBetween behavior |
| Tests/aweXpect.Tests/TimeSpans/ThatTimeSpan.Nullable.IsBetween.Tests.cs | New tests for nullable IsBetween behavior |
| Tests/aweXpect.Tests/TimeSpans/ThatTimeSpan.IsNotBetween.Tests.cs | New tests for non-nullable IsNotBetween behavior |
| Tests/aweXpect.Tests/TimeSpans/ThatTimeSpan.IsBetween.Tests.cs | New tests for non-nullable IsBetween behavior |
| Tests/aweXpect.Core.Tests/Customization/CustomizeSettingsTests.cs | Adjusts expected default timeout via #if DEBUG |
| Tests/aweXpect.Api.Tests/Expected/aweXpect_netstandard2.0.txt | Adds new method signatures for .NET Standard 2.0 |
| Tests/aweXpect.Api.Tests/Expected/aweXpect_net8.0.txt | Adds new method signatures for .NET 8.0 |
| Docs/pages/docs/expectations/10-timespan.md | Documents the new “Between” section |
Comments suppressed due to low confidence (2)
Tests/aweXpect.Tests/TimeSpans/ThatTimeSpan.Nullable.IsNotBetween.Tests.cs:110
- [nitpick] The test name implies the subject is not between the bounds, but in this scenario the subject is between them. Consider renaming to
WhenSubjectIsBetweenMinimumAndMaximum_ShouldFailfor clarity.
public async Task WhenSubjectIsNotBetweenMinimumAndMaximum_ShouldFail()
Tests/aweXpect.Tests/TimeSpans/ThatTimeSpan.IsNotBetween.Tests.cs:82
- [nitpick] This test name suggests the subject is outside the range, but the subject is actually between. Rename to
WhenSubjectIsBetweenMinimumAndMaximum_ShouldFailto match the scenario.
public async Task WhenSubjectIsNotBetweenMinimumAndMaximum_ShouldFail()
|
🚀 Benchmark ResultsDetails
|
👽 Mutation ResultsaweXpectDetails
The final mutation score is 93.67%Coverage Thresholds: high:80 low:60 break:0aweXpect.CoreDetails
The final mutation score is NaN%Coverage Thresholds: high:80 low:60 break:0 |
|
This is addressed in release v2.14.0. |



Adds support for “between” assertions on
TimeSpan(and nullable) with optional tolerance.IsBetweenandIsNotBetweenAPIs and their constraint implementationsBetween
You can verify that the
TimeSpanis between two values:You can also specify a tolerance: