Esempio n. 1
0
 def test_model_perform_logging(self):
     model = QuadraticEquationViewModel()
     model.set_a(2)
     model.set_b(4)
     model.set_c(2)
     model.perform()
     self.assertEqual('Result = Answer:\n x = -1.0',
                      model.logger.get_last_message())
Esempio n. 2
0
    def test_input_wrong_data(self):
        model = QuadraticEquationViewModel()
        model.set_a('@1')
        model.set_b(4)
        model.set_c(2)
        model.perform()

        wrong_message = 'Incorrect input'
        self.assertEqual(wrong_message, model.logger.get_last_message())
Esempio n. 3
0
    def test_model_perform_all_message_logging(self):
        model = QuadraticEquationViewModel()
        model.set_a(2)
        model.set_b(4)
        model.set_c(2)
        model.perform()

        log_message = [
            'Setting a = 2', 'Setting b = 4', 'Setting c = 2',
            'Button clicked', 'a = 2, b = 4, c = 2',
            'Result = Answer:\n x = -1.0'
        ]
        self.assertEqual(log_message, model.logger.get_log_messages()[-6:])
Esempio n. 4
0
 def test_when_enter_incorrect_values_throw_exception(self):
     model = QuadraticEquationViewModel(2, '@48', 2)
     model.perform()
     answer = 'Incorrect input'
     self.assertEqual(answer, model.get_error_message())
Esempio n. 5
0
 def test_when_enter_values_display_result(self):
     model = QuadraticEquationViewModel(2, 4, 2)
     model.perform()
     answer = 'Answer:\n x = -1.0'
     self.assertEqual(answer, model.get_result())