protected void GivenRoverWithDirection(IDirectionState direction) { var coordinate = new Coordinate(5, 5); var plateau = new Plateau(100, 100); Rover = new Rover(plateau, coordinate, direction); }
public StateMachine(IDirectionState directionManager) { _directionManager = directionManager; _occupiedGrids = new List <GridPosition>(); GridBoundary = new GridPosition { XPos = int.MaxValue, YPos = int.MaxValue }; }
private Rover GetRover(MarsArea marsArea, string locationText) { RoverLocation roverLocation = GetRoverLocation(locationText); IDirectionState directionState = GetDirectionState(locationText); ILocation location = new Location(marsArea, roverLocation); return(new Rover(directionState, location)); }
private string GetDirectionStateKey(IDirectionState directionState) { return(directionState switch { NorthState => Constant.NORTH_KEY, EastState => Constant.EAST_KEY, WestState => Constant.WEST_KEY, SouthState => Constant.SOUTH_KEY, _ => throw new Exception(Constant.UNDEFINED_DIRECTION) });
public void FirstLocation_WhenMoveForward_ThenLastLocation(IDirectionState directionState, RoverLocation expectedRoverLocation) { //Given ILocation location = new Location(_defaultMarsArea, _defaultRoverLocation); //When location.MoveForward(directionState); //Then location.GetRoverLocation().Should().BeEquivalentTo(expectedRoverLocation); }
public void Direction_WhenTurnDirection_ThenExpectedDirection(IDirectionState directionState, Type leftDirectionType, Type rightDirectionType) { //Given from parameter //When IDirectionState turnedLeftDirectionState = directionState.TurnLeft(); IDirectionState turnedRightDirectionState = directionState.TurnRight(); //Then Assert.AreEqual(turnedLeftDirectionState.GetType(), leftDirectionType); Assert.AreEqual(turnedRightDirectionState.GetType(), rightDirectionType); }
public void MoveForward(IDirectionState directionState) { switch (directionState) { case NorthState: MoveNorth(); break; case EastState: MoveEast(); break; case WestState: MoveWest(); break; case SouthState: MoveSouth(); break; default: throw new Exception(Constant.UNDEFINED_DIRECTION); } ; }
void IEcsRunSystem.Run() { if (!_restartEventFilter.IsEmpty()) { foreach (var index in _filter) { ref var turtlePath = ref _filter.Get1(index); var paths = turtlePath.Path; paths.Clear(); _direction = new RightDirectionState(); for (var i = 0; i < _turtleConfiguration.PathsCount; i++) { paths.Add(GeneratePath()); } var entity = _filter.GetEntity(index); ref var updateTextEvent = ref entity.Get <UpdateTextEvent>(); updateTextEvent.Text = string.Join("", paths[0]); turtlePath.CurrentPath = 0; turtlePath.CurrentSymbol = 0; }
protected void UpdateStatus(Position position, Direction direction, IDirectionState state) { OnchangeDirectionEvent?.Invoke(position, direction, state); }
void UpdateStatus(Position position, Direction direction, IDirectionState state) { Position = position; Direction = direction; UpdateEvents(state); }
public void TurnRight() { _directionState = _directionState.TurnRight(); }
public Rover(IDirectionState directionState, ILocation location) { _directionState = directionState; _location = location; }
public void TurnRight() { Direction = Direction.Right(); }
public void TurnLeft() { _directionState = _directionState.TurnLeft(); }
public void TurnLeft() { Direction = Direction.Left(); }
public Rover(Plateau plateau, Coordinate coordinate, IDirectionState direction) { this.Coordinate = coordinate; this.Direction = direction; this.plateau = plateau; }
public RoverPosition(Coordinate coordinate, IDirectionState direction) { this.Coordinate = coordinate; this.Direction = direction; }
void UpdateEvents(IDirectionState newstate) { MachineState.OnchangeDirectionEvent -= UpdateStatus; MachineState = newstate; MachineState.OnchangeDirectionEvent += UpdateStatus; }
public void Setup() { _directionManager = new DirectionManager(); stateMachine = new StateMachine.StateMachine(_directionManager); }