public void ConstructorCheck() { int size = 7; Position robotpos = new Position(1, 1); ulong time = 0; RobotDirection robotdir = RobotDirection.UP; FieldType fieldOnBot = FieldType.NO_WALL; int timeleftcrazy = 8; CrazyBotInfo gameInfo = new CrazyBotInfo(size, robotpos, time, robotdir, fieldOnBot, timeleftcrazy); CrazyBotModel gameModel = new CrazyBotModel(); gameModel.newGame(7, gameInfo); Assert.AreEqual(gameModel.getRobotPos(), gameInfo.robot); Assert.AreEqual(gameModel.getSize(), 7); Assert.AreEqual(gameInfo.size, 7); CrazyBotInfo gameInfo11 = new CrazyBotInfo(11, robotpos, time, robotdir, fieldOnBot, timeleftcrazy); gameModel.newGame(11, gameInfo11); Assert.AreEqual(gameModel.getRobotPos(), gameInfo11.robot); Assert.AreEqual(gameModel.getSize(), 11); Assert.AreEqual(gameInfo11.size, 11); for (int i = 0; i < 10; i++) { int prev = gameModel.getTime(); gameModel.AdvanceTime(this, new System.EventArgs()); if (gameModel.isInGame()) { Assert.IsTrue(prev < gameModel.getTime()); } } }
private void gameOver(object obj, EventArgs e) { void update() { foreach (var btn in buttons) { btn.Enabled = false; } boardGrid.Visible = false; MessageBox.Show("Congrats! You win this game in: " + TimeSpan.FromSeconds(model.getTime()).ToString("mm':'ss")); statusBar.Text = "No game is in progress"; pause.Enabled = false; play.Enabled = false; save.Enabled = false; load.Enabled = true; } if (boardGrid.InvokeRequired) { boardGrid.Invoke(new MethodInvoker(delegate { update(); })); } else { update(); } }