コード例 #1
0
        public void ReadInitialPosition_ReturnsCleaningProgramWithCorrectPosition()
        {
            Location expectedPosition = new Location(20, 10);
            InstructionsReader reader = new InstructionsReader();
            reader.ReadInitialPosition("20 10");

            var cleaningProgram = reader.BuildCleaningProgram();

            Assert.AreEqual(cleaningProgram.InitialPosition, expectedPosition);
        }
コード例 #2
0
        public void ReadMoveInstruction_South20Steps_ReturnsCleaningProgramWithCorrectMoveInstructions()
        {
            const Direction expectedInstructionDirection = Direction.South;
            const int expectedInstructionSteps = 20;
            const int expectedMoveInstructions = 1;
            InstructionsReader reader = new InstructionsReader();
            reader.ReadMoveInstruction("S 20");

            var cleaningProgram = reader.BuildCleaningProgram();

            Assert.AreEqual(expectedMoveInstructions, cleaningProgram.MoveInstructions.Count);
            Assert.AreEqual(expectedInstructionDirection, cleaningProgram.MoveInstructions[0].Direction);
            Assert.AreEqual(expectedInstructionSteps, cleaningProgram.MoveInstructions[0].Steps);
        }
コード例 #3
0
        public void ReadCleaningInstructions_BuildsCorrectCleaningProgram()
        {
            const Direction expectedInstructionDirection = Direction.North;
            const int expectedInstructionSteps = 99999;
            const int expectedMoveInstructions = 1;
            Location expectedInitialPosition = new Location(10, 20);
            InstructionsReader reader = new InstructionsReader();
            reader.ReadInitialPosition("10 20");
            reader.ReadMoveInstruction("N 99999");

            var cleaningProgram = reader.BuildCleaningProgram();

            Assert.AreEqual(expectedInitialPosition, cleaningProgram.InitialPosition);
            Assert.AreEqual(expectedMoveInstructions, cleaningProgram.MoveInstructions.Count);
            Assert.AreEqual(expectedInstructionDirection, cleaningProgram.MoveInstructions[0].Direction);
            Assert.AreEqual(expectedInstructionSteps, cleaningProgram.MoveInstructions[0].Steps);
        }
コード例 #4
0
        public void ReadMultipleMoveInstructions_ReturnsCleaningProgramWithCorrectMoveInstructions()
        {
            const int expectedMoveInstructions = 2;

            const Direction expectedFirstInstructionDirection = Direction.North;
            const int expectedFirstInstructionSteps = 20;

            const Direction expectedSecondInstructionDirection = Direction.South;
            const int expectedSecondInstructionSteps = 10;

            InstructionsReader reader = new InstructionsReader();
            reader.ReadMoveInstruction("N 20");
            reader.ReadMoveInstruction("S 10");

            var cleaningProgram = reader.BuildCleaningProgram();

            Assert.AreEqual(expectedMoveInstructions, cleaningProgram.MoveInstructions.Count);
            Assert.AreEqual(expectedFirstInstructionDirection, cleaningProgram.MoveInstructions[0].Direction);
            Assert.AreEqual(expectedFirstInstructionSteps, cleaningProgram.MoveInstructions[0].Steps);
            Assert.AreEqual(expectedSecondInstructionDirection, cleaningProgram.MoveInstructions[1].Direction);
            Assert.AreEqual(expectedSecondInstructionSteps, cleaningProgram.MoveInstructions[1].Steps);
        }