Beispiel #1
0
 def test_refuel__when_fuel_more_than_capacity__should_be_equal(self):
     car_manager = Car(self.make, self.model, self.fuel_consumption, self.fuel_capacity)
     car_manager.refuel(15)
     self.assertEqual(self.fuel_capacity, car_manager.fuel_amount)
Beispiel #2
0
 def test_refuel__when_fuel_negative_and_has_capacity__should_raise_exception(self):
     car_manager = Car(self.make, self.model, self.fuel_consumption, self.fuel_capacity)
     with self.assertRaises(Exception):
         car_manager.refuel(-5)
Beispiel #3
0
 def test_refuel__when_fuel_less_than_capacity__should_add(self):
     car_manager = Car(self.make, self.model, self.fuel_consumption, self.fuel_capacity)
     car_manager.fuel_amount = 3
     car_manager.refuel(5)
     self.assertEqual(8, car_manager.fuel_amount)
Beispiel #4
0
 def test_fuel_amount__when_negative__should_raise_exception(self):
     car_manager = Car(self.make, self.model, self.fuel_consumption, self.fuel_capacity)
     with self.assertRaises(Exception):
         car_manager.fuel_amount = -5
Beispiel #5
0
 def test_refuel__when_fuel_positive_and_has_capacity__should_work(self):
     car_manager = Car(self.make, self.model, self.fuel_consumption, self.fuel_capacity)
     car_manager.refuel(5)
     self.assertEqual(5, car_manager.fuel_amount)
Beispiel #6
0
 def test_fuel_capacity__when_negative__should_raise_exception(self):
     self.fuel_capacity = -5
     with self.assertRaises(Exception):
         Car(self.make, self.model, self.fuel_consumption, self.fuel_capacity)
Beispiel #7
0
 def test_fuel_amount__when_zero__should_work(self):
     car_manager = Car(self.make, self.model, self.fuel_consumption, self.fuel_capacity)
     self.assertEqual(0, car_manager.fuel_amount)
Beispiel #8
0
 def test_fuel_consumption__when_zero__should_raise_exception(self):
     self.fuel_consumption = 0
     with self.assertRaises(Exception):
         Car(self.make, self.model, self.fuel_consumption, self.fuel_capacity)
Beispiel #9
0
 def test_fuel_capacity__when_more_than_zero__should_work(self):
     self.fuel_capacity = 15
     car_manager = Car(self.make, self.model, self.fuel_consumption, self.fuel_capacity)
     self.assertEqual(15, car_manager.fuel_capacity)
Beispiel #10
0
 def test_model_called__when_model_is_none__should_raise_exception(self):
     self.model = None
     with self.assertRaises(Exception):
         Car(self.make, self.model, self.fuel_consumption, self.fuel_capacity)
Beispiel #11
0
 def test_model_called__when_using_valid_parameters__should_work(self):
     car_manager = Car(self.make, self.model, self.fuel_consumption, self.fuel_capacity)
     self.assertEqual(self.model, car_manager.model)
Beispiel #12
0
 def test_drive__when_fuel_needed_more_than_amount__should_raise_exception(self):
     car_manager = Car(self.make, self.model, self.fuel_consumption, self.fuel_capacity)
     car_manager.fuel_amount = 7
     with self.assertRaises(Exception):
         car_manager.drive(5000)
Beispiel #13
0
 def test_drive__when_fuel_needed_equal_to_amount__should_be_zero(self):
     car_manager = Car(self.make, self.model, self.fuel_consumption, self.fuel_capacity)
     car_manager.fuel_amount = 5
     car_manager.drive(500)
     expected = 0
     self.assertEqual(expected, car_manager.fuel_amount)
Beispiel #14
0
 def test_drive__when_fuel_needed_less_than_amount__should_decrease(self):
     car_manager = Car(self.make, self.model, self.fuel_consumption, self.fuel_capacity)
     car_manager.fuel_amount = 7
     car_manager.drive(500)
     expected = 2
     self.assertEqual(expected, car_manager.fuel_amount)