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); }
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 TestRentalManagerAddClient() { // 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"); // Check Assert.AreNotEqual(manager.GetAllClients().Count, 0); Client client = manager.GetAllClients().Last(); Assert.AreEqual(client.FirstName, "Tim"); Assert.AreEqual(client.LastName, "De Smet"); Assert.AreEqual(client.Email, "*****@*****.**"); Assert.AreEqual(client.Phone, "0493100289"); Assert.AreEqual(client.AddressStreet, "Azaleastraat"); Assert.AreEqual(client.AddressNumber, "57"); Assert.AreEqual(client.AddressBus, ""); Assert.AreEqual(client.AddressZip, "9940"); Assert.AreEqual(client.AddressCity, "Evergem"); Assert.AreEqual(client.AddressCounty, "Belgium"); Assert.AreEqual(client.Type, ClientType.AGENCY); Assert.AreEqual(client.CompanyName, "Jetstax"); Assert.AreEqual(client.VATNumber, "BE0730.671.009"); }
private void Submit_Click(object sender, RoutedEventArgs e) { string firstName = inFirstName.Text; string lastName = inLastName.Text; string email = inEmail.Text; string phone = inPhone.Text; string addrStreet = inAddrStreet.Text; string addrNumber = inAddrNumber.Text; string addrBox = inAddrBox.Text; string addrZip = inAddrZip.Text; string addrCity = inAddrCity.Text; string addrCountry = ""; string company = inCompany.Text; string vat = inVAT.Text; if (inAddrCountry.SelectedIndex >= 0) { addrCountry = inAddrCountry.SelectedItem.ToString().Split(new string[] { ": " }, StringSplitOptions.None).Last(); } if (string.IsNullOrWhiteSpace(firstName) || string.IsNullOrWhiteSpace(lastName)) { DisplayThrowbackDialog("You must fill in a first and list name"); return; } if (inAccountType.SelectedIndex < 0) { DisplayThrowbackDialog("You must select an account type"); return; } if (!Enum.TryParse(typeof(ClientType), inAccountType.SelectedItem.ToString().ToUpper().Split(new string[] { ": " }, StringSplitOptions.None).Last(), out object objtype)) { DisplayThrowbackDialog("Something went wrong with the client type, try agian"); return; } ClientType type = (ClientType)objtype; if (type != ClientType.PRIVATE && type != ClientType.VIP) { if (string.IsNullOrWhiteSpace(vat)) { DisplayThrowbackDialog("VAT number must be filled in for that account type"); return; } } try { RentalManager manager = new RentalManager(new UnitOfWork(new RentalContext())); manager.AddClient(firstName, lastName, email, phone, addrStreet, addrNumber, addrBox, addrZip, addrCity, addrCountry, type, company, vat); MailService.Send_WelcomeMail(email, firstName, lastName, type, phone, company); // Send welcome mail DisplayThrowbackDialog("New client has been added"); } catch (Exception error) { DisplayThrowbackDialog(error.Message); return; } }
public void TestRentalManagerClientGetDiscount() { // Setup RentalManager manager = new RentalManager(new UnitOfWork(new RentalContext("development"))); manager.AddClient("Tim", "De Smet", "*****@*****.**", "0493100289", "Azaleastraat", "57", "", "9940", "Evergem", "Belgium", ClientType.PLANNER, "Jetstax", "BE0730.671.009"); // Check Assert.AreNotEqual(manager.GetAllClients().Count, 0); Client client = manager.GetAllClients().Last(); Assert.AreEqual(client.GetDiscount(0), 0); Assert.AreEqual(client.GetDiscount(4), 0); Assert.AreEqual(client.GetDiscount(5), 7.5); Assert.AreEqual(client.GetDiscount(8), 7.5); Assert.AreEqual(client.GetDiscount(10), 10); Assert.AreEqual(client.GetDiscount(11), 10); Assert.AreEqual(client.GetDiscount(15), 12.5); Assert.AreEqual(client.GetDiscount(18), 12.5); Assert.AreEqual(client.GetDiscount(20), 15); Assert.AreEqual(client.GetDiscount(24), 15); Assert.AreEqual(client.GetDiscount(25), 25); Assert.AreEqual(client.GetDiscount(35), 25); }