public StepResponse CommitStep(string input) { var response = _getRoverPositionFromUser.GetRoverPostion(input); if (!response.Success) { return(new StepResponse(response.Message)); } var result = _sim.AddRover(response.Data); return(!result.Success ? new StepResponse(result._legality.ToString()) : new StepResponse(new MoveRoverStep(_sim, result.Rover))); }
public void SimpleMovement() { Simulation _simulation = new Simulation(new Coordinate(5, 5)); var a = _simulation.AddRover(new NewRoverInput(Direction.North, new Coordinate(1, 2))); var directions = new List <Movement>() { Movement.Left, Movement.Move, Movement.Left, Movement.Move, Movement.Left, Movement.Move, Movement.Left, Movement.Move, Movement.Move }; var result = _simulation.TryMoveRover(directions, a.Rover); Assert.AreEqual(result._finalCord, new Coordinate(1, 3)); Assert.AreEqual(result._rover.CurrentDirection, Direction.North); Assert.Pass(); }
public void MovingOffGridResultsInCorrectError() { Simulation _simulation = new Simulation(new Coordinate(5, 5)); var a = _simulation.AddRover(new NewRoverInput(Direction.North, new Coordinate(3, 3))); var directions = new List <Movement>() { Movement.Move, Movement.Move, Movement.Move }; var result = _simulation.TryMoveRover(directions, a.Rover); Assert.AreEqual(result._finalCord, new Coordinate(3, 3)); Assert.AreEqual(result.IsSuccess(), false); Assert.AreEqual(result._legalityOfMove.CantMoveBecauseOffscreen, true); Assert.AreEqual(result._legalityOfMove.CantMoveBecauseRoverInWay, false); Assert.AreEqual(result._rover.CurrentDirection, Direction.North); Assert.Pass(); }