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);
        }
예제 #2
0
        public void AddWeddingReservation_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, 10, 0, 0);
            DateTime endTime         = new DateTime(2020, 09, 22, 20, 0, 0);
            TimeSpan totalHours      = endTime - startTime;

            m.AddLimousine("Tesla", "Model X", "White", 600, 1500, 2500, 2700);
            Limousine limousine = limousineRepo.Find(1);

            m.AddWeddingReservation(customer, limousineExceptedAddress, locationStart, locationArrival,
                                    startTime, endTime, limousine);

            Action act = () =>
            {
                m.AddWeddingReservation(customer, limousineExceptedAddress, locationStart, locationArrival,
                                        startTime, endTime, limousine);
            };

            act.Should().Throw <DomainException>().WithMessage("Limousine is niet beschikbaar.");
        }
예제 #3
0
        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.");
            }
        }
예제 #4
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);
        }
예제 #5
0
        public void GetAllReservations_CustomerId_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);
            Customer customer2       = new Customer("Piet", "", addressCustomer, CategoryType.concertpromotor);
            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);

            m.AddLimousine("Tesla", "Model X", "White", 600, 1500, 2500, 2700);

            //2 reservaties door dezelfde klant
            Limousine limousine1 = limousineRepo.Find(1);

            m.AddWeddingReservation(customer, limousineExceptedAddress, locationStart, locationArrival,
                                    startTime, endTime, limousine1);
            Limousine limousine2 = limousineRepo.Find(1);

            m.AddBusinessReservation(customer, limousineExceptedAddress, locationStart, locationArrival,
                                     new DateTime(2020, 09, 09, 1, 0, 0), new DateTime(2020, 09, 09, 9, 0, 0), limousine2);
            Limousine limousine3 = limousineRepo.Find(1);

            //1 reservatie door een andere klant
            m.AddBusinessReservation(customer2, limousineExceptedAddress, locationStart, locationArrival,
                                     new DateTime(2020, 09, 30, 1, 0, 0), new DateTime(2020, 09, 30, 9, 0, 0), limousine3);

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

            act.Should().NotThrow <Exception>();
            Assert.AreEqual(3, contextTest.Reservations.Local.Count);
            Assert.AreEqual(m.GetAllReservations(customer.CustomerNumber).Count, 2);
        }