public void AdvancedSearchTest() { //Arrange CampgroundSqlDAL campgroundSqlDAL = new CampgroundSqlDAL(); DateTime dt1 = new DateTime(2018, 3, 3, 0, 0, 0); DateTime dt2 = new DateTime(2018, 3, 5, 0, 0, 0); //Act List <Site> sites = campgroundSqlDAL.GetCampgroundAvailabilityAdvancedSearch("Blackwoods", dt1, dt2, 5, true, 0, true); //Assert Assert.AreEqual(2, sites.Count); }
private void GetCampgroundAvailabilityAdvanced(Dictionary <int, Campground> campgrounds) { CampgroundSqlDAL campgroundDAL = new CampgroundSqlDAL(); int campground = campground = CLIHelper.GetInteger("Which Campground (enter 0 to cancel):"); bool returnToPrevious = campground == int.Parse(command_Cancel); //Return to previous screen if user enters 0 if (returnToPrevious) { return; } while (!campgrounds.ContainsKey(campground)) { campground = CLIHelper.GetInteger("Invalid choice. Please pick a campground number from available list:"); } ; DateTime startDate = CLIHelper.GetDateTime("Enter start date (YYYY/MM/DD):"); DateTime endDate = CLIHelper.GetDateTime("Enter end date (YYYY/MM/DD):"); int numberOfGuests = CLIHelper.GetInteger("How many guests?"); bool wheelChairAccessible = CLIHelper.GetBoolFromYesOrNo("Wheel chair accessible (y or n)?"); int rvLength = CLIHelper.GetInteger("RV length: "); bool utilityHookup = CLIHelper.GetBoolFromYesOrNo("Utility hookups (y or n)?"); bool stillBooking = false; do { List <Site> availableSites = campgroundDAL.GetCampgroundAvailabilityAdvancedSearch(campgrounds[campground].Name, startDate, endDate, numberOfGuests, wheelChairAccessible, rvLength, utilityHookup); if (availableSites.Count > 0) { Console.Clear(); Console.WriteLine("Results Matching Your Search Criteria"); Console.WriteLine(); Console.WriteLine("{0,3}{1,12}{2,13}{3,14}{4,9}{5,10}{6,7}", "Campground", "Site No.", "Max Occup.", "Accessible?", "RV Len", "Utility", "Cost"); List <int> availableSiteNumbers = new List <int>(); int totalReservDays = (int)(endDate - startDate).TotalDays; foreach (var site in availableSites) { availableSiteNumbers.Add(site.SiteNumber); double cost = totalReservDays * campgrounds[campground].Daily_Fee; Console.WriteLine(campgrounds[campground].Name.PadRight(17) + site.SiteNumber.ToString().PadRight(12) + site.MaxOccupancy.ToString().PadRight(13) + site.WheelchairAccess.PadRight(11) + site.MaxRVLength.PadRight(10) + site.UtilityHookups.PadRight(9) + cost); } BookReservation(availableSiteNumbers, startDate, endDate); } else { Console.WriteLine("Sorry, there are no sites available in the specified date range."); stillBooking = CLIHelper.GetBoolFromYesOrNo("Would you like to enter another date range (y or n)?"); if (stillBooking) { startDate = CLIHelper.GetDateTime("Enter start date (YYYY/MM/DD):"); endDate = CLIHelper.GetDateTime("Enter end date (YYYY/MM/DD):"); } } } while (stillBooking); }