示例#1
0
        public void TestStart_WrongStatus_2()
        {
            var settings = new SetTest
            {
                GameBoardWidth    = 10,
                GameBoardHeight   = 30,
                GameSpeed         = 40,
                GameScore         = 40.5,
                GamePoints        = 50,
                GameMoveDirection = Direction.Left,
            };
            var generator = new RandomTest();

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

            var game = new Game(settings, generator);

            game.Start();
            game.Stop();
            game.Start();
        }
示例#2
0
        public void TestSettingsInit()
        {
            var settings = new SetTest
            {
                GameBoardWidth    = 10,
                GameBoardHeight   = 30,
                GameSpeed         = 40,
                GameScore         = 40.5,
                GamePoints        = 50,
                GameMoveDirection = Direction.Left,
            };
            var generator = new RandomTest
            {
                genPoints = new List <Point>()
            };
            var game = new Game(settings, generator);

            Assert.AreEqual(40, game.Speed);
            Assert.AreEqual(40.5, game.Score);
            Assert.AreEqual(Direction.Left, game.MoveDirection);
        }
示例#3
0
        public void TestGenerateFood_RandomGenerate_Case1()
        {
            var settings = new SetTest
            {
                GameBoardWidth    = 10,
                GameBoardHeight   = 30,
                GameSpeed         = 40,
                GameScore         = 40.5,
                GamePoints        = 50,
                GameMoveDirection = Direction.Left,
            };

            var generator = new RandomTest();

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

            var game = new Game(settings, generator);

            game.Start();
            Assert.IsNotNull(game.Food);
        }
示例#4
0
        public void TestGameConstructor()
        {
            var settings = new SetTest
            {
                GameBoardWidth    = 10,
                GameBoardHeight   = 30,
                GameSpeed         = 40,
                GameScore         = 40.5,
                GamePoints        = 50,
                GameMoveDirection = Direction.Left
            };

            var generator = new RandomTest();

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

            var game = new Game(settings, generator);

            Assert.IsNotNull(game.Head);
            Assert.AreEqual(GameStatus.ReadyToStart, game.Status);
        }
示例#5
0
        public void TestEat_MaxSpeed()
        {
            var settings = new SetTest
            {
                GameBoardWidth    = 10,
                GameBoardHeight   = 30,
                GameSpeed         = 45,
                GameScore         = 50,
                GamePoints        = 50,
                GameMoveDirection = Direction.Left,
            };

            var generator = new RandomTest();

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

            var game = new Game(settings, generator);

            game.Start();
            game.Move();
            Assert.AreEqual(45, game.Speed);
        }
示例#6
0
        public void TestMoveCheck_CollisionWithTopBorder()
        {
            var settings = new SetTest
            {
                GameBoardWidth    = 10,
                GameBoardHeight   = 30,
                GameSpeed         = 40,
                GameScore         = 40.5,
                GamePoints        = 50,
                GameMoveDirection = Direction.Up,
            };

            var generator = new RandomTest();

            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);
        }
示例#7
0
        public void TestUsualLifecycle()
        {
            var settings = new SetTest
            {
                GameBoardWidth    = 10,
                GameBoardHeight   = 30,
                GameSpeed         = 40,
                GameScore         = 40.5,
                GamePoints        = 50,
                GameMoveDirection = Direction.Left,
            };
            var generator = new RandomTest();

            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);
        }
示例#8
0
        public void TestEat_EatBigFood()
        {
            var settings = new SetTest
            {
                GameBoardWidth    = 10,
                GameBoardHeight   = 30,
                GameSpeed         = 40,
                GameScore         = 0,
                GamePoints        = 50,
                GameMoveDirection = Direction.Left,
            };

            var generator = new RandomTest();

            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);
        }
示例#9
0
        public void TestMoveCheck_CollisionWithEmptyField()
        {
            var settings = new SetTest
            {
                GameBoardWidth    = 10,
                GameBoardHeight   = 30,
                GameSpeed         = 40,
                GameScore         = 40.5,
                GamePoints        = 50,
                GameMoveDirection = Direction.Left,
            };

            var generator = new RandomTest();

            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);
        }