public async Task WithThrownExceptionThrowsException() { // arrange Mock <AbstractLogger> mockLogger = new Mock <AbstractLogger>(); TimerInfo timerInfo = Mockers.GetTimerInfo(); var sut = HealthMockers.GetApiFunctions( out Mock <IUserAuthenticationService> mockUserAuth, out Mock <IHealthService> mockHealthService); System.Exception ex = new System.Exception("My error."); mockHealthService.Setup(m => m.HealthCheck()) .ThrowsAsync(ex); // act await Assert.ThrowsExceptionAsync <System.Exception>(() => sut.SystemHealthCheckTimer(timerInfo, mockLogger.Object)).ConfigureAwait(false); mockLogger.Verify(moc => moc.Log(LogLevel.Error, It.IsAny <System.Exception>(), "Unhandled Exception.")); }