0

Is use c# FluentAssertions and I want to assert if i given async method does not throw an exception.

Given a synchronous method, fluent assertions libray allows me to assert like this

 Action action = () => YourSynchronousMethod();
 action.Should().NotThrow<Exception>();

Can I do the same for async methods?

hannes neukermans
  • 12,017
  • 7
  • 37
  • 56
  • 1
    Does `Func f = async () => { await YourAsynchronousMethod(); };` and `f.Should().NotThrow()` work? – Thomas Weller Jul 24 '18 at 07:25
  • Bear in mind - `async` is an *implementation detail* of a method. Not part of it's signature. What you actually care about is making fluent assertions about *`Task` returning methods*, searching for which brought me to the suggested duplicate. – Damien_The_Unbeliever Jul 24 '18 at 07:27

0 Answers0