public void Rover_PositionOutOfBoundsY_ShouldThrowArgumentOutOfRangeException() { var upperRightCoordinates = "12 12"; var position = "10 13 N"; var rover = new RoverController { UpperRightCoordinates = upperRightCoordinates }; Assert.ThrowsException <System.ArgumentOutOfRangeException>(() => rover.Deploy(position)); }
public void Rover_PositionWithInvalidSyntaxO_ShouldThrowFormatException() { var upperRightCoordinates = "10 10"; var position = "5 5 10"; var rover = new RoverController { UpperRightCoordinates = upperRightCoordinates }; Assert.ThrowsException <System.FormatException>(() => rover.Deploy(position)); }
public void DeploySingleRover_PositionWithExtraArgument_ShouldThrowArgumentException() { var upperRightCoordinates = "10 10"; var position = "5 10 6 N"; var rover = new RoverController { UpperRightCoordinates = upperRightCoordinates }; Assert.ThrowsException <System.ArgumentException>(() => rover.Deploy(position)); }
public void Rover_WithEmptyInstructionParameter_ShouldThrowArgumentNullException() { var upperRightCoordinates = "12 12"; var position = "5 5 N"; var instruction = string.Empty; var rover = new RoverController { UpperRightCoordinates = upperRightCoordinates }; rover.Deploy(position); Assert.ThrowsException <System.ArgumentNullException>(() => rover.ListOfRovers[0].Explore(instruction)); }
public void Rover_WithMultipleInstructionsContainingInvalidInstruction_ShouldThrowFormatException() { var upperRightCoordinates = "12 12"; var position = "5 5 N"; var instruction = "LMLMRTRMLLM"; var rover = new RoverController { UpperRightCoordinates = upperRightCoordinates }; rover.Deploy(position); Assert.ThrowsException <System.FormatException>(() => rover.ListOfRovers[0].Explore(instruction)); }
public void Rover_LeftInstruction_SetsRoverOrientation() { var upperRightCoordinates = "12 12"; var position = "5 1 N"; var expected = "5 1 W"; var instruction = "L"; var rover = new RoverController { UpperRightCoordinates = upperRightCoordinates }; rover.Deploy(position); rover.ListOfRovers[0].Explore(instruction); var actual = rover.ListOfRovers[0].Position; Assert.AreEqual(expected, actual, "L instruction not executed correctly."); }
public void DeployMultipleRovers_WithValidPositions_DeploysMultipleRovers() { var upperRightCoordinates = "10 10"; var numberOfRovers = 3; var expectedNumberOfRovers = 3; var rover = new RoverController(); string[] positions = new string[] { "5 1 N", "5 10 E", "10 0 W" }; rover.UpperRightCoordinates = upperRightCoordinates; for (int i = 0; i < numberOfRovers; i++) { rover.Deploy(positions[i]); } var actualNumberOfRovers = rover.ListOfRovers.Count; Assert.AreEqual(expectedNumberOfRovers, actualNumberOfRovers, "The set value is not equal to the get value"); }
public void Rover_MoveRightInstructionOnRightBound_NoChangeInCoordinates() { var upperRightCoordinates = "12 12"; var position = "12 1 N"; var expected = "12 1 E"; var instruction = "RM"; var rover = new RoverController { UpperRightCoordinates = upperRightCoordinates }; rover.Deploy(position); rover.ListOfRovers[0].Explore(instruction); var actual = rover.ListOfRovers[0].Position; rover.ListOfRovers[0].Explore(instruction); Assert.AreEqual(expected, actual, "RM instruction not executed correctly."); }
public void DeploySingleRover_WithValidPosition_DeploysSingleRover() { var upperRightCoordinates = "10 10"; var position = "5 1 N"; var expectedPosition = "5 1 N"; var expectedNumberOfRovers = 1; var numberOfRovers = 1; var rover = new RoverController(); rover.UpperRightCoordinates = upperRightCoordinates; rover.NumberOfRovers = numberOfRovers; for (int i = 0; i < numberOfRovers; i++) { rover.Deploy(position); } var actualPosition = rover.ListOfRovers[0].Position; var actualNumberOfRovers = rover.ListOfRovers.Count; Assert.AreEqual(expectedPosition, actualPosition, "The set value is not equal to the get value"); Assert.AreEqual(expectedNumberOfRovers, actualNumberOfRovers, "The set value is not equal to the get value"); }