public Robot(int x, int y, Orientation orientation, Mars mars) { X = x; Y = y; Orientation = orientation; _mars = mars; }
private static Robot ParseRobot(String robot, Mars mars) { string[] inputs = robot.Split(' '); var x = int.Parse(inputs[0]); var y = int.Parse(inputs[1]); var orientation = GetOrientation(inputs[2]); return(new Robot(x, y, orientation, mars)); }
public void DirectionalMovement(Orientation orientation, int x, int y) { //arrange var mars = new Mars(5, 3); var robot = new Robot(1, 1, orientation, mars); //act robot.ExecuteCommand(Command.forward); //assert Assert.AreEqual(x, robot.X); Assert.AreEqual(y, robot.Y); }
public void Boundaries(Orientation orientation, int timesForward, bool shouldBeLost) { //arrange var mars = new Mars(5, 3); var robot = new Robot(1, 1, orientation, mars); //act for(int i=0; i<timesForward; i++) robot.ExecuteCommand(Command.forward); //assert Assert.AreEqual(shouldBeLost, robot.IsLost); }
public void ReportLastPositionIfFallenOff() { //arrange var mars = new Mars(5, 3); var lostRobot = new Robot(5, 3, Orientation.north, mars); //act lostRobot.ExecuteCommand(Command.forward); lostRobot.ExecuteCommand(Command.forward); //assert //lost robot's position should be the last one if had before falling off Assert.AreEqual(5, lostRobot.X); Assert.AreEqual(3, lostRobot.Y); }
public void Reorientation(Command command, int timesRotate, Orientation orientation) { //arrange var mars = new Mars(5, 3); var robot = new Robot(0, 0, Orientation.north, mars); //act for(int i=0; i<timesRotate; i++) robot.ExecuteCommand(command); //assert Assert.AreEqual(orientation, robot.Orientation); Assert.AreEqual(0, robot.X); Assert.AreEqual(0, robot.Y); }
public void GetMarsRobotsAndCommandSequences() { //arrange var input = @"50 30 13 12 N FRRFLLFFRRFLL "; var mars = new Mars(50, 30); var expectedRobots = new List<Robot>() { new Robot(13, 12, Orientation.north, mars) }; var expectedCommandSequences = new List<List<Command>> { new Mocks().GetCommandSequence() }; //act List<Robot> actualRobots; List<List<Command>> actualCommandSequences; Input.GetRobotsAndCommandSequences(input, out actualRobots, out actualCommandSequences); //assert Assert.That(actualRobots, IsDeeplyEqual.To(expectedRobots)); Assert.That(actualCommandSequences, IsDeeplyEqual.To(expectedCommandSequences)); }
public void SniffForScentsBeforeFallingOff() { //arrange var mars = new Mars(5, 3); var lostRobot = new Robot(5, 3, Orientation.north, mars); var savedRobot = new Robot(5, 3, Orientation.north, mars); //act lostRobot.ExecuteCommand(Command.forward); savedRobot.ExecuteCommand(Command.forward); //assert Assert.AreEqual(true, lostRobot.IsLost); Assert.AreEqual(false, savedRobot.IsLost); }
private static Robot ParseRobot(String robot, Mars mars) { //1 1 E //33 44 E string[] inputs = robot.Split(' '); var x = int.Parse(inputs[0]); var y = int.Parse(inputs[1]); var orientation = GetOrientation(inputs[2]); return new Robot(x, y, orientation, mars); }