public void ReversiGameModelNewGameInitializeTooSmallTest() { Int32[] wrongGameTableSizesArray = new Int32[] { 10, 2, 20 }; // <- 2 _dataAccess = new ReversiFileDataAccess(wrongGameTableSizesArray); _model = new ReversiGameModel(_dataAccess, _tableSizeDefaultSetting); }
public void Initialize() { _dataAccess = new ReversiFileDataAccess(_supportedGameTableSizesArray); _model = new ReversiGameModel(_dataAccess, _tableSizeDefaultSetting); _model.UpdateTable += new EventHandler<ReversiUpdateTableEventArgs>(model_UpdateTable); _model.SetGameEnded += new EventHandler<ReversiSetGameEndedEventArgs>(model_SetGameEnded); _model.UpdatePlayerTime += new EventHandler<ReversiUpdatePlayerTimeEventArgs>(model_UpdatePlayerTime); }
/// <summary> /// It is invoked, when the system build up the components of the window and the window itself. /// </summary> /// <param name="sender">This object, we do not use it as a param.</param> /// <param name="e">Auto param, we do not use it.</param> private void GameForm_Load(object sender, EventArgs e) { // Resizing to be symetric. _topRowMinimumWidth = _topFlowLayoutPanelForAll.Width + _topFlowLayoutPanelForAll.Margin.Left + _topFlowLayoutPanelForAll.Margin.Right; _topRowMinimumHeight = _topFlowLayoutPanelForAll.Height + _topFlowLayoutPanelForAll.Margin.Top + _topFlowLayoutPanelForAll.Margin.Bottom; _player1GroupBoxMarginLeftDefault = _player1GroupBox.Margin.Left; _bottomButtonPanelMarginLeftDefault = _bottomButtonPanel.Margin.Left; Width = _topRowMinimumWidth + (2 * 8); Height = _topRowMinimumHeight + _menuStrip.Height + _statusStrip.Height + 37; // Init the data access type with the array, that contain the default table sizes. _dataAccess = new ReversiFileDataAccess(_supportedGameTableSizesArray); try { // Init model _model = new ReversiGameModel(_dataAccess, _tableSizeDefaultSetting); } catch (ReversiModelException) { MessageBox.Show("Model initialization problem." + System.Environment.NewLine + System.Environment.NewLine + "Unsupportable table size given to model. The program will close.", "Reversi"); Close(); } // Connect the events. _model.SetGameEnded += new EventHandler<ReversiSetGameEndedEventArgs>(model_SetGameEnded); _model.UpdatePlayerTime += new EventHandler<ReversiUpdatePlayerTimeEventArgs>(model_UpdatePlayerTime); _model.UpdateTable += new EventHandler<ReversiUpdateTableEventArgs>(model_UpdateTable); // We let the user exit, without asking anything at this point. _saved = true; }