Esempio n. 1
0
            private Action startStateMachineAndPrepareSecondStart(StateResult first, StateResult second)
            {
                var observable = stateMachineFinised();

                StateMachine.Start(first.Transition());
                observable.Wait();
                return(() => StateMachine.Start(second.Transition()));
            }
Esempio n. 2
0
            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>();
            }
Esempio n. 3
0
            public void ReturnsHandlerThatCallsProvidedGenericStateFactory()
            {
                var stateResult    = new StateResult <object>();
                var expectedResult = Substitute.For <IObservable <ITransition> >();

                provider.ConfigureTransition(stateResult, _ => expectedResult);

                var handler      = provider.GetTransitionHandler(stateResult);
                var actualResult = handler(stateResult.Transition(null));

                actualResult.Should().Be(expectedResult);
            }
Esempio n. 4
0
            public void ReturnsHandlerThatCallsProvidedGenericStateFactoryWithCorrectArgument()
            {
                var    stateResult      = new StateResult <object>();
                var    expectedArgument = new object();
                object actualArgument   = null;

                provider.ConfigureTransition(stateResult, obj => { actualArgument = obj; return(null); });

                var handler = provider.GetTransitionHandler(stateResult);

                handler(stateResult.Transition(expectedArgument));

                actualArgument.Should().Be(expectedArgument);
            }
Esempio n. 5
0
 public static IObservable <ITransition> OnErrorReturnResult <T>(this IObservable <ITransition> observable, StateResult <T> errorResult)
     where T : Exception
 => observable.Catch((T exception) => Observable.Return(errorResult.Transition(exception)));