Skip to content

Commit 1e4ed6f

Browse files
committed
refactor : moved board creation to utility class
1 parent ef0c8af commit 1e4ed6f

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

Diff for: minesweeper/tests/unittests/BoardUtilies.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from typing import List
2+
3+
from minesweeper.src.Cell import Cell
4+
from minesweeper.src.State import State
5+
6+
7+
class BoardUtilities:
8+
@staticmethod
9+
def create_empty_board() -> List[List[Cell]]:
10+
expected_cells = []
11+
for i in range(9):
12+
row = []
13+
for j in range(9):
14+
row.append(Cell(State.EMPTY))
15+
expected_cells.append(row)
16+
return expected_cells

Diff for: minesweeper/tests/unittests/EmptyBoardUnitTest.py

+4-12
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import unittest
22

3-
from minesweeper.src.Cell import Cell
43
from minesweeper.src.Game import Game
5-
from minesweeper.src.State import State
4+
from minesweeper.tests.unittests.BoardUtilies import BoardUtilities
65

76

87
class EmptyBoardUnitTest(unittest.TestCase):
98

9+
1010
def setUp(self):
1111
self.game = Game()
1212

@@ -18,14 +18,6 @@ def test_when_game_is_started_it_is_running(self):
1818
assert self.game.isRunning == True
1919

2020
def test_board_is_empty_on_start(self):
21-
expected_cells = []
22-
for i in range(9):
23-
row= []
24-
for j in range(9):
25-
row.append(Cell(State.EMPTY))
26-
expected_cells.append(row)
27-
28-
print(self.game.board.cells)
21+
assert self.game.board.cells == BoardUtilities.create_empty_board()
22+
assert self.game.board.isEmpty() == True;
2923

30-
assert self.game.board.cells == expected_cells
31-
assert self.game.board.isEmpty() == True;

0 commit comments

Comments
 (0)