Ejemplo n.º 1
0
        public void TestRoverTurnLeft()
        {
            var boundaries = new Plateau {
                XAxisMin = 0, XAxisMax = 5, YAxisMin = 0, YAxisMax = 5
            };


            var values    = Enum.GetValues(typeof(CompassDirection));
            var random    = new Random();
            var randomDir = (CompassDirection)values.GetValue(random.Next(values.Length));

            var rover = new Rover();

            rover.SetRoverBoundaries(boundaries);
            var location = new Location()
            {
                xAxis = 1, yAxis = 1, Direction = randomDir
            };
            var onSet = rover.InitialLocationSet(location);

            if (onSet)
            {
                var    stringRoute        = "L";
                char[] stringRouteCharArr = stringRoute.ToCharArray();

                rover.SetRoute(stringRouteCharArr);
                rover.Navigate();
                var currentLocation = rover.CurrentLocation;

                var expectedResult = DirectionHelper.GetLeftCompassDirection(randomDir).GetDescription();
                Assert.AreEqual(expectedResult, currentLocation.Direction.GetDescription());
            }
            else
            {
                Assert.Fail();
            }
        }