Ejemplo n.º 1
0
        public void SLMM_StaysIn_Boundaries(int test)
        {
            commandList = new List <Command>();
            if (test == 0)
            {
                commandList.Add(Command.TurnLeft);  // face east
            }
            else
            {
                commandList.Add(Command.TurnLeft);
                commandList.Add(Command.TurnLeft);  // face south
            }
            commandList.Add(Command.Move);
            commandList.Add(Command.Stop);

            foreach (var command in commandList)
            {
                _slmm.PushCommand(command);
            }

            _slmm.Start();

            var position = _slmm.GetPosition;

            Assert.AreEqual(position["width"], 0);
            Assert.AreEqual(position["length"], 0);
        }
Ejemplo n.º 2
0
        public void Run()
        {
            bool   stop   = false;
            Thread thread = new Thread(new ThreadStart(StartSLMM));

            thread.Start();
            while (!stop)
            {
                ConsoleKeyInfo command = _console.ReadKey(true);
                switch (command.Key)
                {
                case ConsoleKey.UpArrow:
                    _slmm.PushCommand(Command.Move);
                    break;

                case ConsoleKey.LeftArrow:
                    _slmm.PushCommand(Command.TurnLeft);
                    break;

                case ConsoleKey.RightArrow:
                    _slmm.PushCommand(Command.TurnRight);
                    break;

                case ConsoleKey.Enter:
                case ConsoleKey.M:
                    _slmm.PushCommand(Command.Mown);
                    break;

                case ConsoleKey.DownArrow:
                case ConsoleKey.Escape:
                    _slmm.PushCommand(Command.Stop);
                    stop = true;
                    break;
                }
            }

            _console.WriteLine("STOP command received. No more commands allowed to be entered.");
        }