public void InvokeTask_ShouldTrackInvocationWithExceptionThrown() { // Arrange MockMethodWithParam <string> subject = new MockMethodWithParam <string>("methodName"); subject.UpdateInvocation(() => { }, () => throw new Exception("Second Invocation")); // Act Func <Task> actual = async() => await subject.InvokeTask(""); Func <Task> thrower = async() => await subject.InvokeTask(""); // Assert actual.Should().NotThrow(); thrower.Should().ThrowExactly <Exception>().WithMessage("Second Invocation"); subject.AssertInvokedCountMatches(2); }