示例#1
0
        public void TestMoveCheck_CollisionWithEmptyField()
        {
            var settings  = new GameSettingsTest(10, 30, 40, 40.5, 50, 5, 5, 1, Direction.Left, "Results.xml");
            var generator = new RandomGeneratorTest();

            generator.genPoints.Add(new Point(7, 7));

            var game = new Game(settings, generator);

            game.Start();
            game.Move();
            game.MoveDirection = Direction.Down;
            for (int i = 0; i < 15; i++)
            {
                game.Move();
            }
            game.MoveDirection = Direction.Right;
            game.Move();
            game.MoveDirection = Direction.Up;
            for (int i = 0; i < 6; i++)
            {
                game.Move();
            }
            game.MoveDirection = Direction.Left;
            game.Move();
            Assert.AreEqual(GameStatus.Completed, game.Status);
        }
示例#2
0
        public void TestSnakeCtrWithoutParameters()
        {
            var   settings    = new GameSettingsTest(10, 30, 40, 40.5, 50, 5, 5, 5, Direction.Left, "Results.xml");
            Snake playerSnake = new Snake(settings);

            Assert.AreEqual(settings.SnakePosX, playerSnake.Head.X);
            Assert.AreEqual(settings.SnakePosY, playerSnake.Head.Y);
        }
示例#3
0
        public void TestGameScoreGetter()
        {
            var settings  = new GameSettingsTest(10, 30, 40, 40, 50, 5, 5, 5, Direction.Left, "Results.xml");
            var generator = new RandomGeneratorTest();

            generator.genPoints.Add(new Point(7, 7));

            var game = new Game(settings, generator);

            Assert.AreEqual(40, game.Score);
        }
示例#4
0
        public void TestStop_WrongStatus_1()
        {
            var settings  = new GameSettingsTest(10, 30, 40, 40.5, 50, 5, 5, 5, Direction.Left, "Results.xml");
            var generator = new RandomGeneratorTest();

            generator.genPoints.Add(new Point(7, 7));

            var game = new Game(settings, generator);

            game.Stop();
        }
示例#5
0
        public void TestSettingsInit()
        {
            var settings  = new GameSettingsTest(10, 30, 40, 40.5, 50, 5, 5, 5, Direction.Left, "Results.xml");
            var generator = new RandomGeneratorTest();

            var game = new Game(settings, generator);

            Assert.AreEqual(40, game.Speed);
            Assert.AreEqual(40.5, game.Score);
            Assert.AreEqual(Direction.Left, game.MoveDirection);
        }
示例#6
0
        public void TestGenerateFood_RandomGenerate_Case1()
        {
            var settings  = new GameSettingsTest(10, 30, 40, 40.5, 50, 5, 5, 5, Direction.Left, "Results.xml");
            var generator = new RandomGeneratorTest();

            generator.genPoints.Add(new Point(7, 7));

            var game = new Game(settings, generator);

            game.Start();
            Assert.IsNotNull(game.Food);
        }
示例#7
0
        public void TestGameConstructor()
        {
            var settings  = new GameSettingsTest(10, 30, 40, 40.5, 50, 5, 5, 5, Direction.Left, "Results.xml");
            var generator = new RandomGeneratorTest();

            generator.genPoints.Add(new Point(7, 7));

            var game = new Game(settings, generator);

            Assert.IsNotNull(game.Head);
            Assert.AreEqual(GameStatus.ReadyToStart, game.Status);
        }
示例#8
0
        public void TestEat_MaxSpeed()
        {
            var settings  = new GameSettingsTest(10, 30, 45, 200, 50, 5, 5, 5, Direction.Left, "Results.xml");
            var generator = new RandomGeneratorTest();

            generator.genPoints.Add(new Point(8, 9));

            var game = new Game(settings, generator);

            game.Start();
            game.Move();
            Assert.AreEqual(45, game.Speed);
        }
示例#9
0
        public void TestEat_EatBigFood()
        {
            var settings  = new GameSettingsTest(10, 30, 40, 0, 50, 5, 5, 1, Direction.Left, "Results.xml");
            var generator = new RandomGeneratorTest();

            generator.genPoints.Add(new Point(3, 1));
            generator.genPoints.Add(new Point(8, 8));
            // Food(3,1)
            var game = new Game(settings, generator);

            game.Start();
            game.Move();
            game.Move();
            Assert.AreEqual(50.2, game.Score);
        }
示例#10
0
        public void TestMoveCheck_CollisionWithTopBorder()
        {
            var settings  = new GameSettingsTest(10, 30, 40, 40.5, 50, 5, 5, 1, Direction.Up, "Results.xml");
            var generator = new RandomGeneratorTest();


            generator.genPoints.Add(new Point(7, 7));

            var game = new Game(settings, generator);

            game.Start();
            game.Move();
            game.Move();
            Assert.AreEqual(GameStatus.Completed, game.Status);
        }
示例#11
0
        public void TestUsualLifecycle()
        {
            var settings  = new GameSettingsTest(10, 30, 40, 40.5, 50, 5, 5, 5, Direction.Left, "Results.xml");
            var generator = new RandomGeneratorTest();

            generator.genPoints.Add(new Point(7, 7));

            var game = new Game(settings, generator);

            Assert.AreEqual(GameStatus.ReadyToStart, game.Status);
            game.Start();
            Assert.AreEqual(GameStatus.InProgress, game.Status);
            game.Stop();
            Assert.AreEqual(GameStatus.Completed, game.Status);
        }
示例#12
0
        public void TestMoveCheck_CollisionWithRightBorder()
        {
            var settings  = new GameSettingsTest(10, 30, 40, 40.5, 50, 5, 5, 5, Direction.Right, "Results.xml");
            var generator = new RandomGeneratorTest();

            generator.genPoints.Add(new Point(7, 7));

            var game = new Game(settings, generator);

            game.Start();
            while (game.Head.X != settings.GameBoardWidth)
            {
                game.Move();
            }
            Assert.AreEqual(GameStatus.Completed, game.Status);
        }
示例#13
0
        public void TestMovement_TurnLeft()
        {
            var settings  = new GameSettingsTest(10, 30, 40, 40.5, 50, 5, 5, 5, Direction.Left, "Results.xml");
            var generator = new RandomGeneratorTest();

            generator.genPoints.Add(new Point(7, 7));

            var game = new Game(settings, generator);

            game.Start();
            var head = game.Head;

            game.Move();
            Assert.AreEqual(head.X - 1, game.Head.X);
            Assert.AreEqual(head.Y, game.Head.Y);
        }
示例#14
0
        public void TestMovement_CheckTailRemove()
        {
            var settings  = new GameSettingsTest(10, 30, 40, 40.5, 50, 5, 5, 5, Direction.Left, "Results.xml");
            var generator = new RandomGeneratorTest();

            generator.genPoints.Add(new Point(7, 7));

            var game = new Game(settings, generator);

            game.Start();
            game.Move();
            var tail = game.Tail;

            game.Move();
            Assert.AreNotEqual(tail.Y, game.Tail.Y);
            Assert.AreEqual(tail.X, game.Tail.X);
        }
示例#15
0
        public void TestGenerateFood_ColissionsWithEmptyField_2()
        {
            var settings  = new GameSettingsTest(10, 30, 40, 40.5, 50, 5, 5, 1, Direction.Left, "Results.xml");
            var generator = new RandomGeneratorTest();

            generator.genPoints.Add(new Point(3, 1));
            generator.genPoints.Add(new Point(5, 5));
            generator.genPoints.Add(new Point(9, 4));
            var game = new Game(settings, generator);

            game.Start();
            game.Move();
            game.Move();

            Assert.IsNotNull(game.Food);
            Assert.AreEqual(9, game.Food.X);
            Assert.AreEqual(4, game.Food.Y);
        }