Beispiel #1
0
        public void Setup()
        {
            transaction       = new TransactionScope();
            parkSqlDao        = new ParkSqlDAO(ConnectionString);
            campgroundSqlDao  = new CampgroundSqlDAO(ConnectionString);
            siteSqlDAO        = new SiteSqlDAO(ConnectionString);
            reservationSqlDAO = new ReservationSqlDAO(ConnectionString);

            using (SqlConnection connection = new SqlConnection(ConnectionString))
            {
                connection.Open();
                SqlCommand cmdPark       = new SqlCommand($"select count(*) from park where name = '{name}'", connection);
                SqlCommand cmdCampground = new SqlCommand($"select count(*) from campground where park_id in (select park_id from park where name = '{name}')", connection);
                SqlCommand cmdSite       = new SqlCommand($"select count(*) from site where campground_id in (select campground_id from campground where name = '{nameCampground}')", connection);

                if (Convert.ToInt32(cmdPark.ExecuteScalar()) == 0)
                {
                    cmdPark = new SqlCommand($"insert into park values('{name}', '{location}', '{establish_date}', {area}, {visitors}, '{discription}')", connection);
                    cmdPark.ExecuteNonQuery();
                }

                if (Convert.ToInt32(cmdCampground.ExecuteScalar()) == 0)
                {
                    cmdCampground = new SqlCommand($" insert into campground (park_id, name, open_from_mm, open_to_mm, daily_fee) values((select park_id from park where name = '{name}'), '{nameCampground}', {open_from_mm}, {open_to_mm}, {daily_fee})", connection);
                    cmdCampground.ExecuteNonQuery();
                }

                if (Convert.ToInt32(cmdSite.ExecuteScalar()) == 0)
                {
                    cmdSite = new SqlCommand($" insert into site (campground_id, site_number, max_occupancy, accessible, max_rv_length, utilities) values((select campground_id from campground where name = '{nameCampground}'), 13, 6, 0, 0, 1)", connection);
                    cmdSite.ExecuteNonQuery();
                }
            }
        }
        public void SiteNumber()
        {
            dao = new SiteSqlDAO(ConnectionString);
            IList <Site> site = dao.ReservationTime(1, 4, Convert.ToDateTime("2019-06-27"), Convert.ToDateTime("2019-06-30"));

            Assert.AreEqual(1, site[0].SiteNumber);
        }
Beispiel #3
0
        public void SearchForOpenSites_ShouldReturn1()
        {
            SiteSqlDAO   dao   = new SiteSqlDAO(ConnectionString);
            IList <Site> sites = dao.SearchForOpenSites(this.CampgroundId, Convert.ToDateTime("2019-02-22"), Convert.ToDateTime("2019-02-24"));

            Assert.AreEqual(1, sites.Count);
        }
        public void TotalFeeForReservationIsCorrectTest()
        {
            dao = new SiteSqlDAO(ConnectionString);
            IList <Site> site = dao.ReservationTime(1, 4, Convert.ToDateTime("2019-06-27"), Convert.ToDateTime("2019-06-30"));

            Assert.AreEqual(500, site[0].NightlyRate);
        }
        public override void Setup()
        {
            base.Setup();
            dao = new SiteSqlDAO(ConnectionString);

            using (SqlConnection connection = new SqlConnection(ConnectionString))
            {
                SqlCommand command = new SqlCommand(
                    @"  SET IDENTITY_INSERT park ON
                        INSERT INTO park (park_id, name, location, establish_date, area, visitors, description) VALUES (1, 'fakePark', 'somewhere', '1000-10-10', 10, 10, 'fun')
                        SET IDENTITY_INSERT park OFF
                        SET IDENTITY_INSERT campground ON
                        INSERT INTO campground (campground_id, park_id, name, open_from_mm, open_to_mm, daily_fee) VALUES (1, 1, 'fakeCampground', 05, 09, 100)
                        SET IDENTITY_INSERT campground OFF
                        SET IDENTITY_INSERT site ON
                        INSERT INTO site (site_id, campground_id, site_number, max_occupancy, accessible, max_rv_length, utilities) VALUES (1, 1, 1, 10, 1, 20, 1)
                        SET IDENTITY_INSERT site OFF
                        SET IDENTITY_INSERT reservation ON
                        INSERT INTO reservation (reservation_id, site_id, name, from_date, to_date, create_date) VALUES
                        (1, 1, 'Family Reservation', '2019-05-10', '2019-05-20', '2019-05-02 09:22:59:340')
                        SET IDENTITY_INSERT reservation OFF", connection);


                connection.Open();
                command.ExecuteNonQuery();
            }
        }
Beispiel #6
0
        public void GetSite_ShouldReturnCorrectInformation_AndConvertSiteToReaderWorks()
        {
            SiteSqlDAO dao  = new SiteSqlDAO(ConnectionString);
            Site       site = dao.GetSite(this.SiteId);

            Assert.AreEqual(10, site.MaxOccupancy);
        }
        public void MaxRvLengthDisplaysCorrectlyTest()
        {
            dao = new SiteSqlDAO(ConnectionString);
            IList <Site> site = dao.ReservationTime(1, 4, Convert.ToDateTime("2019-06-27"), Convert.ToDateTime("2019-06-30"));

            Assert.AreEqual("35", site[0].MaxRvLength);
        }
        public override void Setup()
        {
            base.Setup();
            daoS = new SiteSqlDAO(ConnectionString);

            using (SqlConnection connection = new SqlConnection(ConnectionString))
            {
                string siteSearch = @"
               SET IDENTITY_INSERT Park ON
               INSERT INTO Park (park_id, name, location, establish_date, area, visitors, description)
               VALUES (1, 'Franklin', 'Ohio', '2010-01-01', 120, 120, 'Cool place')
               SET IDENTITY_INSERT PARK OFF
               SET IDENTITY_INSERT campground ON INSERT INTO campground (campground_id, park_id, name, open_from_mm, open_to_mm, daily_fee)
               VALUES (144, 1, 'BlackWoods', 1, 12, 35.00)
               SET IDENTITY_INSERT campground OFF
               INSERT INTO site (campground_id, site_number, max_occupancy, accessible, max_rv_length, utilities)
               VALUES ((SELECT campground_id FROM campground WHERE name = 'Blackwoods'), 12, 6, 0, 0, 0); SELECT SCOPE_IDENTITY()";


                SqlCommand command = connection.CreateCommand();
                command.CommandText = siteSearch;

                connection.Open();

                newSiteId = Convert.ToInt32(command.ExecuteScalar());
            }
        }
        public void TestTwoEndingAfterRes()
        {
            SiteSqlDAO dao = new SiteSqlDAO(connString);

            IList <Site> test = dao.ListAvailableSites(campId, Convert.ToDateTime("2019/11/03"), Convert.ToDateTime("2019/11/04"));

            Assert.AreEqual(2, test.Count);
        }
Beispiel #10
0
        public void AvilableSitesHappyPathTest()
        {
            SiteSqlDAO dao = new SiteSqlDAO(ConnectionString);

            IList <Site> sites = dao.AvilableSites(ParkId);

            Assert.AreEqual(2, sites.Count);
        }
 /// <summary>
 /// Constructor adds items to the top-level menu. You will likely have parameters  passed in
 /// here...
 /// </summary>
 public MainMenu(ParkSqlDAO park, CampgroundSqlDAO campground, SiteSqlDAO site, ReservationSqlDAO reservation) : base("Main Menu")
 {
     this.parkDao        = park;
     this.campgroundDao  = campground;
     this.siteDao        = site;
     this.reservationDao = reservation;
     parks = this.parkDao.GetParks();
 }
        public void ViewAvail()
        {
            SiteSqlDAO dao = new SiteSqlDAO(connectionString);

            IList <Site> sites = dao.ViewAvailableReservations(Convert.ToString(newCampgroundId), "2020-02-17", "2020-02-24");

            Assert.AreEqual(0, sites.Count);
        }
        public void GetAllSites()
        {
            SiteSqlDAO dao = new SiteSqlDAO(connectionString);

            IList <Site> sites = dao.GetAllSites(newSiteId);

            Assert.AreEqual(1, sites.Count);
        }
        public void TestAllSitesBooked()
        {
            SiteSqlDAO dao = new SiteSqlDAO(connString);

            IList <Site> test = dao.ListAvailableSites(campId, Convert.ToDateTime("2019/12/02"), Convert.ToDateTime("2019/12/03"));

            Assert.AreEqual(0, test.Count);
        }
        public void TestStartBeforeRes()
        {
            SiteSqlDAO dao = new SiteSqlDAO(connString);

            IList <Site> test = dao.ListAvailableSites(campId, Convert.ToDateTime("2019/11/01"), Convert.ToDateTime("2019/11/02"));

            Assert.AreEqual(2, test.Count);
        }
 /// <summary>
 /// Constructor adds items to the top-level menu
 /// </summary>
 public CampgroundMenu(Park park, CampgroundSqlDAO campgroundDao, SiteSqlDAO siteDao, ReservationSqlDAO reservationDao) :
     base("Park Menu")
 {
     this.campgroundDao  = campgroundDao;
     this.siteDao        = siteDao;
     this.reservationDao = reservationDao;
     this.park           = park;
 }
Beispiel #17
0
      //[ExpectedException(typeof(Exception))]
      public void GetAvailableSitesWhenDatesAlreadyBooked()
      {
          DateTime     arrivalDate   = DateTime.Parse("2020-06-01");
          DateTime     departureDate = DateTime.Parse("2020-06-10");
          SiteSqlDAO   siteSqlDAO    = new SiteSqlDAO(connectionString);
          IList <Site> sites         = siteSqlDAO.GetAvailableSites(campId.ToString(), arrivalDate, departureDate);

          Assert.IsTrue(sites.Count == 0);
      }
        public void GetCountOfSites()
        {
            ISiteDAO dao = new SiteSqlDAO(connectionString);

            IList <Site> sites = dao.GetAllSites(this.campId);

            // Our test database contains one campsite
            Assert.AreEqual(1, sites.Count);
        }
        public void GetSiteByCampgroundTest()
        {
            //Arrange
            SiteSqlDAO siteSqlDAO = new SiteSqlDAO(connectionString);
            //Act
            IList <Site> sites = siteSqlDAO.GetSitesByCampGroundId(testCampgroundId);

            //Assert
            Assert.IsTrue(sites.Count > 0);
        }
        public void AvailableSitesTest()
        {
            //Arrange
            SiteSqlDAO siteSqlDAO = new SiteSqlDAO(connectionString);
            //Act
            IList <Site> sites = siteSqlDAO.AvailableSites(testCampgroundId, testStartDate, testEndDate);

            //Assert
            Assert.IsTrue(sites.Count > 0);
        }
 /// <summary>
 /// Constructor adds items to the top-level menu
 /// </summary>
 public SiteMenu(Park park, Campground campground, SiteSqlDAO siteDao, ReservationSqlDAO reservationDao, string arrivalDate, string departureDate) :
     base("Park Menu")
 {
     this.siteDao        = siteDao;
     this.reservationDao = reservationDao;
     this.campground     = campground;
     this.arrivalDate    = arrivalDate;
     this.departureDate  = departureDate;
     this.park           = park;
 }
Beispiel #22
0
        public void GetAllSites_ShouldReturn1()
        {
            //Arrange
            SiteSqlDAO dao = new SiteSqlDAO(ConnectionString);
            //Act
            IList <Site> output = dao.GetAllSites(this.CampgroundId);

            //Assert
            Assert.AreEqual(1, output.Count);
        }
Beispiel #23
0
        public void GetSitesForFutureReservationsTest()
        {
            // Arrange
            SiteSqlDAO dao = new SiteSqlDAO(ConnectionString);

            // Act
            IList <Site> sites = dao.GetSitesForFutureReservations(ParkId, DateTime.Now.AddDays(3), DateTime.Now.AddDays(5));

            // Assert
            Assert.AreEqual(2, sites.Count);
        }
Beispiel #24
0
        public void GetSitesWithoutReservationsTest()
        {
            // Arrange
            SiteSqlDAO dao = new SiteSqlDAO(ConnectionString);

            // Act
            IList <Site> sites = dao.GetSitesWithoutReservations(ParkId);

            // Assert
            Assert.AreEqual(2, sites.Count);
        }
Beispiel #25
0
        public void GetSitesThatAllowRVs_Should_ReturnSitesTest()
        {
            // Arrange
            SiteSqlDAO dao = new SiteSqlDAO(ConnectionString);

            // Act
            IList <Site> sites = dao.GetSitesThatAllowRVs(ParkId);

            // Assert
            Assert.AreEqual(2, sites.Count);
        }
        public void ListAllSitesJunipers()
        {
            //arrange
            SiteSqlDAO siteDAO = new SiteSqlDAO(connectionString);

            //act
            IList <Site> sites = siteDAO.ListAllSites(6);

            //assert
            Assert.AreEqual(1, sites.Count);
        }
        public void ListAllSitesUnnamed()
        {
            //arrange
            SiteSqlDAO siteDAO = new SiteSqlDAO(connectionString);

            //act
            IList <Site> sites = siteDAO.ListAllSites(7);

            //assert
            Assert.AreEqual(5, sites.Count);
        }
        public void ListAllSitesBlackwoods()
        {
            //arrange
            SiteSqlDAO siteDAO = new SiteSqlDAO(connectionString);

            //act
            IList <Site> sites = siteDAO.ListAllSites(1);

            //assert
            Assert.AreEqual(12, sites.Count);
        }
        public void TestGetAvailableSitesAdvancedSearchNoMatches()
        {
            //Arrange
            SiteSqlDAO dao = new SiteSqlDAO(connectionString);

            //Act
            IList <Site> sites = dao.GetAvailableSites(newCampgroundId, Convert.ToDateTime("01/01/2020"), Convert.ToDateTime("05/19/2020"), 4, false, 22, true);

            //Assert
            Assert.AreEqual(0, sites.Count);
        }
Beispiel #30
0
        public void CheckSiteId()
        {
            // Assign
            SiteSqlDAO dao = new SiteSqlDAO(connectionString);

            // Act
            IList <Site> list = dao.GetSiteId(blackWoods);

            // Assert
            Assert.AreEqual(blackWoods, list[0].CampgroundId);
        }