public void GetParksTest()
        {
            ParkSqlDal  dal   = new ParkSqlDal(connectionString);
            List <Park> parks = dal.GetParks();

            Assert.IsTrue(parks.Count > 0);
        }
示例#2
0
        public void RunCLI()
        {
            DisplayHeader();
            DisplayMainMenu();
            ParkSqlDal             dal             = new ParkSqlDal(dbConnection);
            Dictionary <int, Park> dictionaryParks = dal.GetAllParks();

            while (true)
            {
                string userOption = Console.ReadLine();
                int    parkIndex  = Convert.ToInt32(userOption);

                if (userOption == "1")
                {
                    DisplayAllParks(dictionaryParks);
                    //sub menu for customer to choose campground based on park id
                    ProcessCustomerOption();
                }
                else if (userOption == "2")
                {
                    GetAllCurrentReservations(dictionaryParks);
                }
                else if (userOption == "3")
                {
                    Console.WriteLine("Thank You For Using Our Park Reservation System");
                    return;
                }

                DisplayMainMenu();
            }
        }
        public void GetParkInfoTest()
        {
            ParkSqlDal dal = new ParkSqlDal(connectionString);
            Park       p   = dal.GetParkInfo("MOSHE");

            Assert.AreEqual("Moshe Grand Dam", p.Name);
        }
示例#4
0
        public void GetAllParksTest()
        {
            List <Park> p       = new List <Park>();
            ParkSqlDal  parkDal = new ParkSqlDal(connectionString);

            p = parkDal.GetAllParks();
            Assert.AreEqual(parkCount, p.Count);
        }
示例#5
0
        public void GetCampgroundByCodeTest()
        {
            Park       p       = new Park();
            ParkSqlDal parkDal = new ParkSqlDal(connectionString);

            p = parkDal.GetParkByCode(code);
            Assert.AreEqual(code, p.ParkCode);
        }
示例#6
0
        public void GetParksDetailTest()
        {
            ParkSqlDal dal  = new ParkSqlDal(connectionString);
            Park       park = dal.GetParkDetail("TEST");

            Assert.IsNotNull(park.ParkCode);
            Assert.IsTrue(park.Name == "Test National Park");
            Assert.IsTrue(park.NumberOfAnimalSpecies == 760);
        }
示例#7
0
        public void GetParksTest()
        {
            ParkSqlDal  dal   = new ParkSqlDal(connectionString);
            List <Park> parks = dal.GetParks();

            Assert.IsTrue(parks.Any(i => i.ParkCode == "TEST"));
            Assert.IsTrue(parks.Any(i => i.Name == "Test National Park"));
            Assert.IsTrue(parks.Count >= 2);
        }
        public void AllParksScreen()
        {
            bool done = false;

            while (!done)
            {
                Console.Clear();
                Console.WriteLine("Select a Park for Further Details: ");

                ParkSqlDal  parkSqlDal = new ParkSqlDal(DatabaseConnection);
                List <Park> parks      = parkSqlDal.GetAllParks();
                foreach (Park park in parks)
                {
                    Console.WriteLine($"{park.Id}) {park.Name} ");
                }
                Console.WriteLine("Q) Quit\n");

                string userinput         = Console.ReadLine().ToUpper();
                bool   userEnteredNumber = int.TryParse(userinput, out int parkIdEntry);
                Park   selectedPark      = GetParkFromListById(parkIdEntry, parks);

                if (userEnteredNumber)
                {
                    if (selectedPark != null)
                    {
                        ParkInformationScreen(selectedPark);
                    }
                    else
                    {
                        Console.WriteLine("Park Id not found! Press any key to try again");
                        Console.ReadKey();
                    }
                }
                else
                {
                    if (userinput == "Q")
                    {
                        done = true;
                    }
                    else
                    {
                        Console.WriteLine("Please enter a valid entry, press any key to try again");
                        Console.ReadKey();
                    }
                }
            }
        }
        public void GetAllParksTest()
        {
            //Arange
            ParkSqlDal parkSqlDal = new ParkSqlDal(connectionString);

            //ACT
            List <Park> parks = parkSqlDal.GetAllParks();

            //Assert
            Assert.IsNotNull(parks, "Parks list is empty!");
            Assert.AreEqual(parkCount, parks.Count, $"Expected a count of {parkCount} for parks");

            bool found = false;

            foreach (Park park in parks)
            {
                if (park.Name == "Test Park")
                {
                    found = true;
                    break;
                }
            }
            Assert.IsTrue(found, "Could not find Test Park named Test Park");
        }
示例#10
0
        public void ProcessCustomerOption()
        {
            DisplaySubMenu();
            ParkSqlDal             dal         = new ParkSqlDal(dbConnection);
            Dictionary <int, Park> listOfParks = dal.GetAllParks();
            int parkId;

            while (true)
            {
                string userInput = Console.ReadLine();
                if (userInput == "1") // park details
                {
                    DisplayAllParks(listOfParks);
                    Console.WriteLine("Please Choose A Park To View Details");
                    parkId = Convert.ToInt32(Console.ReadLine());
                    DisplayParkDetails(parkId, listOfParks);
                }
                else if (userInput == "2")
                {
                    DisplayAllParks(listOfParks);
                    Console.WriteLine("Please Select A Park ID To View All Campground Sites");
                    parkId = Convert.ToInt32(Console.ReadLine());

                    Console.WriteLine(@"What is the arrival date? __/__/____ ");
                    DateTime fromDate = Convert.ToDateTime(Console.ReadLine());

                    Console.WriteLine(@"What is the departure date? __/__/____ ");

                    DateTime toDate = Convert.ToDateTime(Console.ReadLine());

                    if (listOfParks.ContainsKey(parkId))
                    {
                        CampgroundSqlDal             campDal    = new CampgroundSqlDal(dbConnection);
                        Dictionary <int, Campground> listOfCamp = campDal.GetAllCampsByParkId(parkId);
                        Console.WriteLine();
                        Console.WriteLine("Results Matching Your Search Criteria ");
                        foreach (int key  in listOfCamp.Keys)
                        {
                            if (fromDate.Month >= listOfCamp[key].OpenFromMonth && toDate.Month <= listOfCamp[key].OpenToMonth)
                            {
                                Console.WriteLine("Camp Name \t\t Site No.\t Max Occup.\t Accessible?\t RV Len \t Utility\t Cost");

                                SearchAvailableSitesByCampId(key, fromDate, toDate);
                                //MakeReservation(fromDate, toDate);
                            }
                            else
                            {
                                Console.WriteLine(@"Invalid Date(s), park is not open on one of these dates. ");
                            }
                        }
                        //after printing out all the available sites, calls make reservation method
                        MakeReservation(fromDate, toDate);
                    }
                }
                else if (userInput == "3")
                {
                    //Console.Clear();
                    DisplayAllParks(listOfParks);
                    Console.WriteLine("Please Select A Park ID To View Campgrounds");
                    parkId = Convert.ToInt32(Console.ReadLine());
                    if (listOfParks.ContainsKey(parkId))
                    {
                        DisplayCampsByParkId(parkId, listOfParks);
                    }
                    else
                    {
                        Console.WriteLine("Invalid Park ID Selection, Please try again. ");
                    }
                }
                else if (userInput == "4")
                {
                    return;
                }

                DisplaySubMenu();
            }
        }