Пример #1
0
        public void MoveTest()
        {
            _pacman.SetPacmanX(3);
            _pacman.SetPacmanY(2);
            _pacman.SetPacmanDir("WEST");
            Direction currentDirection = Direction.WEST;

            switch (currentDirection)
            {
            case Direction.NORTH:
                if (_pacman.PacmanY() + 1 < 5)
                {
                    _pacman.SetPacmanY(_pacman.PacmanY() + 1);
                }
                break;

            case Direction.EAST:
                if (_pacman.PacmanX() + 1 < 5)
                {
                    _pacman.SetPacmanX(_pacman.PacmanX() + 1);
                }
                break;

            case Direction.SOUTH:
                if (_pacman.PacmanY() - 1 > -1)
                {
                    _pacman.SetPacmanY(_pacman.PacmanY() - 1);
                }
                break;

            case Direction.WEST:
                if (_pacman.PacmanX() - 1 > -1)
                {
                    _pacman.SetPacmanX(_pacman.PacmanX() - 1);
                }
                break;
            }
            String result = _pacman.PacmanX().ToString() + "," + _pacman.PacmanY().ToString() + "," + _pacman.GetDirectionString();

            Assert.AreEqual("2,2,WEST", result);
        }