public void UpdatePosition_MoveToPositionWithSpinner() { var grid = Program.InitializeGrid(5, 5); var spinner = new Spinner(270, new [] { 1, 0 }, grid); grid[grid.FirstOrDefault(g => g.Key.SequenceEqual(spinner.Position)).Key] = spinner; var robot = new Robot(); robot = robot.UpdatePosition(spinner.Position, grid); Assert.IsTrue(robot.Position.SequenceEqual(new[] { 1, 0 })); Assert.AreEqual(3, robot.Direction); }
public void UpdatePosition_MoveToPositionWithRock() { var grid = Program.InitializeGrid(5, 5); var rock = new Rock(new [] { 0, 0 }, grid); grid[grid.FirstOrDefault(g => g.Key.SequenceEqual(rock.Position)).Key] = rock; var robot = new Robot(); robot = robot.UpdatePosition(rock.Position, grid); Assert.IsTrue(robot.Position.SequenceEqual(new[] { 0, 0 })); }
public void UpdatePosition_MoveToEmptyPosition() { var grid = Program.InitializeGrid(5, 5); var robot = new Robot(); robot = robot.UpdatePosition(new[] {1, 0}, grid); Assert.IsTrue(robot.Position.SequenceEqual(new[] {1, 0})); }
public void UpdatePosition_MoveToPositionWithHole() { var grid = Program.InitializeGrid(5, 5); var hole = new Hole(new[] {3, 3}, new[] {1, 0}, grid); grid[grid.FirstOrDefault(g => g.Key.SequenceEqual(hole.Position)).Key] = hole; var robot = new Robot(); robot = robot.UpdatePosition(hole.Position, grid); Assert.IsTrue(robot.Position.SequenceEqual(new[] { 3, 3 })); }
public void UpdatePosition_MoveOutOfBounds() { var grid = Program.InitializeGrid(5, 5); var robot = new Robot(); robot = robot.UpdatePosition(new[] { -1, -1 }, grid); Assert.IsTrue(robot.Position.SequenceEqual(new[] { 0, 0 })); }