public void TestMoveCheck_CollisionWithEmptyField() { var settings = new GameSettingsTest(10, 30, 40, 40.5, 50, 5, 5, 1, Direction.Left, "Results.xml"); var generator = new RandomGeneratorTest(); 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); }
public void TestSnakeCtrWithoutParameters() { var settings = new GameSettingsTest(10, 30, 40, 40.5, 50, 5, 5, 5, Direction.Left, "Results.xml"); Snake playerSnake = new Snake(settings); Assert.AreEqual(settings.SnakePosX, playerSnake.Head.X); Assert.AreEqual(settings.SnakePosY, playerSnake.Head.Y); }
public void TestGameScoreGetter() { var settings = new GameSettingsTest(10, 30, 40, 40, 50, 5, 5, 5, Direction.Left, "Results.xml"); var generator = new RandomGeneratorTest(); generator.genPoints.Add(new Point(7, 7)); var game = new Game(settings, generator); Assert.AreEqual(40, game.Score); }
public void TestStop_WrongStatus_1() { var settings = new GameSettingsTest(10, 30, 40, 40.5, 50, 5, 5, 5, Direction.Left, "Results.xml"); var generator = new RandomGeneratorTest(); generator.genPoints.Add(new Point(7, 7)); var game = new Game(settings, generator); game.Stop(); }
public void TestSettingsInit() { var settings = new GameSettingsTest(10, 30, 40, 40.5, 50, 5, 5, 5, Direction.Left, "Results.xml"); var generator = new RandomGeneratorTest(); var game = new Game(settings, generator); Assert.AreEqual(40, game.Speed); Assert.AreEqual(40.5, game.Score); Assert.AreEqual(Direction.Left, game.MoveDirection); }
public void TestGenerateFood_RandomGenerate_Case1() { var settings = new GameSettingsTest(10, 30, 40, 40.5, 50, 5, 5, 5, Direction.Left, "Results.xml"); var generator = new RandomGeneratorTest(); generator.genPoints.Add(new Point(7, 7)); var game = new Game(settings, generator); game.Start(); Assert.IsNotNull(game.Food); }
public void TestGameConstructor() { var settings = new GameSettingsTest(10, 30, 40, 40.5, 50, 5, 5, 5, Direction.Left, "Results.xml"); var generator = new RandomGeneratorTest(); generator.genPoints.Add(new Point(7, 7)); var game = new Game(settings, generator); Assert.IsNotNull(game.Head); Assert.AreEqual(GameStatus.ReadyToStart, game.Status); }
public void TestEat_MaxSpeed() { var settings = new GameSettingsTest(10, 30, 45, 200, 50, 5, 5, 5, Direction.Left, "Results.xml"); var generator = new RandomGeneratorTest(); generator.genPoints.Add(new Point(8, 9)); var game = new Game(settings, generator); game.Start(); game.Move(); Assert.AreEqual(45, game.Speed); }
public void TestEat_EatBigFood() { var settings = new GameSettingsTest(10, 30, 40, 0, 50, 5, 5, 1, Direction.Left, "Results.xml"); var generator = new RandomGeneratorTest(); 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); }
public void TestMoveCheck_CollisionWithTopBorder() { var settings = new GameSettingsTest(10, 30, 40, 40.5, 50, 5, 5, 1, Direction.Up, "Results.xml"); var generator = new RandomGeneratorTest(); 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); }
public void TestUsualLifecycle() { var settings = new GameSettingsTest(10, 30, 40, 40.5, 50, 5, 5, 5, Direction.Left, "Results.xml"); var generator = new RandomGeneratorTest(); 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); }
public void TestMoveCheck_CollisionWithRightBorder() { var settings = new GameSettingsTest(10, 30, 40, 40.5, 50, 5, 5, 5, Direction.Right, "Results.xml"); var generator = new RandomGeneratorTest(); generator.genPoints.Add(new Point(7, 7)); var game = new Game(settings, generator); game.Start(); while (game.Head.X != settings.GameBoardWidth) { game.Move(); } Assert.AreEqual(GameStatus.Completed, game.Status); }
public void TestMovement_TurnLeft() { var settings = new GameSettingsTest(10, 30, 40, 40.5, 50, 5, 5, 5, Direction.Left, "Results.xml"); var generator = new RandomGeneratorTest(); generator.genPoints.Add(new Point(7, 7)); var game = new Game(settings, generator); game.Start(); var head = game.Head; game.Move(); Assert.AreEqual(head.X - 1, game.Head.X); Assert.AreEqual(head.Y, game.Head.Y); }
public void TestMovement_CheckTailRemove() { var settings = new GameSettingsTest(10, 30, 40, 40.5, 50, 5, 5, 5, Direction.Left, "Results.xml"); var generator = new RandomGeneratorTest(); generator.genPoints.Add(new Point(7, 7)); var game = new Game(settings, generator); game.Start(); game.Move(); var tail = game.Tail; game.Move(); Assert.AreNotEqual(tail.Y, game.Tail.Y); Assert.AreEqual(tail.X, game.Tail.X); }
public void TestGenerateFood_ColissionsWithEmptyField_2() { var settings = new GameSettingsTest(10, 30, 40, 40.5, 50, 5, 5, 1, Direction.Left, "Results.xml"); var generator = new RandomGeneratorTest(); generator.genPoints.Add(new Point(3, 1)); generator.genPoints.Add(new Point(5, 5)); generator.genPoints.Add(new Point(9, 4)); var game = new Game(settings, generator); game.Start(); game.Move(); game.Move(); Assert.IsNotNull(game.Food); Assert.AreEqual(9, game.Food.X); Assert.AreEqual(4, game.Food.Y); }