コード例 #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);
        }