public void InvokeTask_ShouldTrackInvocationWithExceptionThrown() { // Arrange MockMethod subject = new MockMethod("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); }