예제 #1
0
        public void GetAvailableSitesInCampgroundTest()
        {
            // Arrange
            Reservation reservation = new Reservation
            {
                Name      = "Und R. Doge",
                From_Date = DateTime.Now,
                To_Date   = DateTime.Now.AddDays(7)
            };

            using (SqlConnection connection = new SqlConnection(ConnectionString))
            {
                SqlCommand command = new SqlCommand(
                    @"SELECT p.park_id 
                      FROM park p
                      JOIN campground c
                      ON p.park_id = c.park_id
                      JOIN site s 
                      ON c.campground_id = s.campground_id 
                      WHERE s.site_number = 1 
                      AND c.campground_id = (SELECT c.campground_id 
                                             FROM campground c 
                                             WHERE c.name = 'The Back Yard')",
                    connection);
                SqlCommand command2 = new SqlCommand(
                    @"SELECT s.campground_id 
                      FROM site s 
                      JOIN campground c 
                      ON c.campground_id = s.campground_id 
                      WHERE s.site_number = 1 
                      AND c.name = 'The Back Yard'",
                    connection);

                connection.Open();

                parkId       = Convert.ToInt32(command.ExecuteScalar());
                campgroundId = Convert.ToInt32(command2.ExecuteScalar());
            }

            // Act and Assert
            Assert.AreEqual(6, (dao.GetAvailableSitesInCampground(parkId, campgroundId, reservation).Count));
            Assert.AreEqual(2, (dao.GetAvailableSitesInCampground(parkId, campgroundId, reservation)[0].Max_Occupancy));
        }