コード例 #1
0
 public void open_all_blocks_test()
 {
     MinesweeperGrid gameGrid = new MinesweeperGrid(10, 10);
     gameGrid.openAllCells();
     foreach (MinesweeperItem item in gameGrid.items) {
         Assert.True(item.type!= MinesweeperItemType.MinesweeperItemType_None);
     }
 }
コード例 #2
0
 public void find_item_test()
 {
     int rows = 10;
     int cols = 10;
     MinesweeperGrid gameGrid = new MinesweeperGrid(rows, cols);
     gameGrid.makeGrid();
     for (int r = 0; r < rows; r++) {
         for (int c = 0; c < cols; c++) {
             Assert.True(gameGrid.findItemAt(new MinesweeperItemCellDefinition(r,c))!=null);
         }
     }
 }
コード例 #3
0
        private void StartGame(object sender, RoutedEventArgs e)
        {
            try {
                if (!gameParamsAreOk()) {
                    return;
                }

                //creates an intance of MinesweeperGrid by using a GameParams instance (see gameParamsAreOk)
                gameGrid = new MinesweeperGrid(
                    gameParams.rows,
                    gameParams.cols,
                    gameParams.mines
                    );

                //sets MinesweeperGrid event hanlder
                gameGrid.itemAdded += gameGrid_itemAdded;
                gameGrid.itemMineAdded += gameGrid_itemMineAdded;
                gameGrid.loadingCompleted += gameGrid_loadingCompleted;
                gameGrid.errorOccurred += gameGrid_errorOccurred;
                gameGrid.cellOpeningCompleted += gameGrid_cellOpeningCompleted;
                gameGrid.gameOver +=gameGrid_gameOver;
                //makes game grid: it will raise a gameGrid_loadingCompleted() event
                gameGrid.makeGrid();

            }
            catch (Exception ex) {
                handleException(ex);
            }
        }
コード例 #4
0
 public void grid_make_items_test()
 {
     MinesweeperGrid gameGrid = new MinesweeperGrid(10, 10);
     gameGrid.makeGrid();
     Assert.True(gameGrid.items.Count == 100);
 }