Esempio n. 1
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)
Esempio n. 2
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
Esempio n. 3
0
 def test_fuel_amount__when_more_than_zero__should_work(self):
     car_manager = Car(self.make, self.model, self.fuel_consumption, self.fuel_capacity)
     car_manager.fuel_amount = 5
     self.assertEqual(5, car_manager.fuel_amount)
Esempio n. 4
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)
Esempio n. 5
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)
Esempio n. 6
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)