Exemple #1
0
        public void DirectionU2RTest()
        {
            var snake = new SnakeObject(6, 6);

            snake.Direction = SnakeDirection.Down;
            for (var i = 0; i < 15; i++)
            {
                snake.Movement();
            }

            snake.Direction = SnakeDirection.Left;
            for (var i = 0; i < 15; i++)
            {
                snake.Movement();
            }

            snake.Direction = SnakeDirection.Up;
            for (var i = 0; i < 15; i++)
            {
                snake.Movement();
            }

            snake.Direction = SnakeDirection.Right;
            for (var i = 0; i < 15; i++)
            {
                snake.Movement();
            }

            Assert.AreEqual(SnakeDirection.Right, snake.Direction, "Snake failed to turn right");
        }
Exemple #2
0
        public void RestrictedDirectionL2RTest()
        {
            var snake = new SnakeObject(6, 6);

            snake.Direction = SnakeDirection.Down;
            for (var i = 0; i < 15; i++)
            {
                snake.Movement();
            }

            snake.Direction = SnakeDirection.Left;
            for (var i = 0; i < 15; i++)
            {
                snake.Movement();
            }

            snake.Direction = SnakeDirection.Right;

            Assert.AreNotEqual(SnakeDirection.Right, snake.Direction, "Snake accidentally turned into itself");
        }
Exemple #3
0
        public void ExtendedMovementTest()
        {
            var snake = new SnakeObject(6, 6);

            snake.Direction = SnakeDirection.Down;

            for (var i = 0; i < 15; i++)
            {
                snake.Movement();
            }

            Assert.IsTrue(snake.X == 3 && snake.Y == 4);
            snake.Direction = SnakeDirection.Left;

            for (var i = 0; i < 15; i++)
            {
                snake.Movement();
            }

            Assert.IsTrue(snake.X == 2 && snake.Y == 4);
        }
Exemple #4
0
        public void LengthTest()
        {
            var snake = new SnakeObject(6, 6);

            snake.Grow = true;

            for (var i = 0; i < 60; i++)
            {
                snake.Movement();
            }

            Assert.AreEqual(4, snake.Length);
        }
Exemple #5
0
        public void DirectionR2DTest()
        {
            var snake = new SnakeObject(6, 6);


            snake.Direction = SnakeDirection.Down;

            for (var i = 0; i < 15; i++)
            {
                snake.Movement();
            }

            Assert.AreEqual(SnakeDirection.Down, snake.Direction, "Snake failed to turn down");
        }