Ejemplo n.º 1
0
    def execute(self):
        '''
        execute the command taking account the parameters of the command
        '''
        
        if self.game == None:
            raise InvalidCmdParametersException("The command needs a game.")
        elif self.game.initial_sudoku == None:
            raise InvalidCmdParametersException("The Sudoku was not loaded.")

        writer_factory = WriterFactory('txt')
        writer = writer_factory.getWriter()
        writer.write(self.game.initial_sudoku.to_dictionary(), self.readconfig_parameters[self.OUTPUT_PARAM])
Ejemplo n.º 2
0
 def test_factory_should_return_a_console_writer(self):
     writer_factory = WriterFactory('console')
     writer = writer_factory.getWriter()
     self.assertEqual(DisplayCMD, type(writer))
Ejemplo n.º 3
0
 def test_having_txt_file_should_return_a_txt_file_writer(self):
     writer_factory = WriterFactory('txt')
     writer = writer_factory.getWriter()
     self.assertEqual(WriterTXT, type(writer))
Ejemplo n.º 4
0
 def test_having_csv_file_should_return_a_csv_file_writer(self):
     writer_factory = WriterFactory('csv')
     writer = writer_factory.getWriter()
     self.assertEqual(WriterCSV, type(writer))