public float getRentalPrice(EquipmentType equipmentType, int days) { float total = 0; OneTime oneTime = new OneTime(); Premium premium = new Premium(); Regular regular = new Regular(); log.Debug("getRentalPrice: Equipment Type: " + equipmentType + "|Days:" + days); switch (equipmentType) { case EquipmentType.Heavy: total = oneTime.getFees() + premium.getFees(days); break; case EquipmentType.Regular: int daysOverTwo = days - 2; total = oneTime.getFees(); if (daysOverTwo <= 0) { total += premium.getFees(days); } else { total += premium.getFees(2) + regular.getFees(daysOverTwo); } break; case EquipmentType.Specialized: int daysOverThree = days - 3; if (daysOverThree <= 0) { total = premium.getFees(days); } else { total = premium.getFees(3) + regular.getFees(daysOverThree); } break; default: break; } log.Info("getRentalPrice: Total:" + total); return(total); }
public void TestHeavyEquipmentRentalOneDay() { RentalCalculator rc = new RentalCalculator(); OneTime ot = new OneTime(); Premium pr = new Premium(); int days = 1; float shouldBe = ot.getFees() + pr.getFees(1); Assert.AreEqual(rc.getRentalPrice(EquipmentType.Heavy, days), shouldBe); }
public void TestSpecializedEquipmentRentalMoreThanTwoDays() { RentalCalculator rc = new RentalCalculator(); Regular r = new Regular(); Premium pr = new Premium(); int days = 5; float shouldBe = pr.getFees(3) + r.getFees(2); Assert.AreEqual(rc.getRentalPrice(EquipmentType.Specialized, days), shouldBe); }
public void TestRegularEquipmentRentalTwoDays() { RentalCalculator rc = new RentalCalculator(); OneTime ot = new OneTime(); Premium pr = new Premium(); int days = 2; float shouldBe = ot.getFees() + pr.getFees(days); Assert.AreEqual(rc.getRentalPrice(EquipmentType.Regular, days), shouldBe); }