Esempio n. 1
0
        public void ParseCoordinate_WhenPassedValidString_ShouldParse()
        {
            var coord    = "1 4 N";
            var expected = new Coordinate(1, 4);
            var actual   = RoverController.ParseCoordinate(coord);

            Assert.AreEqual(expected, actual);
        }
Esempio n. 2
0
        public Rover(string position, Plateau plateau)
        {
            Coordinate = RoverController.ParseCoordinate(position);
            if (Coordinate.X > plateau.TopRight.X ||
                Coordinate.Y > plateau.TopRight.Y ||
                Coordinate.Y < 0 ||
                Coordinate.X < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(position), "Rover out of range of the plateau graph.");
            }

            Orientation = RoverController.ParseOrientation(position);
        }
Esempio n. 3
0
        public static void Main(string[] args)
        {
            Console.Write("Enter Graph Upper Right Coordinate: ");
            var coordinate = Console.ReadLine();

            var plateau = new Plateau(RoverController.ParseCoordinate(coordinate));

            for (var roverCount = 1; roverCount < 3; roverCount++)
            {
                Console.Write($"Rover {roverCount} Starting Position: ");
                var startPosition = Console.ReadLine();

                var rover = new Rover(startPosition, plateau);

                Console.Write($"Rover {roverCount} Movement Plan: ");
                var movementPlan = Console.ReadLine();

                rover = RoverController.ExecuteMovementPlan(movementPlan, rover, plateau);

                Console.WriteLine($"Rover {roverCount} Output: {rover}");
            }

            Quit();
        }
Esempio n. 4
0
        public void ParseCoordinate_WhenPassedInvalidString_ShouldThrow()
        {
            var coord = "1 2 3 4";

            Assert.ThrowsException <ArgumentException>(() => RoverController.ParseCoordinate(coord));
        }
Esempio n. 5
0
 public void ParseCoordinate_WhenPassedEmptyString_ShouldThrow()
 {
     Assert.ThrowsException <ArgumentException>(() => RoverController.ParseCoordinate(""));
 }