public void World_UpdateWorld_HitWall() { World testWorld = new World(20, 20, 5, 5, 8, 1, 1); testWorld.createSnake(5, "Steven"); bool hitwall = false; for (int i = 0; i < 20; i++) { // move the snake forword a bunch testWorld.UpdateWorld(); // make sure the snake dies eventually foreach (Snake Steven in testWorld.GetSnakes()) { //check if it died if (Steven.GetHead().X == -1) { hitwall = true; } } } Assert.IsTrue(hitwall); }
public void World_Constructor2_OneSnakeTestHeadroom() { // repeat this a bunch since placement is random for (int i = 0; i < 100; i++) { World testWorld = new World(20, 20, 5, 5, 8, 1, 1); testWorld.createSnake(5, "Steven"); //move the snake forward by the headroom testWorld.UpdateWorld(); testWorld.UpdateWorld(); testWorld.UpdateWorld(); testWorld.UpdateWorld(); testWorld.UpdateWorld(); // make sure the snake is still alive foreach (Snake Steven in testWorld.GetSnakes()) { Assert.IsFalse(Steven.GetHead().X == -1); } } }