public void TestConvertResult() { RoverLogic logic = new RoverLogic(); int[] coordinates = { 1, 3, 0 }; var testResult = logic.ConvertToResult(coordinates); string expected = "1 3 N"; Assert.AreEqual(expected, testResult); }
public void Given_MovementCommandThatGoesOutOfBounds_ShouldReturnFalse() { var listOfInstructions = new List <string> { "8 8", "8 8 N", "M", }; var roverLogic = new RoverLogic(listOfInstructions); var result = roverLogic.Execute(); Assert.That(result, Is.EqualTo("Rover moved out of grid at point 8 8 \n End position 8 9 N")); }
public void Given_PositionOutOfGrid_ShouldReturnStatementAndExitLocation(string grid, string position, string movements, bool expected) { var listOfInstructions = new List <string> { grid, position, movements, }; var roverLogic = new RoverLogic(listOfInstructions); var result = roverLogic.IsInBounds(); Assert.That(result, Is.EqualTo(expected)); }
public void GoldenTest() { var listOfInstructions = new List <string> { "8 8", "1 2 E", "MMLMRMMRRMML", }; var roverLogic = new RoverLogic(listOfInstructions); var result = roverLogic.Execute(); Assert.That(result, Is.EqualTo("3 3 S")); }
public void TestCreateBorder() { RoverLogic logic = new RoverLogic(); string input = "5 5"; int[] testResult = logic.CreateBorder(input); int[] expected = { 5, 5 }; Assert.AreEqual(expected.Length, testResult.Length); for (var i = 0; i < expected.Length; i++) { Assert.AreEqual(expected[i], testResult[i]); } }
public void TestConvertToCoordinates() { RoverLogic logic = new RoverLogic(); string input = "1 2 N"; int[] testResult = logic.ConvertToCoordinates(input); int[] expected = { 1, 2, 0 }; Assert.AreEqual(expected.Length, testResult.Length); for (var i = 0; i < expected.Length; i++) { Assert.AreEqual(expected[i], testResult[i]); } }
public void Given_UnknownInstuction_ShouldReturnUnknownInstructions() { var listOfInstructions = new List <string> { "8 8", "1 2 E", "MMLMFMMRRMML", }; var roverLogic = new RoverLogic(listOfInstructions); var result = roverLogic.Execute(); Assert.That(roverLogic.UnknownInstructions.Count, Is.EqualTo(1)); Assert.That(roverLogic.UnknownInstructions[0], Is.EqualTo("F")); }
public void TestIsLimit() { RoverLogic logic = new RoverLogic(); int[] coordinates = { 1, 5, 0 }; int[] border = { 5, 5 }; int[] testResult = logic.IsLimit(coordinates, border); int[] expected = { 0, 0, 0, 1 }; Assert.AreEqual(expected.Length, testResult.Length); for (var i = 0; i < expected.Length; i++) { Assert.AreEqual(expected[i], testResult[i]); } }
public void Given_MovementCommand_ShouldExecuteCorrectly() { var listOfInstructions = new List <string> { "8 8", "1 2 E", "MMLMRMMRRMML", }; var roverLogic = new RoverLogic(listOfInstructions); roverLogic.ExecuteMovementCommand("M"); Assert.That(roverLogic.X, Is.EqualTo(2)); Assert.That(roverLogic.Y, Is.EqualTo(2)); Assert.That(roverLogic.D, Is.EqualTo("E")); }
public void TestGetRoute() { RoverLogic logic = new RoverLogic(); int[] coordinates = { 1, 2, 0 }; string directions = "LMLMLMLMM"; int[] borders = { 5, 5 }; var testResult = logic.GetRoute(coordinates, directions, borders); int[] expected = { 1, 3, 0 }; Assert.AreEqual(expected.Length, testResult.Length); for (var i = 0; i < expected.Length; i++) { Assert.AreEqual(expected[i], testResult[i]); } }
public void Given_ListOfInstructions_Should_BuildRoverLogicBaseCorrectly() { var listOfInstructions = new List <string> { "8 8", "1 2 E", "MMLMRMMRRMML", }; var roverLogic = new RoverLogic(listOfInstructions); Assert.That(roverLogic.XMax, Is.EqualTo(8)); Assert.That(roverLogic.YMax, Is.EqualTo(8)); Assert.That(roverLogic.X, Is.EqualTo(1)); Assert.That(roverLogic.Y, Is.EqualTo(2)); Assert.That(roverLogic.D, Is.EqualTo("E")); Assert.That(roverLogic.Instructions.Count, Is.EqualTo(12)); }