示例#1
0
        public void GetCampSites_CountList_Test()
        {
            List <Campsite> output  = s.GetCampsites(cg, connectionString);
            List <Campsite> output2 = s.GetCampsites(cg2, connectionString);
            List <Campsite> output3 = s.GetCampsites(cg3, connectionString);

            int result  = output.Count;
            int result2 = output2.Count;
            int result3 = output3.Count;

            Assert.AreEqual(12, result);
            Assert.AreEqual(8, result2);
            Assert.AreEqual(5, result3);
        }
示例#2
0
        public void DatesPrompt(int campgroundId, Park selectedPark)
        {
            string fromDate;
            string toDate;
            bool   isDone = false;

            CampsiteDAL     campsiteDAL   = new CampsiteDAL(connectionString);
            CampgroundDAL   campgroundDAL = new CampgroundDAL(connectionString);
            List <Campsite> campsites;

            try
            {
                do
                {
                    Console.WriteLine("\nWhat is the arrival date? (yyyy-mm-dd)");
                    fromDate = Console.ReadLine();

                    Console.WriteLine("\nWhat is the departure date? (yyyy-mm-dd)");
                    toDate = Console.ReadLine();

                    if (!AreDatesInFuture(fromDate, toDate) || !ArriveBeforeDepartCheck(fromDate, toDate))
                    {
                        Console.WriteLine("");
                        Console.WriteLine("Sorry, those are not valid dates.");
                    }
                    else if (!campgroundDAL.CampgroundCheck(campgroundId, selectedPark.Id, fromDate, toDate))
                    {
                        Console.WriteLine("");
                        Console.WriteLine("Sorry, the campground is not open during those dates.");
                    }
                    else
                    {
                        isDone = true;
                    }
                }while (!isDone);

                campsites = campsiteDAL.GetCampsites(campgroundId, fromDate, toDate);

                if (campsites.Count == 0)
                {
                    NoCampsitesAvailablePrompt(campsites);
                }
                else
                {
                    DisplayAvailableReservations(campsites, toDate, fromDate);
                    DisplayCreateReservationMenu(campsites, fromDate, toDate);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine();
                Console.WriteLine("Not a valid value- please try again");
            }
        }
        public void TestAvailableCampsites()
        {
            CampsiteDAL     campsiteDAL = new CampsiteDAL(connectionString);
            List <Campsite> campsites   = campsiteDAL.GetCampsites(1, "2019-10-10", "2019-10-12");
            bool            result      = false;

            for (int i = 0; i < campsites.Count; i++)
            {
                if (campsites[i].SiteId == 1)
                {
                    result = true;
                }
            }
            Assert.AreEqual(true, result);
        }