How to understand example about exceptions #1731
Answered
by
dennisdoomen
lszczygielek
asked this question in
Q&A
-
I'm looking at https://fluentassertions.com/exceptions/ and I understand example like: Action act = () => subject.Foo2("Hello");
act.Should().Throw<InvalidOperationException>()
.WithInnerException<ArgumentException>()
.WithMessage("whatever"); Then I look at paragraph about Func<Task> act = () => asyncObject.ThrowAsync<ArgumentException>();
await act.Should().ThrowAsync<InvalidOperationException>();
await act.Should().NotThrowAsync(); And I don't know what it is. What is In my tests I use: Func<Task<MyType>> func = () => myObject.MyMethodAsync(1).;
await func.Should().ThrowAsync<Exception>(); It works, but when I compare it with example from documentation, I have doubts if I'm doing OK. |
Beta Was this translation helpful? Give feedback.
Answered by
dennisdoomen
Nov 5, 2021
Replies: 1 comment 1 reply
-
In this example, the |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
jnyrup
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In this example, the
asyncObject
is an instance of some type that has anasync
method namesThrowAsync
.