예제 #1
0
        public void Snake_Moves_Left_Correctly()
        {
            //create new snake
            GameSnake    testSnake = new GameSnake();
            List <Point> testSnakeList;

            testSnakeList = testSnake.createFirstSnake(15, 15, 5);
            Assert.IsTrue(testSnakeList.Count() == 5);

            //tested moving left without having eaten food
            testSnakeList = testSnake.snakeMove(Direction.Left, false);
            Assert.IsTrue(testSnakeList.Count() == 5);
            Assert.IsTrue(testSnakeList.ElementAt(0).returnX() == 7);
            Assert.IsTrue(testSnakeList.ElementAt(0).returnY() == 6);
        }
예제 #2
0
        public void Snake_Moves_Down_Correctly()
        {
            //create new snake
            GameSnake    testSnake = new GameSnake();
            List <Point> testSnakeList;

            testSnakeList = testSnake.createFirstSnake(60, 40, 4);

            testSnakeList = testSnake.snakeMove(Direction.Down, false);
            Assert.IsTrue(testSnakeList.Count() == 4);
            Assert.IsTrue(testSnakeList.ElementAt(0).returnX() == 31);
            Assert.IsTrue(testSnakeList.ElementAt(0).returnY() == 20);
            Assert.IsTrue(testSnakeList.ElementAt(3).returnX() == 28);
            Assert.IsTrue(testSnakeList.ElementAt(3).returnY() == 20);
        }
예제 #3
0
        public void Snake_Moves_Up_Correctly()
        {
            //create new snake
            GameSnake    testSnake = new GameSnake();
            List <Point> testSnakeList;

            testSnakeList = testSnake.createFirstSnake(20, 20, 2);
            Assert.IsTrue(testSnakeList.Count() == 2);

            //tested moving up having eaten food
            testSnakeList = testSnake.snakeMove(Direction.Up, true);
            Assert.IsTrue(testSnakeList.Count() == 3);
            Assert.IsTrue(testSnakeList.ElementAt(0).returnX() == 9);
            Assert.IsTrue(testSnakeList.ElementAt(0).returnY() == 10);
        }
예제 #4
0
        public void Snake_Moves_Right_Correctly()
        {
            //create new snake
            GameSnake    testSnake = new GameSnake();
            List <Point> testSnakeList;

            testSnakeList = testSnake.createFirstSnake(20, 40, 3);

            //tested moving right with having eaten food
            testSnakeList = testSnake.snakeMove(Direction.Right, true);
            Assert.IsTrue(testSnakeList.Count() == 4);
            Assert.IsTrue(testSnakeList.ElementAt(0).returnX() == 10);
            Assert.IsTrue(testSnakeList.ElementAt(0).returnY() == 21);
            Assert.IsTrue(testSnakeList.ElementAt(1).returnX() == 10);
            Assert.IsTrue(testSnakeList.ElementAt(1).returnY() == 20);
        }