public void TestRobotSetPositionValid() { Robot robot = new Robot(5); robot.SetPosition(3, 4); robot.SetPosition(1, 2); Assert.AreEqual(1, robot.xPos); Assert.AreEqual(2, robot.yPos); }
public void TestRobotSetPositionInvalidY() { Robot robot = new Robot(5); robot.SetPosition(3, 2); // Valid robot.SetPosition(1, 16); // Invalid // Position not changed by invalid Assert.AreEqual(3, robot.xPos); Assert.AreEqual(2, robot.yPos); }
public void TestRobotSetPositionValidUpper() { Robot robot = new Robot(4); robot.SetPosition(4, 4); Assert.AreEqual(4, robot.xPos); Assert.AreEqual(4, robot.yPos); }
public void TestRobotSetPositionValidLower() { Robot robot = new Robot(5); robot.SetPosition(0, 0); Assert.AreEqual(0, robot.xPos); Assert.AreEqual(0, robot.yPos); }
public void TestCommandMoveCanExecuteInvalidBearing() { Robot robot = new Robot(2); robot.SetPosition(1, 2); var command = new MoveCommand(); Assert.IsFalse(command.CanExecute(robot)); }
public void TestRobotSetPositionInvalidX() { Robot robot = new Robot(5); robot.SetPosition(-3, 2); // Position not changed by invalid Assert.IsNull(robot.xPos); Assert.IsNull(robot.yPos); }
public void TestCommandMoveCanExecuteValid() { Robot robot = new Robot(2); robot.SetPosition(1, 1); robot.SetBearing("NORTH"); var command = new MoveCommand(); Assert.IsTrue(command.CanExecute(robot)); }
public void TestRobotMoveForwardNoBearing() { Robot robot = new Robot(5); robot.SetPosition(1, 2); robot.MoveForward(); Assert.AreEqual(1, robot.xPos); Assert.AreEqual(2, robot.yPos); Assert.IsNull(robot.bearing); }
public void TestRobotMoveForwardLowerY() { Robot robot = new Robot(3); robot.SetPosition(0, 0); robot.SetBearing("SOUTH"); robot.MoveForward(); Assert.AreEqual(0, robot.xPos); Assert.AreEqual(0, robot.yPos); Assert.AreEqual("SOUTH", robot.bearing); }
public void TestRobotMoveForwardUpperY() { Robot robot = new Robot(3); robot.SetPosition(3, 3); robot.SetBearing("NORTH"); robot.MoveForward(); Assert.AreEqual(3, robot.xPos); Assert.AreEqual(3, robot.yPos); Assert.AreEqual("NORTH", robot.bearing); }
public void TestRobotMoveForwardValid() { Robot robot = new Robot(5); robot.SetPosition(1, 2); robot.SetBearing("NORTH"); robot.MoveForward(); Assert.AreEqual(1, robot.xPos); Assert.AreEqual(3, robot.yPos); Assert.AreEqual("NORTH", robot.bearing); }
public void TestCommandMoveExecuteValid() { Robot robot = new Robot(2); robot.SetPosition(1, 1); robot.SetBearing("NORTH"); var command = new MoveCommand(); command.Execute(robot, ""); Assert.AreEqual(1, robot.xPos); Assert.AreEqual(2, robot.yPos); Assert.AreEqual("NORTH", robot.bearing); }
public void TestCommandTurnExecuteAntiClockwise() { Robot robot = new Robot(2); robot.SetPosition(1, 1); robot.SetBearing("NORTH"); var command = new TurnCommand(false); command.Execute(robot, ""); Assert.AreEqual(1, robot.xPos); Assert.AreEqual(1, robot.yPos); Assert.AreEqual("WEST", robot.bearing); }
public void TestCommandReportExecuteValidRobot() { Robot robot = new Robot(2); robot.SetPosition(1, 2); robot.SetBearing("SOUTH"); StringBuilder sb = new StringBuilder(); StringWriter writer = new StringWriter(sb); var command = new ReportCommand(writer); command.Execute(robot, ""); Assert.AreEqual("1,2,SOUTH\r\n", sb.ToString()); }