コード例 #1
0
        public void ParkDALTests()
        {
            /*TEST GetAllParks method*/

            //Arrange
            ParkDAL parkDAL = new ParkDAL(connectionString);

            //Act
            List <Park> parks = parkDAL.GetAllParks();

            //Assert
            Assert.AreEqual(_numberOfParks, parks.Count);//retrieved the number of rows beforehand to compare to the count in the returned list


            /*TEST GetAllCampgrounds method*/

            List <Campground> campgrounds = parkDAL.GetAllCampgrounds(parks[0].ParkID); //using the first index of the returned list from GetAllParks

            Assert.AreEqual(_numberOfCampgroundsWithinPark, campgrounds.Count);         //retrieved number of campgrounds within park_id = 1 beforehand


            /*TEST GetAllSites method*/

            List <Site> sites = parkDAL.GetAllSites(campgrounds[0].CampgroundID); //using the first index of the returned list from GetAllCampgrounds

            Assert.AreEqual(_numberOfSitesWithinCampground, sites.Count);         //retrieved number of campgrounds within campground_id = 1 beforehand

            /*TEST GetAllSites method*/

            //using the first index of the returned list from GetAllCampgrounds, a test from_date, a test to_date
            List <Site> sitesAvailable = parkDAL.GetSelectedSites(campgrounds[0].CampgroundID, "2018-10-15", "2018-10-20");

            Assert.AreEqual(_numberOfSitesAvailable, sitesAvailable.Count);//retrieved number of campgrounds within campground_id = 1 beforehand
        }