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 CalculateStaffel_None_ShouldBeCorrect()
        {
            VipServicesContextTest contextTest = new VipServicesContextTest(keepExistingDB: false);
            VipServicesManager     m           = new VipServicesManager(new UnitOfWork(contextTest));

            Address  address  = new Address("Groenlaan", "17", "Herzele");
            Customer customer = new Customer("Jan", "BE0502358347", address, CategoryType.geen);

            Action act = () =>
            {
                m.CalculateStaffel(customer);
            };

            act.Should().NotThrow <Exception>();
            Assert.AreEqual(m.CalculateStaffel(customer), 0);
        }
        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);
        }
Example #4
0
        private void CalculatePrice()
        {
            try
            {
                DateTime startDate = new DateTime(dtpStartDate.SelectedDate.Value.Year,
                                                  dtpStartDate.SelectedDate.Value.Month, dtpStartDate.SelectedDate.Value.Day,
                                                  (int)cmbStartTime.SelectedItem, 0, 0);
                DateTime endDate = new DateTime(dtpEndDate.SelectedDate.Value.Year,
                                                dtpEndDate.SelectedDate.Value.Month, dtpEndDate.SelectedDate.Value.Day,
                                                (int)cmbEndTime.SelectedItem, 0, 0);

                TimeSpan totalHours = endDate - startDate;

                Price price = new Price();

                double discountPercentage
                    = vipServicesManager.CalculateStaffel((Customer)cmbCustomer.SelectedItem);

                if (cmbArrangement.SelectedItem.Equals(ArrangementType.NightLife))
                {
                    price = PriceCalculator.NightlifePriceCalculator((Limousine)cmbLimousine.SelectedItem, totalHours,
                                                                     startDate, endDate, discountPercentage);
                }
                if (cmbArrangement.SelectedItem.Equals(ArrangementType.Wedding))
                {
                    price = PriceCalculator.WeddingPriceCalculator((Limousine)cmbLimousine.SelectedItem, totalHours,
                                                                   startDate, endDate, discountPercentage);
                }
                if (cmbArrangement.SelectedItem.Equals(ArrangementType.Wellness))
                {
                    price = PriceCalculator.WelnessPriceCalculator((Limousine)cmbLimousine.SelectedItem, totalHours,
                                                                   startDate, endDate, discountPercentage);
                }
                if (cmbArrangement.SelectedItem.Equals(ArrangementType.Business))
                {
                    price = PriceCalculator.PerHourPriceCalculator((Limousine)cmbLimousine.SelectedItem, totalHours,
                                                                   startDate, endDate, discountPercentage);
                }
                if (cmbArrangement.SelectedItem.Equals(ArrangementType.Airport))
                {
                    price = PriceCalculator.PerHourPriceCalculator((Limousine)cmbLimousine.SelectedItem, totalHours,
                                                                   startDate, endDate, discountPercentage);
                }

                txtFirstHourPrice.Text  = "\u20AC" + price.FirstHourPrice.ToString();
                txtSecondHourCount.Text = price.SecondHourCount.ToString() + "x  = ";
                txtSecondHourPrice.Text = "\u20AC" + Math.Round(price.SecondHourPrice, 2).ToString();
                txtOvertimeCount.Text   = price.OvertimeCount.ToString() + "x  = ";
                txtOvertimePrice.Text   = "\u20AC" + Math.Round(price.OvertimePrice, 2).ToString();
                txtNightHourCount.Text  = price.NightHourCount.ToString() + "x  = ";
                txtNightHourPrice.Text  = "\u20AC" + Math.Round(price.NightHourPrice, 2).ToString();
                txtFixedPrice.Text      = "\u20AC" + price.FixedPrice.ToString();
                txtSubTotal.Text        = "\u20AC" + Math.Round(price.SubTotal, 2).ToString();
                txtExclusiveBtw.Text    = "\u20AC" + Math.Round(price.ExclusiveBtw, 2).ToString();
                txtStaffelDiscount.Text = price.StaffelDiscount.ToString() + "%";
                txtBtw.Text             = price.Btw.ToString() + "%";
                txtBtwPrice.Text        = "\u20AC" + Math.Round(price.BtwPrice, 2).ToString();
                txtTotal.Text           = "\u20AC" + Math.Round(price.Total, 2).ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Fout: " + ex.Message,
                                "Exception Sample", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }