Пример #1
0
 def test_test(self):
     sudoku = SudokuBoard(3)
     sudoku.from_dictionary(self.dic_with_data, True)
     
     self.assertFalse(sudoku.dic['A3'].is_editable())
     self.assertFalse(sudoku.dic['B2'].is_editable())
     self.assertTrue(sudoku.dic['B1'].is_editable())
     self.assertTrue(sudoku.dic['B3'].is_editable())
Пример #2
0
 def test_given_a_dictionary_with_invalid_values_then_should_raise_an_exception(self):
     sudoku = SudokuBoard(3)
     
     try:
         sudoku.from_dictionary(self.dic_with_invalid_values)
         self.fail("Did not raise the exception InvalidParameterValueException")
     except InvalidParameterValueException:
         pass
Пример #3
0
 def test_given_an_invalid_dictionary_size_then_should_raise_an_exception(self):
     sudoku = SudokuBoard()
     
     try:
         sudoku.from_dictionary(self.dic_with_data)
         self.fail("Did not raise the exception InvalidDictionarySizeException")
     except InvalidDictionarySizeException:
         pass
Пример #4
0
 def test_given_a_valid_dictionary_then_should_convert_it_to_sudoku_table(self):
     sudoku = SudokuBoard(3)
     sudoku.from_dictionary(self.dic_with_data)
     
     rows = ['A', 'B', 'C']
     cols = range(1, 4)
     
     self.assertEqual(len(self.dic_with_data), len(sudoku.dic))
     
     for row in rows:
         for col in cols:
             self.assertEqual(self.dic_with_data[row + str(col)], sudoku.get_value(row, col))
Пример #5
0
 def test_when_restart_game_is_executed_then_the_user_table_should_be_restarted_properly(self):
     sudoku = SudokuBoard(3)
     user_sudoku = SudokuBoard(3)
     
     sudoku.from_dictionary(self.solved_sudoku, True)
     user_sudoku.from_dictionary(self.user_sudoku, True)
     
     game = Game()
     game.initial_sudoku = sudoku
     game.user_sudoku = user_sudoku
     
     cmd = RestartGameCommand(None)
     cmd.set_game(game)
     cmd.execute()
     
     self.assertDictEqual(game.initial_sudoku.to_dictionary(), game.user_sudoku.to_dictionary())
Пример #6
0
 def test_given_a_valid_parameters_then_should_set_the_hint_value_in_the_soduko_board(self):
     initial_sudoku = SudokuBoard(3)
     user_sudoku = SudokuBoard(3)
     solved_sudoku = SudokuBoard(3)
     
     initial_sudoku.from_dictionary(self.solved_sudoku)
     user_sudoku.from_dictionary(self.user_sudoku)
     solved_sudoku.from_dictionary(self.solved_sudoku)
     
     game = Game()
     game.started = True
     game.initial_sudoku = initial_sudoku
     game.user_sudoku = user_sudoku
     game.solved_sudoku = solved_sudoku
     
     cmd = HintCommand(self.hint_parameters)
     cmd.set_game(game)
     
     cmd.execute()
     
     self.assertEqual(game.solved_sudoku.dic[self.cell].value, game.user_sudoku.dic[self.cell].value)