public void CommandsIgnoredIfRobotNotPlacedOnMap() { var driver = new RobotDriver(robot.Object); robot.Setup(r => r.Place(-1, -1, "NORTH")).Throws <ArgumentOutOfRangeException>(); driver.AddCommand("PLACE -1,-1,NORTH"); driver.AddCommand("MOVE"); driver.AddCommand("REPORT"); driver.AddCommand("LEFT"); driver.AddCommand("RIGHT"); driver.AddCommand("PLACE 1,1,NORTH"); driver.AddCommand("MOVE"); driver.AddCommand("REPORT"); driver.AddCommand("LEFT"); driver.AddCommand("RIGHT"); driver.Drive(); robot.Verify(r => r.Move(), Times.Once); robot.Verify(r => r.Report(), Times.Once); robot.Verify(r => r.Left(), Times.Once); robot.Verify(r => r.Right(), Times.Once); robot.Verify(r => r.Place(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>()), Times.Exactly(2)); }
public void CanIssuePlaceCommandToRobot() { var driver = new RobotDriver(robot.Object); robot.Setup(r => r.Place(0, 0, "NORTH")); driver.AddCommand("PLACE 0,0,NORTH"); driver.Drive(); robot.Verify(r => r.Place(0, 0, "NORTH"), Times.Once); }
public void CanIssueLeftCommandToRobot() { var driver = new RobotDriver(robot.Object); robot.Setup(r => r.Left()); driver.AddCommand("PLACE 0,0,NORTH"); driver.AddCommand("LEFT"); driver.Drive(); robot.Verify(r => r.Left(), Times.Once); }
public void CanGetReportsFromDriver() { var driver = new RobotDriver(robot.Object); string report = "0,0,NORTH"; robot.Setup(r => r.Report()).Returns(report); driver.AddCommand($"PLACE {report}"); driver.AddCommand("REPORT"); driver.Drive(); Assert.Equal(driver.Reports.First(), report); }
public void NoCommandsIssuedUntilRobotPlaced() { var driver = new RobotDriver(robot.Object); driver.AddCommand("MOVE"); driver.AddCommand("REPORT"); driver.AddCommand("LEFT"); driver.AddCommand("RIGHT"); driver.AddCommand("PLACE 0,0,NORTH"); driver.Drive(); robot.Verify(r => r.Move(), Times.Never); robot.Verify(r => r.Report(), Times.Never); robot.Verify(r => r.Left(), Times.Never); robot.Verify(r => r.Right(), Times.Never); robot.Verify(r => r.Place(0, 0, "NORTH"), Times.Once); }