public void AddWelnessReservation_WithNotAvailableLimousine_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, 22, 0, 0); TimeSpan totalHours = endTime - startTime; m.AddLimousine("Tesla", "Model X", "White", 600, 1500, 2500, 2700); Limousine limousine = limousineRepo.Find(1); m.AddWelnessReservation(customer, limousineExceptedAddress, locationStart, locationArrival, startTime, endTime, limousine); Action act = () => { m.AddWelnessReservation(customer, limousineExceptedAddress, locationStart, locationArrival, startTime, endTime, limousine); }; act.Should().Throw <DomainException>().WithMessage("Limousine is niet beschikbaar."); }
private void btnReservation_Click(object sender, RoutedEventArgs e) { if (cmbCustomer.SelectedItem != null && txtStreet.Text != String.Empty && txtNumber.Text != String.Empty && txtTown.Text != String.Empty && cmbArrangement.SelectedItem != null && dtpStartDate != null && dtpEndDate != null && cmbStartLocation.SelectedItem != null && cmbEndTime.SelectedItem != null && cmbStartTime != null && cmbEndTime != null && cmbLimousine != null) { try { Address address = new Address(txtStreet.Text, txtNumber.Text, txtTown.Text); DateTime startDate = GetStartDate(); DateTime endDate = GetEndDate(); if (cmbArrangement.SelectedItem.Equals(ArrangementType.NightLife)) { vipServicesManager.AddNightLifeReservation((Customer)cmbCustomer.SelectedItem, address, (Location)cmbStartLocation.SelectedItem, (Location)cmbArrivalLocation.SelectedItem, startDate, endDate, (Limousine)cmbLimousine.SelectedItem); } if (cmbArrangement.SelectedItem.Equals(ArrangementType.Wedding)) { vipServicesManager.AddWeddingReservation((Customer)cmbCustomer.SelectedItem, address, (Location)cmbStartLocation.SelectedItem, (Location)cmbArrivalLocation.SelectedItem, startDate, endDate, (Limousine)cmbLimousine.SelectedItem); } if (cmbArrangement.SelectedItem.Equals(ArrangementType.Wellness)) { vipServicesManager.AddWelnessReservation((Customer)cmbCustomer.SelectedItem, address, (Location)cmbStartLocation.SelectedItem, (Location)cmbArrivalLocation.SelectedItem, startDate, endDate, (Limousine)cmbLimousine.SelectedItem); } if (cmbArrangement.SelectedItem.Equals(ArrangementType.Business)) { vipServicesManager.AddBusinessReservation((Customer)cmbCustomer.SelectedItem, address, (Location)cmbStartLocation.SelectedItem, (Location)cmbArrivalLocation.SelectedItem, startDate, endDate, (Limousine)cmbLimousine.SelectedItem); } if (cmbArrangement.SelectedItem.Equals(ArrangementType.Airport)) { vipServicesManager.AddAirportReservation((Customer)cmbCustomer.SelectedItem, address, (Location)cmbStartLocation.SelectedItem, (Location)cmbArrivalLocation.SelectedItem, startDate, endDate, (Limousine)cmbLimousine.SelectedItem); } MessageBox.Show("Reservatie is succesvol toegevoegd!"); } catch (Exception ex) { MessageBox.Show("Fout: " + ex.Message, "Exception Sample", MessageBoxButton.OK, MessageBoxImage.Warning); } } else { MessageBox.Show("Gelieve alle velden in te vullen."); } }
public void AddWelnessReservation_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, 7, 0, 0); DateTime endTime = new DateTime(2020, 09, 22, 17, 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.WelnessPriceCalculator(limousine, totalHours, startTime, endTime, discountPercentage); Reservation welnessReservation = new Reservation(customer, DateTime.Now, limousineExceptedAddress, locationStart, locationArrival, ArrangementType.Wellness, startTime, endTime, totalHours, limousine, price); Action act = () => { m.AddWelnessReservation(customer, limousineExceptedAddress, locationStart, locationArrival, startTime, endTime, limousine); }; act.Should().NotThrow <DomainException>(); Assert.AreEqual(1, contextTest.Reservations.Local.Count); var reservationInDb = contextTest.Reservations.First(); Assert.AreEqual(reservationInDb.Customer, welnessReservation.Customer); Assert.AreEqual(reservationInDb.LimousineExpectedAddress, welnessReservation.LimousineExpectedAddress); Assert.AreEqual(reservationInDb.StartLocation, welnessReservation.StartLocation); Assert.AreEqual(reservationInDb.ArrivalLocation, welnessReservation.ArrivalLocation); Assert.AreEqual(reservationInDb.ArrangementType, welnessReservation.ArrangementType); Assert.AreEqual(reservationInDb.StartTime, welnessReservation.StartTime); Assert.AreEqual(reservationInDb.EndTime, welnessReservation.EndTime); Assert.AreEqual(reservationInDb.TotalHours, welnessReservation.TotalHours); Assert.AreEqual(reservationInDb.Limousine, welnessReservation.Limousine); Assert.AreEqual(reservationInDb.Price.Total, welnessReservation.Price.Total); }