public static void GivenExampleIntput_RetursCorrectOutput()
        {
            var inputData = new InputDataBuffer();

            inputData.SetSizeOfArena("5 5");
            inputData.AddInitialPositionAndOrientation("1 2 N");
            inputData.AddCommandStream("LMLMLMLMM");
            inputData.AddInitialPositionAndOrientation("3 3 E");
            inputData.AddCommandStream("MMRMMRMRRM");

            int nrOfRobots = inputData.NrOfRobots;

            var mineRovers = new MineRovers(nrOfRobots);

            var inputConsumer = new ConsumeInputPhaseExecutor(inputData, mineRovers);

            inputConsumer.Run();

            for (int robotIndex = 0; robotIndex < nrOfRobots; robotIndex++)
            {
                var robotActionExecutor = new RobotActionExecutor(mineRovers.Robots[robotIndex],
                                                                  mineRovers.CommandStreams[robotIndex],
                                                                  mineRovers.arena);
                robotActionExecutor.ExecuteAllActions();
            }

            string[] resultOutputs = new string[2];
            for (int robotIndex = 0; robotIndex < nrOfRobots; robotIndex++)
            {
                int[] finalPosition    = mineRovers.Robots[robotIndex].GetPosition();
                char  finalOrientation = mineRovers.Robots[robotIndex].GetOrientationAsChar();
                resultOutputs[robotIndex] = finalPosition[0] + " " + finalPosition[1] + " " + finalOrientation;
            }
            string[] expectedOutputs = { "1 3 N", "5 1 E" };
            for (int i = 0; i < nrOfRobots; i++)
            {
                Assert.Equal(expectedOutputs[i], resultOutputs[i]);
            }
        }
Example #2
0
        public void GetNrOfRobots()
        {
            var inputDataBuffer = new InputDataBuffer();

            string[] initialPositions = { "1 5 E", "2 5 W", "5 1 N", "10 20 S" };
            for (int i = 0; i < initialPositions.Length; i++)
            {
                inputDataBuffer.AddInitialPositionAndOrientation(initialPositions[i]);
            }

            int expectedNrOfRobots = initialPositions.Length;

            Assert.Equal(expectedNrOfRobots, inputDataBuffer.NrOfRobots);
        }
Example #3
0
        public void InitialPositionAndOrientationAdderAndGetter_MultipleAdds()
        {
            var inputDataBuffer = new InputDataBuffer();

            string[] initPositionAndOrientation = { "3 0 N", "2 1 E", "5 5 W", "10 2 S", "0 0 E" };
            for (int i = 0; i < initPositionAndOrientation.Length; i++)
            {
                inputDataBuffer.AddInitialPositionAndOrientation(initPositionAndOrientation[i]);
            }
            for (int i = 0; i < initPositionAndOrientation.Length; i++)
            {
                Assert.Equal(initPositionAndOrientation[i], inputDataBuffer.GetInitialPositionAndOrientation(i));
            }
        }