示例#1
0
        public void TestRentalManagerRemoveInvoice()
        {
            // Pre-setup
            RentalManager manager = new RentalManager(new UnitOfWork(new RentalContext("development")));

            manager.AddClient("Tim", "De Smet", "*****@*****.**", "0493100289", "Azaleastraat", "57", "", "9940", "Evergem", "Belgium", ClientType.AGENCY, "Jetstax", "BE0730.671.009");
            Assert.AreNotEqual(manager.GetAllClients().Count, 0);
            Client client = manager.GetAllClients().Last();

            manager.AddCar("Porsche", "Cayenne Limousine", "White", 310, 1500, 1200, 1600, true);
            Assert.AreNotEqual(manager.GetAllCars().Count, 0);
            Car car = manager.GetAllCars().Last();

            manager.AddReservation(client, ReservationArrangementType.AIRPORT, new DateTime(2020, 8, 20, 10, 0, 0), new DateTime(2020, 8, 20, 13, 0, 0), "Gent", "Gent", new List <Car>()
            {
                car
            }, DateTime.Now, 6.0);

            // Setup
            Assert.AreNotEqual(manager.GetAllReservations().Count, 0);
            Reservation reservation = manager.GetAllReservations().Last();
            int         count       = manager.GetAllReservations().Count;

            manager.RemoveReservation(reservation);

            // Check
            Assert.AreEqual(manager.GetAllReservations().Count, count - 1);
        }
示例#2
0
        public void TestRentalManagerAddInvoice()
        {
            // Pre-setup
            RentalManager manager = new RentalManager(new UnitOfWork(new RentalContext("development")));

            manager.AddClient("Tim", "De Smet", "*****@*****.**", "0493100289", "Azaleastraat", "57", "", "9940", "Evergem", "Belgium", ClientType.AGENCY, "Jetstax", "BE0730.671.009");
            Assert.AreNotEqual(manager.GetAllClients().Count, 0);
            Client client = manager.GetAllClients().Last();

            manager.AddCar("Porsche", "Cayenne Limousine", "White", 310, 1500, 1200, 1600, true);
            Assert.AreNotEqual(manager.GetAllCars().Count, 0);
            Car car = manager.GetAllCars().Last();

            // Setup
            manager.AddInvoice(client, ReservationArrangementType.AIRPORT, new DateTime(2020, 8, 20, 10, 0, 0), new DateTime(2020, 8, 20, 13, 0, 0), new List <Car>()
            {
                car
            }, 6.0);

            // Check
            Invoice            invoice      = manager.GetAllInvoices().Last();
            List <InvoiceItem> invoiceItems = manager.GetInvoiceItems(invoice.ID);

            Assert.AreEqual(invoice.ClientID, client.ID);
            Assert.AreEqual(invoice.DiscountPercent, 0);
            Assert.AreEqual(invoice.Discount, 0);
            Assert.AreEqual(invoice.VATPercent, 6.0);
            Assert.AreEqual(invoice.VAT, 42.9);
            Assert.AreEqual(invoice.SubTotal, 715);
            Assert.AreEqual(invoice.TotalExc, 715);
            Assert.AreEqual(invoice.TotalInc, 757.9);
            Assert.AreEqual(invoice.PaymentDue, 757.9);
            Assert.AreEqual(invoiceItems.Count, 1);
        }
        public void TestCarGetPrice()
        {
            // Setup
            RentalManager manager = new RentalManager(new UnitOfWork(new RentalContext("development")));

            manager.AddCar("Porsche", "Cayenne Limousine", "White", 310, 1500, 1200, 1600, true);

            // Check
            Assert.AreNotEqual(manager.GetAllCars().Count, 0);
            Car car = manager.GetAllCars().Last();

            Assert.AreEqual(car.GetPrice(new DateTime(2020, 8, 20, 10, 0, 0), new DateTime(2020, 8, 20, 13, 0, 0), ReservationArrangementType.AIRPORT), 715);
        }
示例#4
0
        public void TestRentalManagerRemoveClient()
        {
            // Pre-setup
            RentalManager manager = new RentalManager(new UnitOfWork(new RentalContext("development")));

            manager.AddCar("Porsche", "Cayenne Limousine", "White", 310, 1500, 1200, 1600, true);

            // Setup
            Assert.AreNotEqual(manager.GetAllClients().Count, 0);
            Client client = manager.GetAllClients().Last();
            int    count  = manager.GetAllClients().Count;

            manager.RemoveClient(client);

            // Check
            Assert.AreEqual(manager.GetAllClients().Count, count - 1);
        }
        public void TestRentalManagerAddCar()
        {
            // Setup
            RentalManager manager = new RentalManager(new UnitOfWork(new RentalContext("development")));

            manager.AddCar("Porsche", "Cayenne Limousine", "White", 310, 1500, 1200, 1600, true);

            // Check
            Assert.AreNotEqual(manager.GetAllCars().Count, 0);
            Car car = manager.GetAllCars().Last();

            Assert.AreEqual(car.Brand, "Porsche");
            Assert.AreEqual(car.Type, "Cayenne Limousine");
            Assert.AreEqual(car.Color, "White");
            Assert.AreEqual(car.PriceFirst, 310);
            Assert.AreEqual(car.PriceNight, 1500);
            Assert.AreEqual(car.PriceWedding, 1200);
            Assert.AreEqual(car.PriceWellness, 1600);
            Assert.AreEqual(car.Available, true);
        }
示例#6
0
        private void Submit_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            String  brand         = newBrand.Text;
            String  type          = newType.Text;
            Double  priceFirst    = newPriceFirst.Value;
            Double  priceNight    = newPriceNight.Value;
            Double  priceWedding  = newPriceWedding.Value;
            Double  priceWellness = newPriceWellness.Value;
            Boolean available     = newAvailable.IsOn;

            if (string.IsNullOrWhiteSpace(brand) || string.IsNullOrWhiteSpace(type))
            {
                MainWindow.DisplayThrowbackDialog("Car Creation Error", "Brand and model are required fields and must be filled in"); return;
            }
            if (newColor.SelectedIndex < 0)
            {
                MainWindow.DisplayThrowbackDialog("Car Creation Error", "You must select a car color"); return;
            }
            String color = typeof(Color).GetProperties()[newColor.SelectedIndex].Name;

            if (priceFirst < 0 || priceNight < 0 || priceWedding < 0 || priceWellness < 0)
            {
                MainWindow.DisplayThrowbackDialog("Car Creation Error", "All prices must be 0 or higher"); return;
            }

            try
            {
                RentalManager manager = new RentalManager(new UnitOfWork(new RentalContext()));
                manager.AddCar(brand, type, color, priceFirst, priceNight, priceWedding, priceWellness, available);
                MainWindow.DisplayThrowbackDialog("Successfull", "The car has been added to the list");
            }
            catch (Exception error)
            {
                MainWindow.DisplayThrowbackDialog("An internal error occurred", error.Message);
                return;
            }
        }