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 ReservationDetails(int reservationId) { InitializeComponent(); try { Reservation reservation = vipServicesManager.GetReservation(reservationId); txtCustomerNumber.Text = reservation.Customer.CustomerNumber.ToString(); txtCustomerName.Text = reservation.Customer.Name.ToString(); txtCustomerCategory.Text = reservation.Customer.Category.ToString(); if (reservation.Customer.BtwNumber == "") { txtCustomerBtwNumber.Text = "Geen"; } else { txtCustomerBtwNumber.Text = reservation.Customer.BtwNumber.ToString(); } txtCustomerAddress.Text = reservation.Customer.Address.ToString(); txtReservationCreated.Text = reservation.ReservationCreated.Date.ToLongDateString(); txtReservationId.Text = reservation.Id.ToString(); txtLimousineExpectedAddress.Text = reservation.LimousineExpectedAddress.ToString(); txtReservationStartLocation.Text = reservation.StartLocation.ToString(); txtReservationArrivalLocation.Text = reservation.ArrivalLocation.ToString(); txtReservationStartTime.Text = reservation.StartTime.ToLongDateString() + " " + reservation.StartTime.ToShortTimeString(); txtReservationEndTime.Text = reservation.EndTime.ToLongDateString() + " " + reservation.EndTime.ToShortTimeString(); txtLimousineArrangementType.Text = reservation.ArrangementType.ToString(); txtLimousineBrand.Text = reservation.Limousine.Brand.ToString(); txtLimousineModel.Text = reservation.Limousine.Model.ToString(); txtLimousineNumber.Text = reservation.Limousine.Id.ToString(); txtLimousineColor.Text = reservation.Limousine.Color.ToString(); txtFirstHourPrice.Text = "\u20AC" + reservation.Price.FirstHourPrice.ToString(); txtSecondHourCount.Text = reservation.Price.SecondHourCount.ToString() + "x = "; txtSecondHourPrice.Text = "\u20AC" + Math.Round(reservation.Price.SecondHourPrice, 2).ToString(); txtOvertimeCount.Text = reservation.Price.OvertimeCount.ToString() + "x = "; txtOvertimePrice.Text = "\u20AC" + Math.Round(reservation.Price.OvertimePrice, 2).ToString(); txtNightHourCount.Text = reservation.Price.NightHourCount.ToString() + "x = "; txtNightHourPrice.Text = "\u20AC" + Math.Round(reservation.Price.NightHourPrice, 2).ToString(); txtFixedPrice.Text = "\u20AC" + reservation.Price.FixedPrice.ToString(); txtSubTotal.Text = "\u20AC" + Math.Round(reservation.Price.SubTotal, 2).ToString(); txtExclusiveBtw.Text = "\u20AC" + Math.Round(reservation.Price.ExclusiveBtw, 2).ToString(); txtStaffelDiscount.Text = reservation.Price.StaffelDiscount.ToString() + "%"; txtBtw.Text = reservation.Price.Btw.ToString() + "%"; txtBtwPrice.Text = "\u20AC" + Math.Round(reservation.Price.BtwPrice, 2).ToString(); txtTotal.Text = "\u20AC" + Math.Round(reservation.Price.Total, 2).ToString(); } catch (Exception ex) { MessageBox.Show("Fout: " + ex.Message, "Exception Sample", MessageBoxButton.OK, MessageBoxImage.Warning); } }