public void BookReservationsTest()
        {
            //initialize reservation
            Reservation alpha = new Reservation();

            //gets connections
            using (SqlConnection connection = new SqlConnection(ConnectionString))
            {
                //opens connection
                connection.Open();
                //Arrange
                //querystring = the query we want to put into the SQL databse to get the values for the reservation
                string queryString = $"SELECT * FROM reservation WHERE reservation_id = {BlackLodgeReservationId}";
                //takes query string and makes it into a command that can be used in SQL
                SqlCommand command = new SqlCommand(queryString, connection);
                //gets the data returend by the query
                SqlDataReader reader = command.ExecuteReader();
                //the reader reads row by row, in this case only reading the one row
                while (reader.Read())
                {
                    alpha = new Reservation(reader);
                }
            }

            ReservationSqlDAO beta = new ReservationSqlDAO(ConnectionString);

            //Act
            int testRes = beta.BookReservation(alpha);

            //Assert
            Assert.IsTrue(testRes != 0);
        }
        public void AvailableSitesTests()
        {
            // Arrange
            ReservationSqlDAO dao = new ReservationSqlDAO(connectionString);

            // Act
            int actual = dao.BookReservation("Joe Schmo", lastSiteId, new DateTime(2020, 04, 05), new DateTime(2020, 04, 07));

            // Assert
            Assert.AreEqual(Confirmation + 1, actual);
        }
Example #3
0
        public void TestCreateReservation()
        {
            ReservationSqlDAO dao = new ReservationSqlDAO(connectionString);

            DateTime fromDate = Convert.ToDateTime("06/18/2020");
            DateTime toDate   = Convert.ToDateTime("06/19/2020");

            int reservation = dao.BookReservation(site_id, "Bob", fromDate, toDate);

            Assert.IsNotNull(reservation);
        }
        public void Returns_Count_plus_1_when_adding_new_reservation()
        {
            //Arrange
            ReservationSqlDAO reservationSqlDAO = new ReservationSqlDAO(ConnectionString);

            Reservation test = new Reservation();

            test.Site_Id     = BlackLodgeSiteId;
            test.Name        = "testname";
            test.From_Date   = DateTime.Now;
            test.To_Date     = DateTime.Now.AddDays(5);
            test.Create_Date = DateTime.Now;

            //Act
            reservationSqlDAO.BookReservation(test);

            //Assert
            Assert.AreEqual(2, reservationSqlDAO.GetReservations().Count);
        }
        public void BookReservation_Should_Fail_If_SiteId_DoesNotExist()
        {
            // Arrange
            Reservation reservation = new Reservation();

            reservation.SiteId     = 100;
            reservation.Name       = "George Clinton and the Parliament-Funkadelic";
            reservation.FromDate   = Convert.ToDateTime("03/12/23");
            reservation.ToDate     = Convert.ToDateTime("03/15/27");
            reservation.CreateDate = Convert.ToDateTime(DateTime.Now);

            ReservationSqlDAO dao = new ReservationSqlDAO(ConnectionString);
            int startingRowCount  = GetRowCount("reservation");

            dao.BookReservation(reservation);

            int endingRowCount = GetRowCount("reservation");

            Assert.AreNotEqual(startingRowCount, endingRowCount);
        }
        public void BookReservation_Should_IncreaseCountBy1()
        {
            // Arrange
            Reservation reservation = new Reservation();

            reservation.SiteId     = SiteId;
            reservation.Name       = "Ricky Bobby";
            reservation.FromDate   = Convert.ToDateTime("03/12/23");
            reservation.ToDate     = Convert.ToDateTime("03/15/27");
            reservation.CreateDate = Convert.ToDateTime(DateTime.Now);

            ReservationSqlDAO dao = new ReservationSqlDAO(ConnectionString);
            int startingRowCount  = GetRowCount("reservation");

            dao.BookReservation(reservation);

            int endingRowCount = GetRowCount("reservation");

            Assert.AreNotEqual(startingRowCount, endingRowCount);
        }