public void ReceiveCommand_Forward_FaceWest() { Planet planet = new Planet(); PlutoRover rover = new PlutoRover(new Position(4, 4, Orientation.W)); planet.AddObject(rover); rover.ProcessCommand(PlutoCommand.F); Assert.AreEqual(rover.GetPosition(), new Position(3, 4, Orientation.W)); rover.ProcessCommand(PlutoCommand.B); Assert.AreEqual(rover.GetPosition(), new Position(4, 4, Orientation.W)); }
public void ReceiveCommand_Forward_FaceEast() { Planet planet = new Planet(); PlutoRover rover = new PlutoRover(new Position(4, 4, Orientation.E)); planet.AddObject(rover); rover.ProcessCommand(PlutoCommand.F); Assert.IsTrue(rover.GetPosition() == (new Position(5, 4, Orientation.E))); rover.ProcessCommand(PlutoCommand.B); Assert.IsTrue(rover.GetPosition().Equals(new Position(4, 4, Orientation.E))); }
public void ReceiveCommand_MoveOffGrid_West() { Planet planet = new Planet(10, 10); PlutoRover rover = new PlutoRover(new Position(0, 3, Orientation.W)); planet.AddObject(rover); rover.ProcessCommand(PlutoCommand.F); Assert.AreEqual(rover.GetPosition(), new Position(9, 3, Orientation.W)); }
public void ReceiveCommand_Obstacle_FaceSouth() { Planet planet = new Planet(); Rock rock = new Rock(new Position(4, 3, Orientation.N)); planet.AddObject(rock); PlutoRover rover = new PlutoRover(new Position(4, 4, Orientation.S)); planet.AddObject(rover); rover.ProcessCommand(PlutoCommand.F); Assert.AreEqual(rover.GetPosition(), new Position(4, 4, Orientation.S)); }
public void ReceiveCommand_Obstacle_FaceEast() { Planet planet = new Planet(); Rock rock = new Rock(new Position(5, 4, Orientation.N)); planet.AddObject(rock); PlutoRover rover = new PlutoRover(new Position(4, 4, Orientation.E)); planet.AddObject(rover); rover.ProcessCommand(PlutoCommand.F); Assert.IsTrue(rover.GetPosition() == (new Position(4, 4, Orientation.E))); }
public void ReceiveCommand_MultipleCommands() { Planet planet = new Planet(); PlutoRover rover = new PlutoRover(new Position(4, 4, Orientation.N)); planet.AddObject(rover); var commands = new List <PlutoCommand>() { PlutoCommand.F, PlutoCommand.F, PlutoCommand.R, PlutoCommand.F, PlutoCommand.F }; MovementReport report = rover.ProcessCommands(commands); Assert.AreEqual(rover.GetPosition(), new Position(6, 6, Orientation.E)); Assert.IsTrue(report.Success); }
public void ReceiveCommand_Turning() { Planet planet = new Planet(); PlutoRover rover = new PlutoRover(new Position(4, 4, Orientation.N)); planet.AddObject(rover); rover.ProcessCommand(PlutoCommand.L); Assert.AreEqual(rover.GetPosition(), new Position(4, 4, Orientation.W)); rover.ProcessCommand(PlutoCommand.L); Assert.AreEqual(rover.GetPosition(), new Position(4, 4, Orientation.S)); rover.ProcessCommand(PlutoCommand.L); Assert.AreEqual(rover.GetPosition(), new Position(4, 4, Orientation.E)); rover.ProcessCommand(PlutoCommand.L); Assert.AreEqual(rover.GetPosition(), new Position(4, 4, Orientation.N)); rover.ProcessCommand(PlutoCommand.R); Assert.AreEqual(rover.GetPosition(), new Position(4, 4, Orientation.E)); rover.ProcessCommand(PlutoCommand.R); Assert.AreEqual(rover.GetPosition(), new Position(4, 4, Orientation.S)); rover.ProcessCommand(PlutoCommand.R); Assert.AreEqual(rover.GetPosition(), new Position(4, 4, Orientation.W)); rover.ProcessCommand(PlutoCommand.R); Assert.AreEqual(rover.GetPosition(), new Position(4, 4, Orientation.N)); }
public void ReceiveCommand_MultipleCommandsAndObstruction() { Planet planet = new Planet(); Rock rock = new Rock(new Position(6, 6, Orientation.N)); planet.AddObject(rock); PlutoRover rover = new PlutoRover(new Position(4, 4, Orientation.N)); planet.AddObject(rover); var commands = new List <PlutoCommand>() { PlutoCommand.F, PlutoCommand.F, PlutoCommand.R, PlutoCommand.F, PlutoCommand.F }; MovementReport report = rover.ProcessCommands(commands); Assert.AreEqual(rover.GetPosition(), new Position(5, 6, Orientation.E)); Assert.IsFalse(report.Success); Assert.IsTrue(object.ReferenceEquals(rock, report.Obstructions[0])); }