コード例 #1
0
ファイル: RobotTests.cs プロジェクト: yurik256/RobotCleaner
        public void ExecutionOutput_PathWithoutRepeatingCells_ReturnsCorrectValue()
        {
            var position = new Location(10, 22);
            var expectedOutput = "=> Cleaned: 2";
            IList<MovementInstruction> instructions = new List<MovementInstruction>();
            instructions.Add(new MovementInstruction(Direction.East, 1));

            var cleaningProgram = new CleaningProgram(position, instructions);
            var robot = new Robot(cleaningProgram);

            robot.Clean();
            var output = robot.ExecutionOutput();

            Assert.AreEqual(expectedOutput, output);
        }
コード例 #2
0
ファイル: RobotTests.cs プロジェクト: yurik256/RobotCleaner
        public void ExecutionOutput_NoInstructionsProvided_ReturnsCorrectValue()
        {
            var position = new Location(10, 22);
            var expectedOutput = "=> Cleaned: 1";
            IList<MovementInstruction> instructions = new List<MovementInstruction>();

            var cleaningProgram = new CleaningProgram(position, instructions);
            var robot = new Robot(cleaningProgram);

            robot.Clean();

            var output = robot.ExecutionOutput();

            Assert.AreEqual(expectedOutput, output);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: yurik256/RobotCleaner
        static void Main(string[] args)
        {
            InstructionsReader reader = new InstructionsReader();

            var totalInstructions = reader.ReadTotalInstructions(Console.ReadLine());

            reader.ReadInitialPosition(Console.ReadLine());

            for (var i = 0; i < totalInstructions; i++)
            {
                reader.ReadMoveInstruction(Console.ReadLine());
            }

            var cleaningProgram = reader.BuildCleaningProgram();

            Robot robot = new Robot(cleaningProgram);

            robot.Clean();

            Console.WriteLine(robot.ExecutionOutput());
        }