public void retry_on_error_determines_whether_a_given_exception_results_in_a_retry() { var tries = 0; var scheduler = new TestScheduler(); var source = Observable .Defer( () => { ++tries; if (tries < 3) { return(Observable.Throw <Unit>(new InvalidOperationException())); } return(Observable.Throw <Unit>(new Exception())); }); var sut = source .RetryWithBackoff(100, retryOnError: ex => ex is InvalidOperationException, scheduler: scheduler) .Subscribe( _ => { }, ex => { }); Assert.Equal(1, tries); scheduler.AdvanceUntilEmpty(); Assert.Equal(3, tries); }
public void repeat_count_determines_how_many_times_to_repeat(int repeatCount) { var repetitions = 0; var scheduler = new TestScheduler(); var source = Observable .Defer( () => { ++repetitions; return(Observable.Return(Unit.Default)); }); var sut = source .RepeatWithBackoff(repeatCount, scheduler: scheduler) .Subscribe( _ => { }, ex => { }); scheduler.AdvanceUntilEmpty(); Assert.Equal(repeatCount, repetitions); }
public void retry_count_determines_how_many_times_to_retry(int retryCount) { var tries = 0; var scheduler = new TestScheduler(); var source = Observable .Defer( () => { ++tries; return(Observable.Throw <Unit>(new Exception())); }); var sut = source .RetryWithBackoff(retryCount, scheduler: scheduler) .Subscribe( _ => { }, ex => { }); scheduler.AdvanceUntilEmpty(); Assert.Equal(retryCount, tries); }