Esempio n. 1
0
        public void GivenAListOfCommands_WhenTheListCalculatesMoreThan5Actions_ThenOnlyTheFirst5AreExecuted()
        {
            var commands = new List <string>()
            {
                "1", "1", "1", "1", "1", "1", "1", "1", "1", "1"
            };
            var calculate = new RoverCoordinateCalculate(commands);

            Assert.Equal(501, calculate.AddressCommands(1, Cardinal.South).Location);
        }
Esempio n. 2
0
        public void GivenAStartingCoordinateOf1_WhenTheRoverIsTurnedLeftAndMovedByOneMeter_ThenTheExpectedCoordinateIs2()
        {
            var commands = new List <string>()
            {
                "Left", "1"
            };

            var calculate = new RoverCoordinateCalculate(commands);

            Assert.Equal(2, calculate.AddressCommands(1, Cardinal.South).Location);
        }
Esempio n. 3
0
        public void GivenAStartingCoordinateOf1_WhenTheCommandIsSetSouthBy2Plus3Meters_ThenTheExpectedCoordinateIs501()
        {
            var commands = new List <string>()
            {
                "2", "3"
            };

            var calculate = new RoverCoordinateCalculate(commands);

            Assert.Equal(501, calculate.AddressCommands(1, Cardinal.South).Location);
        }
Esempio n. 4
0
        public void GivenAStartingCoordinateOf1_WhenTheCommandIZigZag_ThenTheExpectedCoordinateIs501()
        {
            var commands = new List <string>()
            {
                "2", "Left", "3", "Right", "2",
            };

            var calculate = new RoverCoordinateCalculate(commands);

            Assert.Equal(404, calculate.AddressCommands(1, Cardinal.South).Location);
        }
Esempio n. 5
0
        public void GivenARoverSouthFacingStartingPoint_WhenTheRoverIsTurnedLeft_ThenTheRoverFacesEast()
        {
            var commands = new List <string>()
            {
                "Left", "1"
            };

            var calculate = new RoverCoordinateCalculate(commands);

            var(Location, Compass) = calculate.AddressCommands(1, Cardinal.South);
            var rover = new Rover(Location, Compass);

            Assert.Equal(Cardinal.East, rover.CardinalDirection);
        }
Esempio n. 6
0
        public void GivenARoverSouthFacingStartingPoint_WhenTheRoverRoamsTheBoundaryAndBack_ThenTheRoverReturnsTo1m()
        {
            var commands = new List <string>()
            {
                "99", "Left", "Left", "99"
            };

            var calculate = new RoverCoordinateCalculate(commands);

            var(Location, Compass) = calculate.AddressCommands(1, Cardinal.South);
            var rover = new Rover(Location, Compass);

            Assert.Equal(1, rover.Location);
        }
Esempio n. 7
0
        public void GivenARoverSouthFacingStartingPoint_WhenTheRoverIsIncrementallyMoved5m_ThenTheRoverIsAt500m()
        {
            var commands = new List <string>()
            {
                "1", "1", "1", "1", "1"
            };

            var calculate = new RoverCoordinateCalculate(commands);

            var(Location, Compass) = calculate.AddressCommands(1, Cardinal.South);
            var rover = new Rover(Location, Compass);

            Assert.Equal(501, rover.Location);
        }
Esempio n. 8
0
        public void GivenARoverSouthFacingStartingPoint_WhenTheRoverTravels100meters_ThenTheRoverFacesHaltsAt9901m()
        {
            var commands = new List <string>()
            {
                "100"
            };

            var calculate = new RoverCoordinateCalculate(commands);

            var(Location, Compass) = calculate.AddressCommands(1, Cardinal.South);
            var rover = new Rover(Location, Compass);

            Assert.Equal(Cardinal.South, rover.CardinalDirection);
            Assert.Equal(9901, rover.Location);
        }
Esempio n. 9
0
        public void GivenARoverSouthFacingStartingPoint_WhenHasTheAssignmentExample_ThenTheRoverReturns4624m()
        {
            var commands = new List <string>()
            {
                "50", "Left", "23", "Left", "4"
            };

            var calculate = new RoverCoordinateCalculate(commands);

            var(Location, Compass) = calculate.AddressCommands(1, Cardinal.South);
            var rover = new Rover(Location, Compass);

            Assert.Equal(4624, rover.Location);
            Assert.Equal(Cardinal.North, rover.CardinalDirection);
        }
Esempio n. 10
0
        public void GivenARoverSouthFacingStartingPoint_WhenTheRoverTurnsLeftAnd101meters_ThenTheRoverFacesHaltsAt100m()
        {
            var commands = new List <string>()
            {
                "Left", "101"
            };

            var calculate = new RoverCoordinateCalculate(commands);

            var(Location, Compass) = calculate.AddressCommands(1, Cardinal.South);
            var rover = new Rover(Location, Compass);

            Assert.Equal(Cardinal.East, rover.CardinalDirection);
            Assert.Equal(100, rover.Location);
        }
Esempio n. 11
0
        public void Given2ChangesOfDirection_WhenTheRoverTravels101meters_ThenTheRoverFacesHaltsAt9903m()
        {
            var commands = new List <string>()
            {
                "Left", "2", "Right", "101"
            };

            var calculate = new RoverCoordinateCalculate(commands);

            var(Location, Compass) = calculate.AddressCommands(1, Cardinal.South);
            var rover = new Rover(Location, Compass);

            Assert.Equal(Cardinal.South, rover.CardinalDirection);
            Assert.Equal(9903, rover.Location);
        }