public void CalculateFeesTest() { Campground campground = new Campground(); campground.DailyFee = 35.00M; decimal result = campground.CalculateFees(DateTime.Parse("05/10/2019"), DateTime.Parse("05/11/2019")); Assert.AreEqual(35, result); decimal result1 = campground.CalculateFees(DateTime.Parse("05/10/2019"), DateTime.Parse("05/20/2019")); Assert.AreEqual(350, result1); }
/// <summary> /// Takes inputs from the user to display a menu for available reservations parkwide to select from. /// </summary> /// <param name="park"></param> /// <param name="occupancy"></param> /// <param name="accessible"></param> /// <param name="rvLength"></param> /// <param name="utility"></param> /// <param name="arrivalDate"></param> /// <param name="departureDate"></param> private void SearchParkWideForAvailableReservationsMenu(Park park, int occupancy, bool accessible, int rvLength, bool utility, DateTime arrivalDate, DateTime departureDate) { const ConsoleKey MAKE_RESERVATION_KEY = ConsoleKey.D1; const ConsoleKey QUIT_KEY = ConsoleKey.Q; bool exit = false; while (!exit) { Console.Clear(); var sites = Npsd.GetAvailableSitesParkWide(park, occupancy, accessible, rvLength, utility, arrivalDate, departureDate); Console.WriteLine("Campground".PadRight(20) + "Site No.".PadRight(20) + "Max Occup.".PadRight(20) + "Accessible?".PadRight(20) + "Max RV Length".PadRight(20) + "Utility".PadRight(20) + "Cost"); foreach (var site in sites) { Campground camp = Npsd.GetCampgroundForSite(site.Value.SiteId); Console.WriteLine($"{camp.Name.PadRight(20)}{site.Value.SiteNumber.ToString().PadRight(20)}{site.Value.MaxOccupancy.ToString().PadRight(20)}" + $"{site.Value.Accessible.ToString().PadRight(20)} {site.Value.MaxRvLength.ToString().PadRight(20)}" + $"{site.Value.Utilities.ToString().PadRight(20)}{camp.CalculateFees(arrivalDate, departureDate):c}"); } if (sites.Count == 0) { Console.WriteLine("Sorry, there aren't any available sites with your requirements."); } Console.WriteLine(); Console.WriteLine("Available Options:"); Console.WriteLine($"{MAKE_RESERVATION_KEY.ToString().Substring(1)}) Make Reservation."); Console.WriteLine($"{QUIT_KEY}) Return to prior menu."); ConsoleKey userSelection = Console.ReadKey(true).Key; Console.WriteLine(); if (userSelection == MAKE_RESERVATION_KEY && sites.Count > 0) { int siteSelection = ParseUserInputRequired("Which site should be reserved (enter 0 to cancel)? "); if (siteSelection != 0 && sites.ContainsKey(siteSelection)) { string reservationName = AskUserForInputRequired("What name should the reservation be made under? "); try { int reservationId = Npsd.MakeReservation(Mgr.User.Id, sites[siteSelection].SiteId, reservationName, arrivalDate, departureDate); PrintMessageToScreen($"The reservation has been made and the confirmation id is {reservationId}"); } catch { PrintMessageToScreen("Failed in making a reservation, please try again."); } } else if (siteSelection != 0 && !sites.ContainsKey(siteSelection)) { PrintMessageToScreen("Invalid site selection, please try again..."); } } else if (userSelection == QUIT_KEY) { exit = true; } } }