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