Exemple #1
0
        public void Specifying_an_event_activity()
        {
            _instance = new Instance();
            _machine  = new InstanceStateMachine();
            _observer = new StateChangeObserver <Instance>();

            using (IDisposable subscription = _machine.StateChanged.Subscribe(_observer))
            {
                _machine.TransitionToState(_instance, _machine.Running);
            }
        }
        public void Specifying_an_event_activity()
        {
            _instance = new Instance();
            _machine  = new InstanceStateMachine();
            _observer = new StateChangeObserver <Instance>();

            using (IDisposable subscription = _machine.ConnectStateObserver(_observer))
            {
                _machine.RaiseEvent(_instance, x => x.Initialized).Wait();
                _machine.RaiseEvent(_instance, x => x.Finish).Wait();
            }
        }
        public void Specifying_an_event_activity()
        {
            _instance      = new Instance();
            _machine       = new InstanceStateMachine();
            _observer      = new StateChangeObserver <Instance>();
            _eventObserver = new EventRaisedObserver <Instance>();

            using (IDisposable subscription = _machine.ConnectStateObserver(_observer))
                using (IDisposable beforeEnterSub = _machine.ConnectEventObserver(_machine.Initialized, _eventObserver))
                    using (IDisposable afterLeaveSub = _machine.ConnectEventObserver(_machine.LegCramped, _eventObserver))
                    {
                        _machine.RaiseEvent(_instance, x => x.Initialized).Wait();
                        _machine.RaiseEvent(_instance, x => x.LegCramped).Wait();
                        _machine.RaiseEvent(_instance, x => x.Finish).Wait();
                    }
        }