public void Create_Board_5X5_Set_Two_Rovers_1_2_N_Expects_Conflict_Exception() { RoverBoard board = new RoverBoard(5, 5); Rover rover = board.SetRoverOnBoard(new System.Drawing.Point(1, 2), RoverDirectionHelper.GetDirectionByChar('N')); board.ComputeMovements("M", rover); Rover rover2 = board.SetRoverOnBoard(new System.Drawing.Point(1, 2), RoverDirectionHelper.GetDirectionByChar('N')); board.ComputeMovements("M", rover2); }
public void Board5X5_RoverOn_1_2_N_Computes_LMLMLMLMM_Expects_1_3_N() { RoverBoard board = new RoverBoard(5, 5); Rover rover = board.SetRoverOnBoard(new System.Drawing.Point(1, 2), RoverDirectionHelper.GetDirectionByChar('N')); Rover expected = new Rover { Direction = RoverDirection.North, Location = new System.Drawing.Point(1, 2) }; Assert.AreEqual(expected.Direction, rover.Direction); Assert.AreEqual(expected.Location, rover.Location); //LMLMLMLMM expected .Rotate(Rotation.Left) .Move() .Rotate(Rotation.Left) .Move() .Rotate(Rotation.Left) .Move() .Rotate(Rotation.Left) .Move() .Move(); board.ComputeMovements("LMLMLMLMM", rover); Assert.AreEqual("1 3 N", rover.ToString()); Assert.AreEqual(expected.ToString(), rover.ToString()); // 1 3 N }
public void Create_Board_5X5_Set_Rover_1_2_N_MovesOutOfBoard_Expects_ArgumentOutOfRangeException() { RoverBoard board = new RoverBoard(5, 5); Rover rover = board.SetRoverOnBoard(new System.Drawing.Point(1, 2), RoverDirectionHelper.GetDirectionByChar('N')); board.ComputeMovements("MMMMMMMMMM", rover); }
public void Create_Board_5X5_Set_RoverOn_1_2_N_PassRoverNull_Expects_ArgumentNullException() { RoverBoard board = new RoverBoard(5, 5); Rover rover = board.SetRoverOnBoard(new System.Drawing.Point(1, 2), RoverDirectionHelper.GetDirectionByChar('N')); board.ComputeMovements("LM", null); }
public void Create_Board_5X5_Set_RoverOn_1_2_N_PassInvalidLiteralCommand_Expects_ArgumentException() { RoverBoard board = new RoverBoard(5, 5); Rover rover = board.SetRoverOnBoard(new System.Drawing.Point(1, 2), RoverDirectionHelper.GetDirectionByChar('N')); board.ComputeMovements("asdf", rover); }
public void Board5X5_RoverOn_3_3_E_Computes_MMRMMRMRRM_Expects_5_1_E() { RoverBoard board = new RoverBoard(5, 5); Rover rover = board.SetRoverOnBoard(new System.Drawing.Point(3, 3), RoverDirectionHelper.GetDirectionByChar('E')); Rover expected = new Rover { Direction = RoverDirection.East, Location = new System.Drawing.Point(3, 3) }; Assert.AreEqual(expected.Direction, rover.Direction); Assert.AreEqual(expected.Location, rover.Location); //MMRMMRMRRM expected .Move() .Move() .Rotate(Rotation.Right) .Move() .Move() .Rotate(Rotation.Right) .Move() .Rotate(Rotation.Right) .Rotate(Rotation.Right) .Move(); board.ComputeMovements("MMRMMRMRRM", rover); Assert.AreEqual("5 1 E", rover.ToString()); Assert.AreEqual(expected.ToString(), rover.ToString()); // 5 1 E }
public void Create_Board_5X5_Set_Rover_1_2_N_RotateRight_4Times_Expects_The_Same_Heading() { RoverBoard board = new RoverBoard(5, 5); Rover rover = board.SetRoverOnBoard(new System.Drawing.Point(1, 2), RoverDirectionHelper.GetDirectionByChar('N')); rover .Rotate(Rotation.Right) .Rotate(Rotation.Right) .Rotate(Rotation.Right) .Rotate(Rotation.Right); Assert.AreEqual(RoverDirection.North, rover.Direction); board.ComputeMovements("RRRR", rover); Assert.AreEqual(RoverDirection.North, rover.Direction); }