private CreatePathExpression State(State state) { if (_selectingTo) { _to = state; _createdPath = _machine.CreatePath(_from, _to); return this; } else { _from = state; return this; } }
protected override void Because() { base.Because(); sut.AddState(); sut.AddState(); sut.CreatePathFrom.State(1).To.State(2).GetPath(); path = sut.CreatePathFrom.State(1).To.State(3).GetPath(); sut.Start(); }
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; }