public void TestWinAtRow1() { /* Test win at first row. * X | X | X * O | O | - * - | - | - */ Tictactoe game = new Tictactoe(); game.Put(game.NextPlayer(), 0, 0); // X Assert.IsFalse(game.Win(), "Not by this 1st run"); game.Put(game.NextPlayer(), 1, 0); // O Assert.IsFalse(game.Win(), "Not by this 2st run"); game.Put(game.NextPlayer(), 0, 1); // X Assert.IsFalse(game.Win(), "Not by this 3st run"); game.Put(game.NextPlayer(), 1, 1); // O Assert.IsFalse(game.Win(), "Not by this 4st run"); game.Put(game.NextPlayer(), 0, 2); // X Assert.IsTrue(game.Win(), "X shold be win by this turn"); // X wins. }
public void TestWinAtDiagonal2() { /* Test win at top-right to left-bottom. * - | O | X * - | X | O * X | - | - */ Tictactoe game = new Tictactoe(); game.Put(game.NextPlayer(), 0, 2); // X Assert.IsFalse(game.Win(), "Not by this 1st run"); game.Put(game.NextPlayer(), 1, 0); // O Assert.IsFalse(game.Win(), "Not by this 2st run"); game.Put(game.NextPlayer(), 1, 1); // X Assert.IsFalse(game.Win(), "Not by this 3st run"); game.Put(game.NextPlayer(), 2, 1); // O Assert.IsFalse(game.Win(), "Not by this 4st run"); game.Put(game.NextPlayer(), 2, 0); // X Assert.IsTrue(game.Win(), "X shold be win by this turn"); // X wins. }
void StartGame() { this._game = new Tictactoe(); lbNextPlayer.Text = this.Player; }
void Reset() { // reset buttons style var buttons = new Button[9] { btNumber1, btNumber2, btNumber3, btNumber4, btNumber5, btNumber6, btNumber7, btNumber8, btNumber9 }; for (int i = 0; i < buttons.Length; i++) { buttons[i].Text = i.ToString(); buttons[i].ForeColor = Color.FromArgb(204, 204, 204); } // reset game's object this._game = new Tictactoe(); // reset label lbNextPlayer.Text = "-"; }