예제 #1
0
        public void PerformMapTests(string inputFile)
        {
            var currentGame = InitializeGame("TestMaps/" + inputFile + ".in");

            var loop = new ManualEventCaller();

            currentGame.Register(loop);

            var commandStream = new StreamReader("TestMaps/" + inputFile + "Command.in");

            var commandString = commandStream.ReadLine();

            while (commandString != null)
            {
                var command = commandString.Split(' ');

                switch (command[0])
                {
                case "right":
                    loop.MoveToRight();
                    break;

                case "down":
                    loop.MoveToBottom();
                    break;

                case "up":
                    loop.MoveToTop();
                    break;

                case "left":
                    loop.MoveToLeft();
                    break;

                default:
                    Assert.Fail("Invalid command file format");
                    break;
                }

                var newCoords      = currentGame.GetPlayerPosition();
                var expectedCoords = (int.Parse(command[1]), int.Parse(command[2]));

                Assert.AreEqual(expectedCoords, newCoords);

                commandString = commandStream.ReadLine();
            }
        }
예제 #2
0
        public void CheckScreenChangingOnBigMaps(
            string inputFile,
            bool moveUpDown,
            int stepCount)
        {
            var currentGame = InitializeGame($"TestMaps/{inputFile}.in");
            var loop        = new ManualEventCaller();

            currentGame.Register(loop);

            for (int i = 0; i < stepCount; ++i)
            {
                if (moveUpDown)
                {
                    loop.MoveToBottom();
                }
                else
                {
                    loop.MoveToRight();
                }
            }

            var currentCoordinates = currentGame.GetPlayerPosition();

            Assert.AreEqual(
                moveUpDown ? (0, stepCount) : (stepCount, 0), currentCoordinates);

            for (int i = 0; i < stepCount; ++i)
            {
                if (moveUpDown)
                {
                    loop.MoveToTop();
                }
                else
                {
                    loop.MoveToLeft();
                }
            }

            currentCoordinates = currentGame.GetPlayerPosition();
            Assert.AreEqual((0, 0), currentCoordinates);
        }