Conversation
…sertions, and Contain for EnumerableAssertions Co-authored-by: MrKWatkins <345796+MrKWatkins@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add floating point assertions and numeric comparisons
Add floating-point assertions, numeric comparison assertions, and Feb 19, 2026
Contain for enumerables
MrKWatkins
requested changes
Feb 20, 2026
Owner
MrKWatkins
left a comment
There was a problem hiding this comment.
You didn't do these points from my list:
- Async Action Assertions (new type group)
ActionAssertions covers Action only. Required for async delegates (Func):
ThrowAsync<TException>() — asserts the async action throws the specified exception type
ThrowAsync<TException>(string expectedMessage) — with message check
NotThrowAsync() — asserts the async action does not throw
Should mirror the existing ActionAssertions API and chain into ExceptionAssertions.
Entry point needed in ShouldExtensions:
Should(this Func<Task> value) → AsyncActionAssertions
(2 uses, e.g. await multiEnvironment.Awaiting(m => m.StopAsync()).Should().ThrowAsync().WithMessage(...))
Also needed in InvokingExtensions:
Awaiting<T>(this T value, Func<T, Task> action) → Func<Task>
Typed NotThrow<TException>()
ActionAssertions.NotThrow() asserts no exception is thrown. There is also usage of a typed variant that asserts a specific exception type is not thrown (other exceptions may propagate):
NotThrow<TException>() — asserts the action does not throw TException specifically
(e.g. stream.Invoking(s => s.WriteByte(0)).Should().NotThrow())
Change the NotThrow methods, sync and async, for Funcs to return the result of the func afterwards to allow chaining, via a AndResult parameter. E.g. Assert.That(x => x.ToString).Should().NotThrow().And.Result.Should().NotBeNull()
…Task>), and Awaiting extensions Co-authored-by: MrKWatkins <345796+MrKWatkins@users.noreply.github.com>
Contributor
Author
Added in fd1d985:
Usage example: await multiEnvironment.Awaiting(m => m.StopAsync()).Should().ThrowAsync<SomeException>("expected message"); |
Copilot
AI
changed the title
Add floating-point assertions, numeric comparison assertions, and
Add floating-point assertions, numeric comparison assertions, Feb 20, 2026
Contain for enumerablesContain for enumerables, and async action assertions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds four missing assertion capabilities needed for projects working with numeric comparisons, enumerable containment, and async code.
New:
FloatingPointAssertions<T>(IFloatingPoint<T>constrained)floatanddoublenow get a dedicated assertions type viaShould():BeApproximately(T expected, T precision)— asserts|value − expected| ≤ precisionBeLessThan,BeLessThanOrEqualTo,BeGreaterThan,BeGreaterThanOrEqualToFloatingPointAssertionsChain<T>for.AndchainingNumeric comparisons on
IntegerAssertions<T>BeLessThan,BeLessThanOrEqualTo,BeGreaterThan,BeGreaterThanOrEqualToadded — leverages the existingIBinaryInteger<T>constraint'sIComparisonOperators.ContainonEnumerableAssertions<TEnumerable, T>Asserts the enumerable contains a specific item; throws
"Value should contain {expected} but did not."on failure.New:
AsyncActionAssertionsforFunc<Task>Async delegates now have a dedicated assertions type via
Should(), mirroring the existingActionAssertionsAPI:ThrowAsync<TException>()— asserts the async action throws the specified exception type, returnsTask<ActionAssertionsChain<TException>>ThrowAsync<TException>(string expectedMessage)— with message checkNotThrowAsync()— asserts the async action does not throwInvokingExtensionsgainsAwaiting<T>(this T value, Func<T, Task> action)andAwaiting<T, TResult>(this T value, Func<T, Task<TResult>> action)for wrapping async methods on a value for assertion testing.💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.