@Test public void test() { rentalcompany.addCar(car1); rentalcompany.addCar(car2); int testmethod = rentalcompany.terminateRental(drivinglicence); // No rental contract should return 0 and print message. assertEquals(0, testmethod); rentalcompany.issueCar(drivinglicence, "large"); car1.drive(40); testmethod = rentalcompany.terminateRental(drivinglicence); // Check that message is passed when fuel is liable assertEquals(4, testmethod); rentalcompany.issueCar(drivinglicence, "small"); testmethod = rentalcompany.terminateRental(drivinglicence); // Check that 0 returned and message printed when all conditions met assertEquals(0, testmethod); }
@Test public void test() { // test car won't add fuel if not rented assertEquals(0, car1.addFuel(30)); car1.setRentalStatus(true); car1.drive(50); int a = car1.addFuel(10); car1.drive(50); int b = car1.addFuel(5); // Check car will only add fuel to full capacity if given // right amount and too much. assertEquals(a, b); car2.setRentalStatus(true); car2.drive(50); a = car1.addFuel(10); car2.drive(50); b = car1.addFuel(5); assertEquals(a, b); }