public void Stop_When_ExceptionIsThrown_Then_ResultShouldContainThrownException() { using var resetEvent = new ManualResetEventSlim(); using var testee = new ContinuousJob(_ => { resetEvent.Set(); throw new InvalidOperationException(); }); testee.Start(); resetEvent.Wait(); Thread.Sleep(1); var result = testee.Stop(); result.Error !.InnerException.Should().BeOfType <InvalidOperationException>(); }
public void Start_When_ExceptionIsThrownAndHandled4Times_Then_TesteExceptionShouldContainThrownException() { using var resetEvent = new ManualResetEventSlim(); var errorCounter = 0; using var testee = new ContinuousJob( _ => throw new InvalidOperationException(), (Exception _, ref bool handled) => handled = errorCounter++ < 4); testee.Start(); testee.Wait(); Thread.Sleep(1); testee.Exception !.InnerException.Should().BeOfType <InvalidOperationException>(); }