public void CalculateStaffel_Vip_2Res_ShouldBeCorrect() { VipServicesContextTest contextTest = new VipServicesContextTest(keepExistingDB: false); VipServicesManager m = new VipServicesManager(new UnitOfWork(contextTest)); LimousineRepository limousineRepo = new LimousineRepository(contextTest); StaffelDiscountTestInitialize(); Address address = new Address("Groenlaan", "17", "Herzele"); Customer customer = new Customer("Jan", "BE0502358347", address, CategoryType.vip); m.AddLimousine("Chrysler", "300C Limousine", "White", 175, 800, 500, 1000); Limousine limousine = limousineRepo.Find(1); m.AddWeddingReservation(customer, address, new Location("Gent"), new Location("Brussel"), new DateTime(2020, 09, 22, 10, 0, 0), new DateTime(2020, 09, 22, 20, 0, 0), limousine); m.AddWeddingReservation(customer, address, new Location("Gent"), new Location("Brussel"), new DateTime(2020, 09, 23, 10, 0, 0), new DateTime(2020, 09, 23, 20, 0, 0), limousine); Action act = () => { m.CalculateStaffel(customer); }; act.Should().NotThrow <Exception>(); Assert.AreEqual(m.CalculateStaffel(customer), 5); }
public void TestPriceCalculationChargedDiscountsMaxAmountReservation() { DateTime reservationDateStart = new DateTime(2020, 01, 23, 15, 00, 00); DateTime reservationDateEnd = new DateTime(2020, 01, 23, 18, 00, 00); Arrangement arrangement = new HourlyArrangement(100, HourlyArrangementType.Airport, reservationDateStart, reservationDateEnd); Limousine limoTest = new Limousine("FIAT 500", 100, new List <Arrangement>() { }); List <Discount> vip = new List <Discount>() { new Discount(2, 0.05f), new Discount(7, 0.075f), new Discount(15, 0.1f) }; Category categorieTestVIP = new Category(vip, CategorieType.vip); Client clientTest = new Client("Tom", "684432685", "Jef De Belderlaan 6", categorieTestVIP); _ = new Reservation("Kerkstraat 45", clientTest, new ReservationDetails(reservationDateStart, reservationDateEnd, Location.Gent, Location.Brussel, limoTest, arrangement)); _ = new Reservation("Kerkstraat 45", clientTest, new ReservationDetails(reservationDateStart.AddDays(1), reservationDateEnd.AddDays(1), Location.Gent, Location.Brussel, limoTest, arrangement)); _ = new Reservation("Kerkstraat 45", clientTest, new ReservationDetails(reservationDateStart.AddDays(2), reservationDateEnd.AddDays(1), Location.Gent, Location.Brussel, limoTest, arrangement)); _ = new Reservation("Kerkstraat 45", clientTest, new ReservationDetails(reservationDateStart.AddDays(3), reservationDateEnd.AddDays(1), Location.Gent, Location.Brussel, limoTest, arrangement)); _ = new Reservation("Kerkstraat 45", clientTest, new ReservationDetails(reservationDateStart.AddDays(4), reservationDateEnd.AddDays(1), Location.Gent, Location.Brussel, limoTest, arrangement)); _ = new Reservation("Kerkstraat 45", clientTest, new ReservationDetails(reservationDateStart.AddDays(5), reservationDateEnd.AddDays(1), Location.Gent, Location.Brussel, limoTest, arrangement)); _ = new Reservation("Kerkstraat 45", clientTest, new ReservationDetails(reservationDateStart.AddDays(6), reservationDateEnd.AddDays(1), Location.Gent, Location.Brussel, limoTest, arrangement)); Reservation test = new Reservation("Kerkstraat 45", clientTest, new ReservationDetails(reservationDateStart.AddDays(7), reservationDateEnd.AddDays(2), Location.Gent, Location.Brussel, limoTest, arrangement)); test.PriceCalculation.ChargedDiscounts.ShouldBe(17.25m);//7.5% }
public void LimousineTest_Methods() { List <Arangement> arangements = new List <Arangement> { new Wedding(2000), new Wellness(3200), new Airport(), new Business(), new Nightlife(2500) }; Limousine limousine = new Limousine(100, "Tesla Model X", 10, arangements); int price = 2000; DateTime dateNeeded = new DateTime(2000, 2, 23, 10, 0, 0); limousine.PriceForArangement(dateNeeded, "Wedding", startHour: new TimeSpan(7, 0, 0)).Key.Should().Be(price); price = 3200; dateNeeded = new DateTime(2000, 2, 25, 10, 0, 0); limousine.PriceForArangement(dateNeeded, "Wellness", startHour: new TimeSpan(7, 0, 0)).Key.Should().Be(price); price = 2500; dateNeeded = new DateTime(2000, 2, 24, 10, 0, 0); limousine.PriceForArangement(dateNeeded, "Nightlife", startHour: new TimeSpan(22, 0, 0)).Key.Should().Be(price); TimeSpan startHour = new TimeSpan(10, 0, 0); TimeSpan endHour = new TimeSpan(15, 0, 0); price = 360; dateNeeded = new DateTime(2000, 2, 27, 10, 0, 0); limousine.PriceForArangement(dateNeeded, "Airport", startHour: startHour, endHour: endHour).Key.Should().Be(price); dateNeeded = new DateTime(2000, 2, 29, 10, 0, 0); limousine.PriceForArangement(dateNeeded, "Business", startHour: startHour, endHour: endHour).Key.Should().Be(price); }
public void AddWelnessReservation_WithLessThen10Hours_ShouldThrowException() { VipServicesContextTest contextTest = new VipServicesContextTest(keepExistingDB: false); VipServicesManager m = new VipServicesManager(new UnitOfWork(contextTest)); LimousineRepository limousineRepo = new LimousineRepository(contextTest); Address addressCustomer = new Address("Groenlaan", "17", "Herzele"); Address limousineExceptedAddress = new Address("Nieuwstraat", "5B", "Brussel"); Customer customer = new Customer("Jan", "", addressCustomer, CategoryType.particulier); Location locationStart = new Location("Gent"); Location locationArrival = new Location("Brussel"); DateTime startTime = new DateTime(2020, 09, 22, 12, 0, 0); DateTime endTime = new DateTime(2020, 09, 22, 19, 0, 0); TimeSpan totalHours = endTime - startTime; m.AddLimousine("Tesla", "Model X", "White", 600, 1500, 2500, 2700); Limousine limousine = limousineRepo.Find(1); Action act = () => { m.AddWelnessReservation(customer, limousineExceptedAddress, locationStart, locationArrival, startTime, endTime, limousine); }; act.Should().Throw <DomainException>().WithMessage("Een Welness reservatie moet altijd 10 uur zijn."); }
public void LimousineTest_Constructor() { List <Arangement> arangements = new List <Arangement> { new Wedding(2000), new Wellness(3200), new Airport(), new Business(), new Nightlife(2500) }; int FirsHourprice = 130; int Available = 1; string Name = "Tesla Model X"; Limousine limousine = new Limousine(130, "Tesla Model X", 1, arangements); limousine.FirstHourPrice.Should().Be(FirsHourprice); limousine.Name.Should().BeEquivalentTo(Name); limousine.Available.Should().Be(Available); limousine.Arangements.Count.Should().Be(arangements.Count); limousine.Arangements.Any(s => s.GetType().ToString().Equals(new Wedding(2000).GetType().ToString())).Should().BeTrue(); limousine.Arangements.Any(s => s.GetType().ToString().Equals(new Wellness(3200).GetType().ToString())).Should().BeTrue(); limousine.Arangements.Any(s => s.GetType().ToString().Equals(new Airport().GetType().ToString())).Should().BeTrue(); limousine.Arangements.Any(s => s.GetType().ToString().Equals(new Business().GetType().ToString())).Should().BeTrue(); limousine.Arangements.Any(s => s.GetType().ToString().Equals(new Nightlife(2500).GetType().ToString())).Should().BeTrue(); }
public void ReserveringTest_Methods() { DateTime date = new DateTime(2000, 1, 10, 20, 3, 1); Address address = new Address("Leusrhoek", "Gent", "20"); var discounts = Parser.GetDiscounts().Where(d => d.ClientType == ClientType.Vip).ToList(); Client test = new Client(ClientType.Vip, Parser.GetDiscounts().Where(s => s.ClientType.Equals("Vip")).ToList(), new Address("Leurshoek", "Beveren", "61"), "Vip", "0862333424", new List <ReservationsPerYear>()); Address endLocation = new Address("Leusrhoek", "Gent", "20"); DateTime dateNeeded = new DateTime(2000, 2, 13, 8, 0, 0); List <Arangement> arangements = new List <Arangement> { new Wedding(2000), new Wellness(3200), new Airport(), new Business(), new Nightlife(2500) }; Limousine limousine = new Limousine(130, "Tesla Model X", 1, arangements); Reservering reservering = new Reservering(date, test, address); reservering.AddDetails(endLocation, limousine, dateNeeded, "Wedding", startHour: new TimeSpan(7, 0, 0)); reservering.Details.ToPayAmount.Should().Be(2120); }
public void DetailsTest_Methods() { Address location = new Address("Leusrhoek", "Gent", "20"); List <Arangement> arangements = new List <Arangement>() { new Wedding(2000) }; Limousine limousine = new Limousine(200, "Tesla - X", 2, arangements); DateTime dateNeeded = new DateTime(10, 2, 23, 10, 0, 0); string arrangement = "Wedding"; Details details = new Details(location, location, limousine, dateNeeded, arrangement); Address address = new Address("Leusrhoek", "Beveren", "20"); var discounts = Parser.GetDiscounts().Where(d => d.ClientType == ClientType.Vip).ToList(); Client test = new Client(ClientType.Vip, Parser.GetDiscounts().Where(s => s.ClientType.Equals("Vip")).ToList(), new Address("Leurshoek", "Beveren", "61"), "Vip", "0862333424", new List <ReservationsPerYear>()); int subTotal = 2000; float usedDiscount = 0; int amountWithoutBtw = 2000; int btwAmount = 120; int toPay = 2120; details.CalculatePrices(test, startHour: new TimeSpan(7, 0, 0)); details.SubTotal.Should().Be(subTotal); details.UsedDiscount.Should().Be(usedDiscount); details.AmountWithoutBtw.Should().Be(amountWithoutBtw); details.BtwAmount.Should().Be(btwAmount); details.ToPayAmount.Should().Be(toPay); }
/// <summary> /// Deze method voegt een business arrangement reservatie toe aan de DB /// </summary> public void AddBusinessReservation(Customer customer, Address limousineExpectedAddress, Location startLocation, Location arrivalLocation, DateTime startTime, DateTime endTime, Limousine limousine) { if (endTime < startTime) { throw new DomainException("Een reservatie mag niet eindigen voor het begint."); } TimeSpan totalHours = endTime - startTime; if (totalHours.Hours < 1) { throw new DomainException("Een Business reservatie mag niet korter zijn dan 1uur."); } if (totalHours.Hours > 11) { throw new DomainException("Een Business reservatie mag niet langer zijn dan 11uur."); } List <Limousine> limousines = GetAllAvailableLimousines(startTime, endTime, ArrangementType.Business); if (!limousines.Contains(limousine)) { throw new DomainException("Limousine is niet beschikbaar."); } double discountPercentage = CalculateStaffel(customer); Price price = PriceCalculator.PerHourPriceCalculator(limousine, totalHours, startTime, endTime, discountPercentage); Reservation reservation = new Reservation(customer, DateTime.Now, limousineExpectedAddress, startLocation, arrivalLocation, ArrangementType.Business, startTime, endTime, totalHours, limousine, price); uow.Reservations.AddReservation(reservation); uow.Complete(); }
/// <summary> /// Deze method voegt een welness arrangement reservatie toe aan de DB /// </summary> public void AddWelnessReservation(Customer customer, Address limousineExpectedAddress, Location startLocation, Location arrivalLocation, DateTime startTime, DateTime endTime, Limousine limousine) { if (endTime < startTime) { throw new DomainException("Een reservatie mag niet eindigen voor het begint."); } if (startTime.Hour < 7 || startTime.Hour > 12) { throw new DomainException("Een Welness reservatie moet starten tussen 07u00 en 12u00."); } TimeSpan totalHours = endTime - startTime; if (totalHours.Hours != 10) { throw new DomainException("Een Welness reservatie moet altijd 10 uur zijn."); } List <Limousine> limousines = GetAllAvailableLimousines(startTime, endTime, ArrangementType.Wellness); if (!limousines.Contains(limousine)) { throw new DomainException("Limousine is niet beschikbaar."); } double discountPercentage = CalculateStaffel(customer); Price price = PriceCalculator.WelnessPriceCalculator(limousine, totalHours, startTime, endTime, discountPercentage); Reservation reservation = new Reservation(customer, DateTime.Now, limousineExpectedAddress, startLocation, arrivalLocation, ArrangementType.Wellness, startTime, endTime, totalHours, limousine, price); uow.Reservations.AddReservation(reservation); uow.Complete(); }
/// <summary> /// Deze method berekent de netto prijs voor het NightLife arrangement /// </summary> public static Price NightlifePriceCalculator(Limousine limousine, TimeSpan totalHours, DateTime startTime, DateTime endTime, double discountPercentage) { Price price = new Price(); //NightLife is minstens 7uur en heeft een vaste prijs, stel de vaste prijs in voor de gekozen limo price.FixedPrice = limousine.NightLifePrice; //Indien het totale uur groter is dan 7, bereken het aantal overuren = nachturen if (totalHours.Hours > 7) { //Bereken de overige uren als nachturen TimeSpan sevenHours = new TimeSpan(7, 0, 0); price.NightHourCount = totalHours.Hours - sevenHours.Hours; //Bereken op basis van het aantal nachturen, de nacht prijs in totaal, afgerond op 5 price.NightHourPrice = Math.Round(((double)(price.NightHourPercentage / 100.0) * ((double)price.NightHourCount * (double)limousine.FirstHourPrice)) / 5) * 5; } //Bereken de subtotaalprijs op basis van de vorige bedragen price.SubTotal = price.FixedPrice + price.NightHourPrice; //Stel de staffelkorting in price.StaffelDiscount = discountPercentage; //Bereken de totaalprijs in een algemene method TotalPriceCalculator(price); return(price); }
public void GetAllAvailableLimousines_AvailableLimousine_ShouldWork() { VipServicesContextTest contextTest = new VipServicesContextTest(keepExistingDB: false); VipServicesManager m = new VipServicesManager(new UnitOfWork(contextTest)); LimousineRepository limousineRepo = new LimousineRepository(contextTest); Address addressCustomer = new Address("Groenlaan", "17", "Herzele"); Address limousineExceptedAddress = new Address("Nieuwstraat", "5B", "Brussel"); Customer customer = new Customer("Jan", "", addressCustomer, CategoryType.particulier); Location locationStart = new Location("Gent"); Location locationArrival = new Location("Brussel"); m.AddLimousine("Chrysler", "300C Limousine", "White", 175, 800, 500, 1000); Limousine limousineChrysler = limousineRepo.Find(1); // 6 uur ervoor m.AddBusinessReservation(customer, limousineExceptedAddress, locationStart, locationArrival, new DateTime(2020, 09, 22, 0, 0, 0), new DateTime(2020, 09, 22, 2, 0, 0), limousineChrysler); // 6 uur erna m.AddBusinessReservation(customer, limousineExceptedAddress, locationStart, locationArrival, new DateTime(2020, 09, 22, 16, 0, 0), new DateTime(2020, 09, 22, 18, 0, 0), limousineChrysler); List <Limousine> limousines = m.GetAllAvailableLimousines(new DateTime(2020, 09, 22, 8, 0, 0), new DateTime(2020, 09, 22, 10, 0, 0), ArrangementType.NightLife); Assert.AreEqual(1, contextTest.Limousines.Local.Count); Assert.AreEqual(2, contextTest.Reservations.Local.Count); Assert.AreEqual(limousines.Count, 1); }
public void GetAllAvailableLimousines_LimousineNotAvailable_ShouldNotShow() { VipServicesContextTest contextTest = new VipServicesContextTest(keepExistingDB: false); VipServicesManager m = new VipServicesManager(new UnitOfWork(contextTest)); LimousineRepository limousineRepo = new LimousineRepository(contextTest); Address addressCustomer = new Address("Groenlaan", "17", "Herzele"); Address limousineExceptedAddress = new Address("Nieuwstraat", "5B", "Brussel"); Customer customer = new Customer("Jan", "", addressCustomer, CategoryType.particulier); Location locationStart = new Location("Gent"); Location locationArrival = new Location("Brussel"); DateTime startTime = new DateTime(2020, 09, 22, 20, 0, 0); DateTime endTime = new DateTime(2020, 09, 23, 3, 0, 0); //Niet beschikbaar - al gereserveerd m.AddLimousine("Chrysler", "300C Limousine", "White", 175, 800, 500, 1000); Limousine limousineChrysler = limousineRepo.Find(1); m.AddNightLifeReservation(customer, limousineExceptedAddress, locationStart, locationArrival, startTime, endTime, limousineChrysler); List <Limousine> limousines = m.GetAllAvailableLimousines(startTime, endTime, ArrangementType.NightLife); Assert.AreEqual(1, contextTest.Limousines.Local.Count); Assert.AreEqual(1, contextTest.Reservations.Local.Count); Assert.AreEqual(limousines.Count, 0); }
public PriceCalculation(Arrangement arrangement, Limousine limousine, Client client, DateTime reservationDateStart, DateTime reservationDateEnd) { Hours = arrangement.GetHours(reservationDateStart, reservationDateEnd, limousine.FirstHourPrice); Subtotal = (int)arrangement.Price; ChargedDiscounts = CalculateChargedDiscounts(Subtotal, client); TotalExclusiveVAT = Subtotal - ChargedDiscounts; VATAmount = TotalExclusiveVAT * (Decimal)vatPercentage; Total = TotalExclusiveVAT + VATAmount; }
/// <summary> /// Calculates all prices. /// </summary> /// <param name="client">The client that reserved the limousine.</param> /// <param name="extraHours">Amount of extra hours added to the duration of the arangement (if applicable).</param> /// <param name="startHour">When the arangement starts (if applicable).</param> /// <param name="endHour">When the arangement ends (if applicable).</param> public void CalculatePrices(Client client, int?extraHours = null, TimeSpan?startHour = null, TimeSpan?endHour = null) { var result = Limousine.PriceForArangement(DateLimousineNeeded, Arangement, extraHours, startHour, endHour); Hours = result.Value; SubTotal = result.Key; UsedDiscount = client.GetDiscount(); AmountWithoutBtw = (int)(SubTotal - (SubTotal * (UsedDiscount / 100.0f))); BtwAmount = (int)(AmountWithoutBtw * (BtwPercentage / 100.0f)); ToPayAmount = AmountWithoutBtw + BtwAmount; }
public void TestReservationDetailsDatesNotHoursOnly() { Limousine limoTest = new Limousine("FIAT 500", 100, new List <Arrangement>() { }); DateTime reservationDateStart = new DateTime(2012, 01, 23, 12, 15, 00); DateTime reservationDateEnd = new DateTime(2012, 01, 23, 18, 00, 00); Arrangement arrangement = new HourlyArrangement(100, HourlyArrangementType.Airport, reservationDateStart, reservationDateEnd); Action a = () => new ReservationDetails(reservationDateStart, reservationDateEnd, Location.Gent, Location.Brussel, limoTest, arrangement); a.ShouldThrow <ArgumentException>().Message.ShouldBe("Reservatiedatums mogen enkel uren bevatten."); }
public void CarPriceUpdated_WhenISelectEngineAndGearbox() { // Given Car car = new Limousine(); // When car = new DieselEngine(car); car = new AutomaticGearbox(car); // Then Assert.Equal(114200, car.GetCost()); }
private static void Main(string[] args) { Console.WriteLine("Bridge Mode Demo"); var limousine = new Limousine(new GasEngine()); var bus = new Bus(new DieselEngine()); limousine.Start(); limousine.Stop(); bus.Start(); bus.Stop(); }
/// <summary> /// Deze method berekent de netto prijs voor het Wedding arrangement /// </summary> public static Price WeddingPriceCalculator(Limousine limousine, TimeSpan totalHours, DateTime startTime, DateTime endTime, double discountPercentage) { Price price = new Price(); //Wedding is minstens 7uur en heeft een vaste prijs, stel de vaste prijs in voor de gekozen limo price.FixedPrice = limousine.WeddingPrice; //Indien het totale uur groter is dan 7, stel de eerste uur prijs in if (totalHours.Hours > 7) { price.FirstHourPrice = limousine.FirstHourPrice; //Indien het totale uur groter is dan 8, bereken de nachtprijs en de overuren if (totalHours.Hours > 8) { //Trek 8 uur af van de totale tijd en tel 8 uur op bij het start uur voor een juiste uur berekening later in de code TimeSpan eightHours = new TimeSpan(8, 0, 0); totalHours = totalHours - eightHours; DateTime startTimeMinusStartHour = startTime + eightHours; //Bereken het aantal nachturen price.NightHourCount = CalculateNightHours(totalHours, startTimeMinusStartHour, endTime); //Bereken op basis van het aantal nachturen, de nacht prijs in totaal, afgerond op 5 price.NightHourPrice = Math.Round(((double)(price.NightHourPercentage / 100.0) * ((double)price.NightHourCount * (double)limousine.FirstHourPrice)) / 5) * 5; if ((totalHours.Hours - price.NightHourCount) > 0) { //Bereken het aantal over uren uren minus het aantal nacht uren price.OvertimeCount = totalHours.Hours - price.NightHourCount; //Bereken op basis van het aantal ove uren, de overuur prijs in het totaal, afgerond op 5 price.OvertimePrice = Math.Round(((double)(price.SecondHourPercentage / 100.0) * ((double)price.OvertimeCount * (double)limousine.FirstHourPrice)) / 5) * 5; } //Stel totaaluur terug correct in totalHours = totalHours + eightHours; } } //Bereken de subtotaalprijs op basis van de vorige bedragen price.SubTotal = price.FixedPrice + price.FirstHourPrice + price.NightHourPrice + price.OvertimePrice; //Stel de staffelkorting in price.StaffelDiscount = discountPercentage; //Bereken de totaalprijs in een algemene method TotalPriceCalculator(price); return(price); }
public void WeddingArrangementDuurtAltijdMinstens7Uur_ZouIncorrecteParameterExceptionMoetenGeven() { Klant klant = new Klant(); Limousine limo = new Limousine(); DateTime startDatum = new DateTime(2100, 12, 31, 1, 0, 0); Arrengement arrengement = Arrengement.Wedding; int startUur = 22; int duur = 6; StalLocatie stalLocatie = StalLocatie.Antwerpen; StalLocatie eindLocatie = StalLocatie.Gent; string verwachtAdres = "testAdres1 25 testGemeente"; Reservatie res = new Reservatie(klant, startDatum, arrengement, startUur, duur, limo, DateTime.Now, stalLocatie, eindLocatie, verwachtAdres, 0); }
public void NightlifeArrangementMagNietVroegerDan20UurBeginnen_ZouIncorrecteParameterExceptionMoetenGeven() { Klant klant = new Klant(); Limousine limo = new Limousine(); DateTime startDatum = new DateTime(2100, 12, 31, 1, 0, 0); Arrengement arrengement = Arrengement.NightLife; int startUur = 19; int duur = 7; StalLocatie stalLocatie = StalLocatie.Antwerpen; StalLocatie eindLocatie = StalLocatie.Gent; string verwachtAdres = "testAdres1 25 testGemeente"; Reservatie res = new Reservatie(klant, startDatum, arrengement, startUur, duur, limo, DateTime.Now, stalLocatie, eindLocatie, verwachtAdres, 0); }
public void ReservatieAanmakenZonderDuur_ZouIncorrecteParameterExceptionMoetenGeven() { Klant klant = new Klant(); Limousine limo = new Limousine(); DateTime startDatum = new DateTime(2100, 12, 31, 1, 0, 0); Arrengement arrengement = Arrengement.NightLife; int startUur = -1; int duur = 0; StalLocatie stalLocatie = StalLocatie.Antwerpen; StalLocatie eindLocatie = StalLocatie.Gent; string verwachtAdres = "testAdres1 25 testGemeente"; Reservatie res = new Reservatie(klant, startDatum, arrengement, startUur, duur, limo, DateTime.Now, stalLocatie, eindLocatie, verwachtAdres, 0); }
public void TestReservationDetailsLimousineNotReady() { Limousine limoTest = new Limousine("FIAT 500", 100, new List <Arrangement>() { }); DateTime reservationDateStart = new DateTime(2012, 01, 23, 12, 00, 00); DateTime reservationDateEnd = new DateTime(2012, 01, 23, 18, 00, 00); Arrangement arrangement = new HourlyArrangement(100, HourlyArrangementType.Airport, reservationDateStart, reservationDateEnd); ReservationDetails detailsTest = new ReservationDetails(reservationDateStart, reservationDateEnd, Location.Gent, Location.Brussel, limoTest, arrangement); DateTime reservationDateStartNext = new DateTime(2012, 01, 23, 20, 00, 00); DateTime reservationDateEndNext = new DateTime(2012, 01, 24, 5, 00, 00); Action a = () => new ReservationDetails(reservationDateStartNext, reservationDateEndNext, Location.Charleroi, Location.Brussel, limoTest, arrangement); a.ShouldThrow <ArgumentException>().Message.ShouldBe("Tussen 2 reservaties moet er minstens 6 uur verschil zijn."); }
/// <summary> /// Deze method berekent de netto prijs voor het Welness arrangement /// </summary> public static Price WelnessPriceCalculator(Limousine limousine, TimeSpan totalHours, DateTime startTime, DateTime endTime, double discountPercentage) { Price price = new Price(); //Welness is een arrangement met een vaste 10 uur, stel de welness prijs in als subtotaal want het kan geen nachturen ect,.. hebben price.FixedPrice = limousine.WelnessPrice; price.SubTotal = price.FixedPrice; //Stel de staffelkorting in price.StaffelDiscount = discountPercentage; //Bereken de totaalprijs in een algemene method TotalPriceCalculator(price); return(price); }
public void TestRudyManagerAddReservationLimousineNotInDatabase() { UnitOfWork uow = new UnitOfWork(new VIPServicesRudyTestContext(true)); VIPServicesRudyManager m = new VIPServicesRudyManager(uow); DateTime reservationDateStart = new DateTime(2020, 01, 23, 15, 00, 00); DateTime reservationDateEnd = new DateTime(2020, 01, 23, 18, 00, 00); Limousine limoTest = new Limousine("FIAT 500", 100, new List <Arrangement>() { }); Client clientTest = uow.Clients.GetClient(3); Arrangement arrangement = new HourlyArrangement(100, HourlyArrangementType.Airport, reservationDateStart, reservationDateEnd); Reservation test = new Reservation("Kerkstraat 45", clientTest, new ReservationDetails(reservationDateStart, reservationDateEnd, Location.Gent, Location.Brussel, limoTest, arrangement)); Action act = () => m.AddReservation(test); act.ShouldThrow <ArgumentException>().Message.ShouldBe("Limousine zit nog niet in databank gelieve Limousine eerst toe te voegen."); }
public void TestRudyManagerAddReservation() { UnitOfWork uow = new UnitOfWork(new VIPServicesRudyTestContext(false)); VIPServicesRudyManager m = new VIPServicesRudyManager(uow); Parser.InitTestDatabase(uow); DateTime reservationDateStart = new DateTime(2020, 01, 23, 15, 00, 00); DateTime reservationDateEnd = new DateTime(2020, 01, 23, 18, 00, 00); Limousine limoTest = uow.Limousines.GetLimousine(2); Client clientTest = uow.Clients.GetClient(2); Arrangement arrangement = new HourlyArrangement(100, HourlyArrangementType.Airport, reservationDateStart, reservationDateEnd); Reservation test = new Reservation("Kerkstraat 45", clientTest, new ReservationDetails(reservationDateStart, reservationDateEnd, Location.Gent, Location.Brussel, limoTest, arrangement)); m.AddReservation(test); uow.Reservations.InDatabase(test).ShouldBeTrue(); }
public void GetReservation_ShouldWork() { VipServicesContextTest contextTest = new VipServicesContextTest(keepExistingDB: false); VipServicesManager m = new VipServicesManager(new UnitOfWork(contextTest)); LimousineRepository limousineRepo = new LimousineRepository(contextTest); Address addressCustomer = new Address("Groenlaan", "17", "Herzele"); Address limousineExceptedAddress = new Address("Nieuwstraat", "5B", "Brussel"); Customer customer = new Customer("Jan", "", addressCustomer, CategoryType.particulier); Location locationStart = new Location("Gent"); Location locationArrival = new Location("Brussel"); DateTime startTime = new DateTime(2020, 09, 22, 8, 0, 0); DateTime endTime = new DateTime(2020, 09, 22, 18, 0, 0); TimeSpan totalHours = endTime - startTime; m.AddLimousine("Tesla", "Model X", "White", 600, 1500, 2500, 2700); Limousine limousine = limousineRepo.Find(1); double discountPercentage = m.CalculateStaffel(customer); Price price = PriceCalculator.WeddingPriceCalculator (limousine, totalHours, startTime, endTime, discountPercentage); Reservation weddingReservation = new Reservation(customer, DateTime.Now, limousineExceptedAddress, locationStart, locationArrival, ArrangementType.Wedding, startTime, endTime, totalHours, limousine, price); m.AddWeddingReservation(customer, limousineExceptedAddress, locationStart, locationArrival, startTime, endTime, limousine); Action act = () => { m.GetReservation(1); }; act.Should().NotThrow <Exception>(); Assert.AreEqual(1, contextTest.Reservations.Local.Count); var reservationInDb = m.GetReservation(1); Assert.AreEqual(reservationInDb.Customer, weddingReservation.Customer); Assert.AreEqual(reservationInDb.LimousineExpectedAddress, weddingReservation.LimousineExpectedAddress); Assert.AreEqual(reservationInDb.StartLocation, weddingReservation.StartLocation); Assert.AreEqual(reservationInDb.ArrivalLocation, weddingReservation.ArrivalLocation); Assert.AreEqual(reservationInDb.ArrangementType, weddingReservation.ArrangementType); Assert.AreEqual(reservationInDb.StartTime, weddingReservation.StartTime); Assert.AreEqual(reservationInDb.EndTime, weddingReservation.EndTime); Assert.AreEqual(reservationInDb.TotalHours, weddingReservation.TotalHours); Assert.AreEqual(reservationInDb.Limousine, weddingReservation.Limousine); Assert.AreEqual(reservationInDb.Price.Total, weddingReservation.Price.Total); }
public void AddLimousineTests() { ManagerContextTest mct = new ManagerContextTest(true); ServiceManager sm = new ServiceManager(new UnitOfWork(mct)); List <Arangement> arangements = new List <Arangement>(); arangements.Add(new Business()); arangements.Add(new Wellness(3000)); arangements.Add(new Airport()); Limousine l1 = new Limousine(200, "test1", 3, arangements); Action act = () => sm.AddVehicle(l1); act.Should().NotThrow <Exception>(); arangements = new List <Arangement>(); arangements.Add(new Business()); arangements.Add(new Wellness(1020)); arangements.Add(new Airport()); arangements.Add(new Wedding(3050)); Limousine l2 = new Limousine(150, "test2", 1, arangements); arangements = new List <Arangement>(); arangements.Add(new Business()); arangements.Add(new Wellness(3500)); arangements.Add(new Airport()); arangements.Add(new Wedding(9000)); Limousine l3 = new Limousine(210, "test3", 4, arangements); arangements = new List <Arangement>(); arangements.Add(new Business()); arangements.Add(new Wellness(3500)); arangements.Add(new Airport()); arangements.Add(new Wedding(2000)); arangements.Add(new Nightlife(3210)); Limousine l4 = new Limousine(290, "test4", 7, arangements); List <Limousine> ls = new List <Limousine>() { l2, l3, l4 }; act = () => sm.AddVehicles(ls); act.Should().NotThrow <Exception>(); }
/// <summary> /// A constructor that makes a Details object. /// </summary> /// <param name="startLocation">Location where the limousine picks up the client.</param> /// <param name="endLocation">Location where the limousine drops the client off.</param> /// <param name="limousine">The limousine that was hired.</param> /// <param name="dateLimousineNeeded">The date the limousine is hired.</param> /// <param name="arangement">The arangement used.</param> public Details(Address startLocation, Address endLocation, Limousine limousine, DateTime dateLimousineNeeded, string arangement) { if (!Reservering.LocationAllowed(startLocation)) { throw new DomainException("Start locatie van de limousine beschikbaar in volgende locaties: Antwerpen, Gent, Brussel, Hasselt en Charleroi."); } if (!Reservering.LocationAllowed(endLocation)) { throw new DomainException("Eind locatie van de limousine beschikbaar in volgende locaties: Antwerpen, Gent, Brussel, Hasselt en Charleroi."); } StartLocation = startLocation; EndLocation = endLocation; Limousine = limousine; DateLimousineNeeded = dateLimousineNeeded; Arangement = arangement; BtwPercentage = 6.0f; }
public void LimoToevoegenAccepteertGemengdeNullWaarden_Test() { ReservatieManager rm = new ReservatieManager(new TestDataBaseHandler()); string naam = "testLimo1"; int uurPrijs = 150; int?nightlifePrijs1 = 1234; int?weddingPrijs2 = null; int?wellnessPrijs3 = null; rm.VoegLimousineToe(naam, uurPrijs, nightlifePrijs1, weddingPrijs2, wellnessPrijs3); Limousine testLimo = rm.VindLimousineVoorId(1); Assert.IsTrue(testLimo.Naam == naam, "Naam van de Limo is niet correct toegevoegd"); Assert.IsTrue(testLimo.EersteUurPrijs == uurPrijs, $"Eerste uur prijs van {testLimo.Naam} is niet correct toegevoegd"); Assert.IsTrue(testLimo.NightlifePrijs == nightlifePrijs1, $"Nightlife prijs van {testLimo.Naam} is niet null"); Assert.IsTrue(testLimo.WeddingPrijs == null, $"Wedding prijs van {testLimo.Naam} is niet null"); Assert.IsTrue(testLimo.WellnessPrijs == null, $"Wellness prijs van {testLimo.Naam} is niet null"); nightlifePrijs1 = null; weddingPrijs2 = 9876; wellnessPrijs3 = null; rm.VoegLimousineToe(naam, uurPrijs, nightlifePrijs1, weddingPrijs2, wellnessPrijs3); testLimo = rm.VindLimousineVoorId(2); Assert.IsTrue(testLimo.Naam == naam, "Naam van de Limo is niet correct toegevoegd"); Assert.IsTrue(testLimo.EersteUurPrijs == uurPrijs, $"Eerste uur prijs van {testLimo.Naam} is niet correct toegevoegd"); Assert.IsTrue(testLimo.NightlifePrijs == null, $"Nightlife prijs van {testLimo.Naam} is niet null"); Assert.IsTrue(testLimo.WeddingPrijs == weddingPrijs2, $"Wedding prijs van {testLimo.Naam} is niet null"); Assert.IsTrue(testLimo.WellnessPrijs == null, $"Wellness prijs van {testLimo.Naam} is niet null"); nightlifePrijs1 = null; weddingPrijs2 = null; wellnessPrijs3 = 5605; rm.VoegLimousineToe(naam, uurPrijs, nightlifePrijs1, weddingPrijs2, wellnessPrijs3); testLimo = rm.VindLimousineVoorId(3); Assert.IsTrue(testLimo.Naam == naam, "Naam van de Limo is niet correct toegevoegd"); Assert.IsTrue(testLimo.EersteUurPrijs == uurPrijs, $"Eerste uur prijs van {testLimo.Naam} is niet correct toegevoegd"); Assert.IsTrue(testLimo.NightlifePrijs == null, $"Nightlife prijs van {testLimo.Naam} is niet null"); Assert.IsTrue(testLimo.WeddingPrijs == null, $"Wedding prijs van {testLimo.Naam} is niet null"); Assert.IsTrue(testLimo.WellnessPrijs == wellnessPrijs3, $"Wellness prijs van {testLimo.Naam} is niet null"); }
public ReservationDetails(DateTime reservationDateStart, DateTime reservationDateEnd, Location startLocation, Location arrivalLocation, Limousine limousine, Arrangement arrangement) { if (!limousine.IsReservable(reservationDateStart)) { throw new ArgumentException("Tussen 2 reservaties moet er minstens 6 uur verschil zijn."); } if (reservationDateStart.Minute > 0 || reservationDateEnd.Minute > 0) { throw new ArgumentException("Reservatiedatums mogen enkel uren bevatten."); } ReservationDateStart = reservationDateStart; ReservationDateEnd = reservationDateEnd; StartLocation = startLocation; ArrivalLocation = arrivalLocation; limousine.LastReservation = reservationDateEnd; Limousine = limousine; Arrangement = arrangement; }