Assertions for Func<Task<T>>
See original GitHub issueCurrently both Func<Task>
and Func<Task<T>>
are handled by AsyncFunctionAssertions
which has a Subject
of type Func<Task>
and hence ignores the return value for Func<Task<T>>
.
If we split AsyncFunctionAssertions
into:
AsyncFunctionAssertions
forFunc<Task<T>>
, andAsyncActionAssertions
forFunc<Task>
That should enable us to return the result of Task<T>
for further assertions, similar to what was implement ed for Func<T>
in #951, such as:
// Arrange/Act
Func<Task<int>> func = () => Task.FromResult(42);
// Assert
func.Should().NotThrow().Which.Should().Be(42);
(await func.Should().NotThrowAsync()).Which.Should().Be(42);
This was inspired by this question
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Assertion Functions in TypeScript
An assertion function is a function that throws an error if something unexpected happened. Using assertion signatures, we can tell TypeScript ...
Read more >Assert Function (The GNU Awk User's Guide)
The assert() function tests the condition parameter. If it is false, it prints a message to standard error, using the string parameter to...
Read more >assert() — Verify Condition
The assert() function prints a diagnostic message to stderr and aborts the program if expression is false (zero). The diagnostic message has one...
Read more >What is the "assert" function? - c++
It is a function that will halt program execution if the value it has evaluated is false. Usually it is surrounded by a...
Read more >Playground Example - Assertion Functions
These are typically called assertions (or invariants) and they are small functions which raise errors early when your variables don't match up to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I would like to combine this extension with an additional feature:
The test would fail if the Task does not complete within specified time span.
What do you think about such feature?
@lg2de I would prefer if you opened a new issue with an API proposal describing the purpose of the functions and their function signatures.