public void StateMachineStartedEventHandlerCanAccessDispatcher() { var evt = new ManualResetEvent(false); var dispatcherObject = new Window(); StateMachine = new ReactiveStateMachine.ReactiveStateMachine <TestStates>("TestMachine", TestStates.Collapsed); StateMachine.StateMachineStarted += (sender, args) => { Assert.DoesNotThrow(() => dispatcherObject.Dispatcher.VerifyAccess()); evt.Set(); }; StateMachine.Start(); while (!evt.WaitOne(50)) { DispatcherHelper.DoEvents(); } }
public void StateMachineExceptionEventHandlerCanAccessDispatcher() { var evt = new ManualResetEvent(false); var dispatcherObject = new Window(); StateMachine = new ReactiveStateMachine.ReactiveStateMachine <TestStates>("TestMachine", TestStates.Collapsed); StateMachine.AddAutomaticTransition(TestStates.Collapsed, TestStates.FadingIn, new Action(() => { throw new Exception(); })); StateMachine.StateMachineException += (sender, args) => { Assert.DoesNotThrow(() => dispatcherObject.Dispatcher.VerifyAccess()); evt.Set(); }; StateMachine.Start(); while (!evt.WaitOne(50)) { DispatcherHelper.DoEvents(); } }