Exemple #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())
Exemple #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())
Exemple #3
0
    def test_correct_set_value(self):
        model = QuadraticEquationViewModel()
        model.set_a(1)
        model.set_b(10)
        model.set_c(-12)

        self.assertEqual(1, model.get_a())
        self.assertEqual(10, model.get_b())
        self.assertEqual(-12, model.get_c())
Exemple #4
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:])
Exemple #5
0
 def test_set_c_logging(self):
     model = QuadraticEquationViewModel()
     model.set_c(2)
     self.assertEqual('Setting c = 2', model.logger.get_last_message())
Exemple #6
0
 def test_when_clear_c_button_disabled(self):
     model = QuadraticEquationViewModel(1, -1, 1)
     model.set_c(None)
     self.assertEqual('disabled', model.is_button_enable())