public void Should_Be_Blocked_By_Obstacle() { bool[,] map = create_map(1,0); Rover rover = new Rover(0, 0, Direction.North); Assert.False(rover.Move(Command.f, map).IsOperationSucceeded()); Assert.AreEqual(new int[] { 0, 0 }, rover.GetLocation()); Assert.True(rover.Move(Command.r, map).IsOperationSucceeded()); Assert.True(rover.Move(Command.f, map).IsOperationSucceeded()); Assert.AreEqual(new int[] { 0, 1 }, rover.GetLocation()); }
public void Should_Move_One_Step_Further() { bool[,] map = create_map(); Rover rover = new Rover(0, 0, Direction.North); //move forward Assert.True(rover.Move(Command.f,map).IsOperationSucceeded()); Assert.AreEqual(new int[] { 1, 0 }, rover.GetLocation()); //move backward Assert.True(rover.Move(Command.b, map).IsOperationSucceeded()); Assert.AreEqual(new int[] { 0, 0 }, rover.GetLocation()); }
public void Should_Reset_Rover() { Rover rover = new Rover(5, 10, Direction.South); rover.Reset(); Assert.AreEqual(new int[] { 0, 0 }, rover.GetLocation()); Assert.AreEqual(Direction.North, rover.GetDirection()); }
public void Should_Not_Be_Blocked_On_The_Edge() { bool[,] map = create_map(); Rover rover = new Rover(0, 0, Direction.North); Assert.True(rover.Move(Command.b, map).IsOperationSucceeded()); Assert.AreEqual(new int[] { 99, 0 }, rover.GetLocation()); rover = new Rover(0, 0, Direction.West); Assert.True(rover.Move(Command.f, map).IsOperationSucceeded()); Assert.AreEqual(new int[] { 0, 99 }, rover.GetLocation()); rover = new Rover(99, 99, Direction.North); Assert.True(rover.Move(Command.f, map).IsOperationSucceeded()); Assert.AreEqual(new int[] { 0, 99 }, rover.GetLocation()); rover = new Rover(99, 99, Direction.East); Assert.True(rover.Move(Command.f, map).IsOperationSucceeded()); Assert.AreEqual(new int[] { 99, 0 }, rover.GetLocation()); }
static void PrintCurrentLocation(Rover rover) { Location location = rover.GetLocation(); Console.WriteLine("The rover has moved to " + location.position.xPosition + " " + location.position.yPosition + " " + location.direction.PrintID() + " "); }
public void Should_Return_Correct_Location() { Rover rover = new Rover(0, 0, Direction.North); Assert.AreEqual(new int[] { 0, 0 }, rover.GetLocation()); }