コード例 #1
0
        public void TestParkNames()
        {
            TransactionScope testParkNames;

            testParkNames = new TransactionScope();
            ParkSqlDAL  parkDAL = new ParkSqlDAL(connectionString);
            List <Park> park    = parkDAL.GetParks();

            string park_1_Name = "Acadia";
            string park_2_Name = "Arches";
            string park_3_Name = "Cuyahoga Valley";

            bool output_Name_Matches1 = park[0].name == park_1_Name;

            Assert.IsTrue(output_Name_Matches1);

            bool output_Name_Matches2 = park[1].name == park_2_Name;

            Assert.IsTrue(output_Name_Matches2);

            bool output_Name_Matches3 = park[2].name == park_3_Name;

            Assert.IsTrue(output_Name_Matches3);

            testParkNames.Dispose();
        }
コード例 #2
0
        public void TestCampgroundList()
        {
            TransactionScope test = new TransactionScope();

            ParkSqlDAL  parkDAL = new ParkSqlDAL(connectionString);
            List <Park> park    = parkDAL.GetParks();

            CampgroundSqlDAL campgroundDAL = new CampgroundSqlDAL(connectionString);

            List <Campground> testNumberOfCampsAcadia         = campgroundDAL.GetAllCampgroundFromPark(park[0]);
            List <Campground> testNumberOfCampsArches         = campgroundDAL.GetAllCampgroundFromPark(park[1]);
            List <Campground> testNumberOfCampsCuyahogaValley = campgroundDAL.GetAllCampgroundFromPark(park[2]);

            //assert
            bool outputAcadia_doesCampCountNumberMatch = testNumberOfCampsAcadia.Count == 3;

            Assert.IsTrue(outputAcadia_doesCampCountNumberMatch);

            bool outputArches_doesCampCountNumberMatch = testNumberOfCampsArches.Count == 3;

            Assert.IsTrue(outputArches_doesCampCountNumberMatch);

            bool outputCuyahogaValley_doesCampCountNumberMatch = testNumberOfCampsCuyahogaValley.Count == 1;

            Assert.IsTrue(outputCuyahogaValley_doesCampCountNumberMatch);

            test.Dispose();
        }
コード例 #3
0
        /// <summary>
        /// Display the list of parks
        /// </summary>
        /// <returns>The park id selected by user</returns>
        private int DisplayAllParks()
        {
            int parkSelection = 0;

            while (true)
            {
                ParkSqlDAL   dal   = new ParkSqlDAL(DatabaseConnection);
                IList <Park> parks = dal.GetParks();


                if (parks.Count > 0)
                {
                    Console.WriteLine("Please select the national park that you wish to visit.");
                    foreach (Park park in parks)
                    {
                        Console.WriteLine(park.ParkId.ToString().PadRight(10) + park.Name.PadRight(40));
                    }
                    Console.Write(">>  ");
                    parkSelection = CLIHelper.GetInteger(Console.ReadLine());
                    if (parkSelection <= parks.Count && parkSelection > 0)
                    {
                        break;
                    }
                    Console.Clear();
                }
                else
                {
                    Console.WriteLine("**** SOLD TO PRIVATE CORPORATION-TEDDY ROOSEVELT SPINNING IN GRAVE ****");
                }
            }
            return(parkSelection);
        }
コード例 #4
0
        // GET: Home
        public ActionResult Index()
        {
            ParkSqlDAL  parkDAL  = new ParkSqlDAL(connectionString);
            List <Park> parkList = parkDAL.GetParks();

            return(View("Index", parkList));
        }
コード例 #5
0
        // GET: Home
        public ActionResult Home()
        {
            ParkSqlDAL  dal   = new ParkSqlDAL(connectionString);
            List <Park> parks = dal.GetParks();

            return(View(parks));
        }
コード例 #6
0
        public void ParkSqlDalTests()
        {
            ParkSqlDAL parkDal = new ParkSqlDAL(connectionString);

            List <Park> parks = parkDal.GetParks();

            Assert.IsNotNull(parks);
        }
コード例 #7
0
        public void GetParksTest()
        {
            ParkSqlDAL dal = new ParkSqlDAL(ConnectionString);

            var park = dal.GetParks();

            Assert.AreEqual(1, park.Count);
        }
コード例 #8
0
ファイル: ParkTests.cs プロジェクト: scpalves/Ares
        public void GetAllParksTest()
        {
            ParkSqlDAL  testPark = new ParkSqlDAL(connectionString);
            List <Park> testList = testPark.GetParks();

            Assert.AreEqual(4, testList.Count);
            Assert.AreEqual("test park", testList[3].ParkName);
            Assert.AreEqual("ohio", testList[3].Location);
        }
コード例 #9
0
        private void GetParks()
        {
            IParkDAL     parkdal = new ParkSqlDAL(DatabaseConnectionString.DatabaseString);
            IList <Park> parks   = parkdal.GetParks();

            for (int i = 0; i < parks.Count; i++)
            {
                Console.WriteLine($"{parks[i].ParkId}) {parks[i].Name}");
            }
        }
コード例 #10
0
        public void GetParksTest_ReturnAllParks()
        {
            // Arrange
            ParkSqlDAL PSDal = new ParkSqlDAL(ConnectionString);

            // Act
            IList <Park> parks = PSDal.GetParks();

            // Assert
            Assert.AreEqual(1, parks.Count);
        }
コード例 #11
0
        public void GetParkDetailTest()
        {
            //Arrange
            IParkDAL pDetailDAL = new ParkSqlDAL(connectionString);

            //Act
            IList <ParkModel> details = pDetailDAL.GetParks("YNP");

            //Assert
            Assert.IsNotNull(details);
            Assert.AreEqual("Yellowstone National Park", details[0].ParkName);
        }
コード例 #12
0
        public void GetParksTest()
        {
            //Arrange
            ParkSqlDAL parkSqlDal = new ParkSqlDAL(connectionString);

            //Act
            List <Park> parks = parkSqlDal.GetParks();

            //Assert
            Assert.IsNotNull(parks);
            Assert.AreEqual(numberOfParks, parks.Count);
        }
コード例 #13
0
        public void TestParkList()
        {
            TransactionScope testParkList;

            testParkList = new TransactionScope();

            ParkSqlDAL  parkDAL = new ParkSqlDAL(connectionString);
            List <Park> park    = parkDAL.GetParks();
            bool        output  = park.Count > 0;

            Assert.IsTrue(output);
            testParkList.Dispose();
        }
コード例 #14
0
        private void PrintMenu()
        {
            Console.WriteLine("Select a Park for Further Details");
            IParkDAL     parkDal = new ParkSqlDAL(DatabaseConnection);
            IList <Park> parks   = parkDal.GetParks();


            foreach (Park park in parks)
            {
                Console.WriteLine($"{park.ParkId}) {park.Name}");
            }
            Console.WriteLine("Q) Quit");
        }
コード例 #15
0
        public void GetParksTest()
        {
            // Arrange
            IParkDAL pDAL = new ParkSqlDAL(connectionString);

            //Act
            IList <ParkModel> park = pDAL.GetParks();

            //Assert
            int parkTotal = park.Count;

            Assert.IsNotNull(park);
            Assert.AreEqual(4, parkTotal);
        }
コード例 #16
0
        public void DisplayMainMenu()
        {
            ParkSqlDAL parkDal = new ParkSqlDAL(_dbConnectionString);

            List <Park> parks = parkDal.GetParks();

            Console.Clear();
            Console.WriteLine();
            Console.WriteLine(" View Parks ");
            Console.WriteLine();

            bool exit = false;

            while (!exit)
            {
                for (int index = 0; index < parks.Count; index++)
                {
                    Console.WriteLine(" " + (index + 1) + ") " + parks[index].ParkName);
                }

                Console.WriteLine(" Q - Quit");
                Console.WriteLine();
                Console.Write(" Select a park... ");

                string command = Console.ReadLine();
                int    selection;

                if (command == "q" || command == "Q")
                {
                    DisplayQuitApplication();
                    exit = true;
                }
                else if (int.TryParse(command, out selection))
                {
                    if (selection > 0 && selection <= parks.Count)
                    {
                        DisplayParkInfoMenu(parks[selection - 1]);
                    }
                }
                else
                {
                    DisplayInvalidRequest();
                }

                Console.ReadKey();
                Console.Clear();
            }
        }
コード例 #17
0
ファイル: CapstoneCLI.cs プロジェクト: scpalves/Ares
        /// <summary>
        /// Get all Parks calls the GetParks method from the ParkSqlDAL Class and creates a list
        /// then that list is called into an if statement and if the count of the items in the list is > 0
        /// then it will print out all the parks contained in the park table in the database
        /// else no results will be printed out.
        /// </summary>
        private void GetAllParks()
        {
            ParkSqlDAL  dal   = new ParkSqlDAL(DatabaseConnection);
            List <Park> parks = dal.GetParks();

            if (parks.Count > 0)
            {                           //I used a lambda expression in the foreach loop. Just a different way to write the foreach loop
                                        //But does exactly the same thing if written out the longer way.
                parks.ForEach(item =>
                {
                    Console.WriteLine(item + "\n");
                });
            }
            else
            {
                Console.WriteLine("NO RESULTS");
            }
        }
コード例 #18
0
        private void DisplayParkNames()
        {
            ParkSqlDAL  pIO   = new ParkSqlDAL(DatabaseConnection);
            List <Park> parks = pIO.GetParks();

            numParks = parks.Count;

            if (parks.Count > 0)
            {
                for (int i = 0; i < parks.Count; i++)
                {
                    Console.WriteLine((i + 1) + ") " + parks[i].Name);
                }
            }
            else
            {
                Console.WriteLine("**** NO RESULTS FOUND ****");
            }
        }
コード例 #19
0
        // this method connects to the DAL class to store (in a list) and display all parks for the user //
        private List <Park> ListAllParks()
        {
            ParkSqlDAL  dal   = new ParkSqlDAL(connectionString);
            List <Park> parks = dal.GetParks();

            if (parks.Count > 0)
            {
                foreach (Park park in parks)
                {
                    Console.WriteLine("{0, -3}{1, -20}", $"{park.park_id.ToString()})", $"{park.name}");
                }
            }
            else
            {
                Console.WriteLine("**** NO RESULTS ****");
            }
            Console.WriteLine("{0, -3}{1, -20}", $"Q)", $"quit");
            return(parks);
        }
コード例 #20
0
        // this method connects to the DAL class to store (in a list) and display the info on the selected park //
        private List <Park> DisplayParkInfo()
        {
            ParkSqlDAL  dal   = new ParkSqlDAL(connectionString);
            List <Park> parks = dal.GetParks();

            Console.WriteLine("---------------------------------------------");
            Console.WriteLine("              PARK INFORMATION");
            Console.WriteLine("---------------------------------------------");
            Console.WriteLine("{0, -20}{1, 25}", $"Name: ", $"{parks[customerSelection].name.ToString().ToUpper()}");
            Console.WriteLine("---------------------------------------------");
            Console.WriteLine("{0, -20}{1, 25}", $"Location:", $"{parks[customerSelection].location}");
            Console.WriteLine("{0, -20}{1, 25}", $"Established:", $"{parks[customerSelection].establish_date.ToString()}");
            Console.WriteLine("{0, -20}{1, 25}", $"Area: ", $"{parks[customerSelection].area.ToString()}");
            Console.WriteLine("{0, -20}{1, 25}", $"Annual Visitors:", $"{parks[customerSelection].visitors.ToString()}");
            Console.WriteLine("---------------------------------------------");
            Console.WriteLine();
            Console.WriteLine(parks[customerSelection].description);
            return(parks);
        }
コード例 #21
0
        public void TestListSiteDAL()
        {
            testScope = new TransactionScope();
            DateTime startTime = new DateTime(2016, 08, 01);
            DateTime endTime   = new DateTime(2016, 08, 03);

            ParkSqlDAL  parkDAL = new ParkSqlDAL(connectionString);
            List <Park> park    = parkDAL.GetParks();

            CampgroundSqlDAL  campgroundDAL           = new CampgroundSqlDAL(connectionString);
            List <Campground> testNumberOfCampsAcadia = campgroundDAL.GetAllCampgroundFromPark(park[0]);

            SiteSqlDAL siteDal = new SiteSqlDAL(connectionString);

            List <Site> availableSites = siteDal.GetAvailableSites(testNumberOfCampsAcadia[0], startTime, endTime);

            Assert.IsNotNull(availableSites);
            Assert.IsTrue(availableSites.Count > 0);

            testScope.Dispose();
        }
コード例 #22
0
        public void DisplayMenu()
        {
            ParkSqlDAL parkDal = new ParkSqlDAL(_dbConnectionString);

            List <Park> parks = parkDal.GetParks();

            menus.MenuTitle("National Parks Reservation System");

            bool exit = false;

            while (!exit)
            {
                menus.MainMenu(parks);

                string command = Console.ReadLine();
                int    selection;

                if (command == "q" || command == "Q")
                {
                    menus.QuitMenu();
                    exit = true;
                }
                else if (int.TryParse(command, out selection))
                {
                    if (selection > 0 && selection <= parks.Count)
                    {
                        DisplayParkInfo(parks[selection - 1]);
                    }
                }
                else
                {
                    menus.InvalidEntry();
                }

                Console.ReadKey();
                Console.Clear();
            }
        }
コード例 #23
0
        public void TestCampgroundName()
        {
            TransactionScope testNames = new TransactionScope();

            ParkSqlDAL  parkDAL = new ParkSqlDAL(connectionString);
            List <Park> park    = parkDAL.GetParks();

            CampgroundSqlDAL campgroundDAL = new CampgroundSqlDAL(connectionString);

            List <Campground> testNamesOfCampsAcadia = campgroundDAL.GetAllCampgroundFromPark(park[0]);

            List <Campground> testNamesOfCampsArches = campgroundDAL.GetAllCampgroundFromPark(park[1]);

            List <Campground> testNamesOfCampsCuyahoga = campgroundDAL.GetAllCampgroundFromPark(park[2]);

            //assert
            bool outputArcadia_isCampNameCorrect1 = testNamesOfCampsAcadia[0].name == "Blackwoods";

            Assert.IsTrue(outputArcadia_isCampNameCorrect1);

            bool outputArcadia_isCampNameCorrect2 = testNamesOfCampsAcadia[2].name == "Schoodic Woods";

            Assert.IsTrue(outputArcadia_isCampNameCorrect2);

            bool outputArches_isCampNameCorrect1 = testNamesOfCampsAcadia[0].name == "Devil's Garden";

            Assert.IsTrue(outputArches_isCampNameCorrect1);

            bool outputArches_isCampNameCorrect2 = testNamesOfCampsAcadia[2].name == "Juniper Group Site";

            Assert.IsTrue(outputArches_isCampNameCorrect2);

            bool outputCuyahogaValley_isCampNameCorrect1 = testNamesOfCampsAcadia[2].name == "The Unnamed Primitive Campsites";

            Assert.IsTrue(outputCuyahogaValley_isCampNameCorrect1);

            testNames.Dispose();
        }