Esempio n. 1
0
        public State AddState(Action<State> initializer)
        {
            var state = new State { Id = _states.Count + 1 };
            _states.Add(state);

            if (initializer != null)
                initializer(state);

            return state;
        }
Esempio n. 2
0
 private CreatePathExpression State(State state)
 {
     if (_selectingTo)
     {
         _to = state;
         _createdPath = _machine.CreatePath(_from, _to);
         return this;
     }
     else
     {
         _from = state;
         return this;
     }
 }
Esempio n. 3
0
 protected override void Because()
 {
     _state = sut.AddState(s => s.Name = _name);
     sut.Start();
 }
Esempio n. 4
0
 public Context(StateMachine stateMachine, State associatedState)
 {
     AssociatedState = associatedState;
     _stateMachine = stateMachine;
 }
Esempio n. 5
0
 public void AddDestination(State destination)
 {
     destinations.Add(destination);
 }
Esempio n. 6
0
 public Path(State fromState)
 {
     FromState = fromState;
 }
Esempio n. 7
0
 public ContextStub(StateMachine stateMachine, State associatedState)
     : base(stateMachine, associatedState)
 {
 }
Esempio n. 8
0
 public UseSwordContext(StateMachine stateMachine, State associatedState)
     : base(stateMachine, associatedState)
 {
 }
Esempio n. 9
0
 public UseBareHandsContext(StateMachine stateMachine, State associatedState)
     : base(stateMachine, associatedState)
 {
 }
Esempio n. 10
0
 public SamuraiContext(StateMachine stateMachine, State associatedState)
     : base(stateMachine, associatedState)
 {
 }
Esempio n. 11
0
        public Path CreatePath(State from, State to)
        {
            if (from == to)
                throw new ArgumentException("Can't add a path between two equal states");

            Path path = _paths.SingleOrDefault(p => p.FromState == from);
            if (path == null)
            {
                path = new Path(from);
                _paths.Add(path);
            }

            if (path.Destinations.Any(d => d == to))
                throw new ArgumentException(string.Format("There is already a destination {0} for state {1}", to.Id, from.Id));

            path.AddDestination(to);
            return path;
        }
Esempio n. 12
0
 private void SetCurrentState(State state)
 {
     CurrentState = state;
 }