public void MoveFromOvestDirection_ObstaclePoint_ThrowException() { var B = new Backward(); Grid G = new Grid(5, 5, new FakeObstacleGenerator()); RoverMars R = new RoverMars('O'); R.Position.X = 1; R.Position.Y = 2; B.MoveFromOvestDirection(R, G); }
public void MoveFromSudDirection_turnLeft_expectedNewDirection_E() { var rover = new RoverMars('S'); var g = new Grid(2, 3, new FakeObstacleGenerator()); var L = new Left(); char expected = 'E'; L.MoveFromSudDirection(rover, g); Assert.AreEqual(expected, rover.Direction); }
public void MoveFromEstDirection_TurnRight_newExpectedDirection_S() { var r = new RoverMars('E'); var g = new Grid(4, 4, new FakeObstacleGenerator()); var R = new Right(); R.MoveFromEstDirection(r, g); char expected = 'S'; Assert.AreEqual(expected, r.Direction); }
public void MoveRover_RoverDirectionSRightInputCommand_MoveFromSudDirectionOfRightCommandIsCalled() { var rover = new RoverMars('S'); var g = new Grid(4, 4, new FakeObstacleGenerator()); var command = new List <ICommand> { new FakeRigtCommand() }; Move.MoveRover(rover, g, command); var TestCommand = command[0] as FakeRigtCommand; Assert.IsTrue("Right.MoveFromSudDirection".Equals(TestCommand.Fake)); }
public void MoveRover_RoverDirectionNLeftImputCommand_MoveFromNordDirectionOfLeftCommandIsCalled() { var rover = new RoverMars('N'); var g = new Grid(4, 4, new FakeObstacleGenerator()); var command = new List <ICommand> { new FakeLeftCommand() }; Move.MoveRover(rover, g, command); var TestCommand = command[0] as FakeLeftCommand; Assert.IsTrue("Left.MoveFromNordDirection".Equals(TestCommand.Fake)); }
public void MoveFromOvestDirection_NewRoverPoint_OutOfGridValueLessThenZero_Expected_NewXEqualsMaxXOfGrid() { { var B = new Backward(); Grid G = new Grid(5, 5, new FakeObstacleGenerator()); RoverMars R = new RoverMars('O'); R.Position.X = -2; R.Position.Y = 2; B.MoveFromOvestDirection(R, G); Point expectedNewRoverPosition = new Point(5, 2); Assert.AreEqual(expectedNewRoverPosition, R.Position); } }
public void MoveFromSudDirection_ObstaclePoint_ThrowException() { var B = new Backward(); RoverMars R = new RoverMars('N'); // this case should never happen but this class does not know // i give to the rover an impossible point R.Position.X = 2; R.Position.Y = 1; Grid G = new Grid(5, 5, new FakeObstacleGenerator()); B.MoveFromSudDirection(R, G); }
public void MoveRover_RoverDirectionEBackwardtInputCommand_MoveFromEstDirectionOfBackwardCommandIsCalled() { var rover = new RoverMars('E'); var g = new Grid(4, 4, new FakeObstacleGenerator()); var command = new List <ICommand> { new FakeBackwardCommand() }; Move.MoveRover(rover, g, command); var TestCommand = command[0] as FakeBackwardCommand; Assert.IsTrue("Backward.MoveFromEstDirection".Equals(TestCommand.Fake)); }
public void MoveFromNordDirection_NewRoverPoint_OutOfGrid_Expected_NewYEqualsZero() { var B = new Backward(); RoverMars R = new RoverMars('N'); R.Position.X = 1; R.Position.Y = 7; Grid G = new Grid(5, 5, new FakeObstacleGenerator()); B.MoveFromNordDirection(R, G); Point expectedNewRoverPosition = new Point(1, 0); Assert.AreEqual(expectedNewRoverPosition, R.Position); }
public void MoveFromEstDirection_NewRoverPoint_OutOfGrid_Expected_NewXEqualsZero() { Backward B = new Backward(); RoverMars R = new RoverMars('E'); R.Position.X = 7; R.Position.Y = 1; Grid G = new Grid(5, 5, new FakeObstacleGenerator()); B.MoveFromEstDirection(R, G); Point expectedNewRoverPosition = new Point(0, 1); Assert.AreEqual(expectedNewRoverPosition, R.Position); }
public void MoveFromEstDirection_MoveRoverInXMinusOne() { var B = new Backward(); RoverMars R = new RoverMars('E'); R.Position.X = 1; R.Position.Y = 1; Grid G = new Grid(5, 5, new FakeObstacleGenerator()); B.MoveFromEstDirection(R, G); Point expectedNewRoverPosition = new Point(0, 1); Assert.AreEqual(expectedNewRoverPosition, R.Position); }
public void MoveFromOvestDirection_NewRoverPoint_OutOfGrid_Expected_NewXEqualsZero() { var B = new Backward(); Grid G = new Grid(5, 5, new FakeObstacleGenerator()); RoverMars R = new RoverMars('O'); //rover orientation is ovest direction R.Position.X = 5; R.Position.Y = 1; B.MoveFromOvestDirection(R, G); Point expectedNewRoverPosition = new Point(0, 1); Assert.AreEqual(expectedNewRoverPosition, R.Position); }
public void MoveFromSudDirection_MoveRoverInYMinusOne() { Foreward F = new Foreward(); RoverMars R = new RoverMars('S'); R.Position.X = 1; R.Position.Y = 1; Grid G = new Grid(5, 5, new FakeObstacleGenerator()); F.MoveFromSudDirection(R, G); Point expectedNewRoverPosition = new Point(1, 0); Assert.AreEqual(expectedNewRoverPosition, R.Position); }
public void MoveFromOvestDirection_NewRoverPoint_OutOfGrid_Expected_NewXEqualsZero() { Foreward F = new Foreward(); Grid G = new Grid(5, 5, new FakeObstacleGenerator()); RoverMars R = new RoverMars('O'); //rover orientation is ovest direction //rover actual position is an impossible point since in the reality this case never occurs R.Position.X = 7; R.Position.Y = 1; F.MoveFromOvestDirection(R, G); Point expectedNewRoverPosition = new Point(0, 1); Assert.AreEqual(expectedNewRoverPosition, R.Position); }
public void MoveFromSudDirection_NewRoverPoint_OutOfGrid_Expected_NewYEqualsZero() { Foreward F = new Foreward(); RoverMars R = new RoverMars('S'); //cannot happen R.Position.X = 1; R.Position.Y = 7; Grid G = new Grid(5, 5, new FakeObstacleGenerator()); F.MoveFromSudDirection(R, G); Point expectedNewRoverPosition = new Point(1, 0); Assert.AreEqual(expectedNewRoverPosition, R.Position); }
public void MoveFromSudDirection_NewRoverPoint_OutOfGridValueLessThenZero_Expected_NewYEqualsMaxYOfGrid() { var B = new Backward(); RoverMars R = new RoverMars('N'); // this case should never happen but this class does not know // i give to the rover an impossible point R.Position.X = 1; R.Position.Y = -2; Grid G = new Grid(5, 5, new FakeObstacleGenerator()); B.MoveFromSudDirection(R, G); Point expectedNewRoverPosition = new Point(1, 5); Assert.AreEqual(expectedNewRoverPosition, R.Position); }
public void MoveFromOvestDirection_MoveRoverInXPluOne() { Backward B = new Backward(); //rover orientation is ovest direction, is not responsibility of this class check direction RoverMars R = new RoverMars('O'); //rover actual position is 1,1 R.Position.X = 1; R.Position.Y = 1; Grid G = new Grid(5, 5, new FakeObstacleGenerator()); B.MoveFromOvestDirection(R, G); Point expectedNewRoverPosition = new Point(2, 1); Assert.AreEqual(expectedNewRoverPosition, R.Position); }
public void MoveFromEstDirection_NewRoverPoint_OutOfGridValueLessThenZero_Expected_NewXEqualsMaxXOfGrid() { Foreward F = new Foreward(); RoverMars R = new RoverMars('E'); // this case should never happen but this class does not know // i give to the rover an impossible point R.Position.X = -2; R.Position.Y = 1; Grid G = new Grid(5, 5, new FakeObstacleGenerator()); F.MoveFromEstDirection(R, G); Point expectedNewRoverPosition = new Point(5, 1); Assert.AreEqual(expectedNewRoverPosition, R.Position); }
static void Main(string[] args) { ObstacleGenerator generatorProva = new ObstacleGenerator(0); //ProvaAManoGeneratore generatorProva = new ProvaAManoGeneratore(); Grid myProvaGrid = new Grid(0, 0, generatorProva); RoverMars myRover = new RoverMars(); char commandToInsertInList = 'c'; List <ICommand> userList = new List <ICommand>(); Console.WriteLine("Welcome to the program that make you send command to rover in a list" + Environment.NewLine + "Digit F to insert a foreward command;" + Environment.NewLine + "Digit B to insert a backword command;" + Environment.NewLine + "Digit L to insert a left command;" + Environment.NewLine + "Digit R to insert a right command" + Environment.NewLine + "Digit E to send the complete list of command to the rover"); while (commandToInsertInList != 'E') { try { commandToInsertInList = Convert.ToChar(Console.ReadLine().ToUpper()); } catch (Exception e) { commandToInsertInList = 'c';//not valid command-->defalut is the case } switch (commandToInsertInList) { case 'F': userList.Add(new Foreward()); Console.WriteLine("if you want insert another command or send the list"); break; case 'B': userList.Add(new Backward()); Console.WriteLine("if you want insert another command or send the list"); break; case 'L': userList.Add(new Left()); Console.WriteLine("if you want insert another command or send the list"); break; case 'R': userList.Add(new Right()); Console.WriteLine("if you want insert another command or send the list"); break; case 'E': Console.WriteLine("The following command have been sent to Rover"); Console.ForegroundColor = ConsoleColor.Green; foreach (ICommand c in userList) { Console.WriteLine(c.ToString()); } Console.ResetColor(); break; default: Console.WriteLine("The command is not valid"); break; } } Console.WriteLine("The following are the rover movement"); Move.MoveRover(myRover, myProvaGrid, userList); Console.ReadLine();// only to not close terminal }