Ejemplo n.º 1
0
        public void Moving_Out_Of_Range_Throws_Exception(string instruction)
        {
            //Arrange
            var dron = new Dron(0, 0, 'S', _forest);

            //Act & Assert
            Assert.Throws <GameException>(() => dron.ExecuteInstructions(instruction));
        }
Ejemplo n.º 2
0
        public void Moving_East_As_Expected()
        {
            //Arrange
            var dron = new Dron(1, 1, 'E', _forest);

            //Act
            dron.ExecuteInstructions("M");

            //Assert
            Assert.Equal <int>(2, dron.X);
        }
Ejemplo n.º 3
0
        public void Moving_South_As_Expected()
        {
            //Arrange
            var dron = new Dron(0, 1, 'S', _forest);

            //Act
            dron.ExecuteInstructions("M");

            //Assert
            Assert.Equal <int>(0, dron.Y);
        }
Ejemplo n.º 4
0
        private void ExecuteInstruction(string instruction)
        {
            string[] splitedInstruction = instruction.Split(' ');

            switch (splitedInstruction.Length)
            {
            case (int)InstructionEnum.MoveDronInstruction:
                _dron.ExecuteInstructions(instruction);
                break;

            case (int)InstructionEnum.SetDronPositionInstruction:
                SetDronInitialPosition(splitedInstruction);
                break;

            case (int)InstructionEnum.SetForestDimensionInstruction:
                SetForestDimensions(splitedInstruction);
                break;

            default:
                throw new GameException("Invalid Instruction");
            }
        }