public void DoesNotGetStuckInADeadlockWhenSomeTransitionTimeOuts(int n) { Reset(); var someResult = new StateResult(); var lastResult = PrepareTransitions(someResult, n); Transitions.ConfigureTransition(lastResult, new TestSyncState(Observable.Never <ITransition>)); var observable = stateMachineFinised(); StateMachine.Start(someResult.Transition()); ((TestScheduler)Scheduler).AdvanceBy(TimeSpan.FromSeconds(62).Ticks); observable.Wait(); Action secondStart = () => StateMachine.Start(someResult.Transition()); secondStart.Should().NotThrow <InvalidOperationException>(); }
protected StateResult PrepareTransitions(StateResult entryPoint, int n) { var lastResult = entryPoint; for (byte i = 0; i < n; i++) { var nextResult = new StateResult(); Func <IObservable <ITransition> > transition = () => Observable.Create <ITransition>(async observer => { await Task.Delay(1).ConfigureAwait(false); observer.OnNext(new Transition(nextResult)); observer.OnCompleted(); }); Transitions.ConfigureTransition(lastResult, new TestSyncState(transition)); lastResult = nextResult; } return(lastResult); }
protected void PrepareFailingTransition(StateResult lastResult) { Func <IObservable <ITransition> > failingTransition = () => Observable.Throw <ITransition>(new TestException()); Transitions.ConfigureTransition(lastResult, new TestSyncState(failingTransition)); }