public void InstructionParseTest() { var expected = new IRoverAction[] { RoverActionPool.GetAction('L'), RoverActionPool.GetAction('M'), RoverActionPool.GetAction('L'), RoverActionPool.GetAction('M'), RoverActionPool.GetAction('R'), }; var actual = "LMLMR".ParseAsInstructions().ToArray(); Assert.Equal(expected, actual); }
public void Testing_For_Misc_Command1() { position = new RoverLocationDetails(1, 1, 10, 10, "east"); string command = "FLLFR"; foreach (var key in command) { IRoverAction action = RoverAction.DoAction(key); action.PerformAction(position); } RoverFinalCoordinate mars = new RoverFinalCoordinate(); Assert.Equal("2 2 northeast", mars.GetFinalCoordinate(position)); }
public void Testing_For_Boundary() { position = new RoverLocationDetails(10, 10, 10, 10, "north"); string command = "FFFFF"; foreach (var key in command) { IRoverAction action = RoverAction.DoAction(key); action.PerformAction(position); } RoverFinalCoordinate mars = new RoverFinalCoordinate(); Assert.Equal("10 10 north", mars.GetFinalCoordinate(position)); }
public void Testing_For_Misc_Command3() { position = new RoverLocationDetails(3, 3, 5, 5, "east"); string command = "FFRFFRFRRF"; foreach (var key in command) { IRoverAction action = RoverAction.DoAction(key); action.PerformAction(position); } RoverFinalCoordinate mars = new RoverFinalCoordinate(); Assert.Equal("4 2 west", mars.GetFinalCoordinate(position)); }
public void Testing_For_Misc_Command2() { position = new RoverLocationDetails(1, 2, 5, 5, "north"); string command = "LFLFLFLFF"; foreach (var key in command) { IRoverAction action = RoverAction.DoAction(key); action.PerformAction(position); } RoverFinalCoordinate mars = new RoverFinalCoordinate(); Assert.Equal("0 1 south", mars.GetFinalCoordinate(position)); }
public void Testing_For_Right() { position = new RoverLocationDetails(1, 1, 10, 10, "north"); position.XLower = 0; position.XUpper = 10; position.YLower = 0; position.YUpper = 10; string command = "RR"; foreach (var key in command) { IRoverAction action = RoverAction.DoAction(key); action.PerformAction(position); } RoverFinalCoordinate mars = new RoverFinalCoordinate(); Assert.Equal("1 1 east", mars.GetFinalCoordinate(position)); }
public void DoAction(char actionToDo) { this.actionToDo = RoverActionFactory.GetRoverAction(actionToDo); state.DoAction(this); }