public void GetCampgroundsTests() { CampgroundDAO dao = new CampgroundDAO(connectionString); //arrange IList <Campground> campgrounds = dao.GetCampgrounds(); //act Assert.AreEqual(1, campgrounds.Count); //assert }
static void Main(string[] args) { // Get the connection string from the appsettings.json file IConfigurationBuilder builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); IConfigurationRoot configuration = builder.Build(); string connectionString = configuration.GetConnectionString("Project"); /******************************************************************** * // If you do not want to use CLIMenu, you can remove the following *********************************************************************/ // Create any DAOs needed here, and then pass them into main menu... IParkDAO parkDAO = new ParkDAO(connectionString); ICampgroundDAO campgroundDAO = new CampgroundDAO(connectionString); IReservationDAO reservationDAO = new ReservationDAO(connectionString); ISiteDAO siteDAO = new SiteDAO(connectionString); MainMenu mainMenu = new MainMenu(parkDAO, campgroundDAO, reservationDAO, siteDAO); // You'll probably be adding daos to the constructor // Run the menu. mainMenu.Run(); }
private void ViewCampsInterface(Park selectedPark) { bool exit = false; while (!exit) { Console.Clear(); CampgroundDAO dao = new CampgroundDAO(_connectionString); IList <Campground> camps = dao.GetCampgrounds(selectedPark.ParkId); int Campcount = 0; //Dictionary created for passing into Infromation into other Methods Dictionary <int, Campground> campDict = new Dictionary <int, Campground>(); if (camps.Count > 0) { Console.WriteLine($"{selectedPark.Name} National Park Campgrounds"); Console.WriteLine(); Console.WriteLine("".PadRight(3) + "Name".PadRight(35) + "Open".PadRight(18) + "Close".PadRight(18) + "Daily Fee"); foreach (Campground c in camps) { Console.WriteLine($"#{++Campcount} {c.Name.PadRight(35)} " + $"{c.OpenFromString.PadRight(18)} {c.OpenToString.PadRight(18)} {c.DailyFee.ToString("C")}"); campDict.Add(Campcount, c); } Console.WriteLine(); Console.WriteLine("Select a Command"); Console.WriteLine("1) Search for Available Reservation"); Console.WriteLine("2) Return to Previous Screen"); int selection = CLIHelper.GetSingleInteger("Selection... ", 1, 2); Console.WriteLine(); if (selection == 1) { Console.WriteLine("Which campground? (enter 0 to cancel)"); int choice = CLIHelper.GetSingleInteger("Selection... ", 0, camps.Count); Console.WriteLine(); if (choice != 0) { SearchForReservationInterface(campDict[choice]); } } else if (selection == 2) { exit = true; } } else { NoResults(exit); } } }
public void GetCampGroundsTest_ShouldReturnAllCampGrounds() { //Arrange CampgroundDAO dao = new CampgroundDAO(ConnectionString); //Act IList <CampGround> campGrounds = dao.GetCampGrounds(ParkId); //Assert Assert.AreEqual(1, campGrounds.Count); }
public void GetCampgroundsTest() { ParkDAO parkDAO = new ParkDAO(connectionString); CampgroundDAO campgroundDAO = new CampgroundDAO(connectionString); List <Park> parks = parkDAO.GetParks(); IList <Campground> campgrounds = campgroundDAO.GetCampgrounds(parks[0]); Assert.AreEqual(1, campgrounds.Count); }
private void GetCampgrounds(int park_id) { IList<Campground> campgrounds = CampgroundDAO.GetCampgroundByParkId(park_id); Console.WriteLine(Campground.GetHeader()); foreach (Campground campground in campgrounds) { Console.WriteLine(campground); } }
public static void TestAuthentication() { var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); IConfigurationRoot configuration = builder.Build(); string connectionString = configuration.GetConnectionString("Project"); IUserSecurityDAO db = new UserSecurityDAO(connectionString); UserManager userMgr = new UserManager(db); CampgroundDBCLI cli = new CampgroundDBCLI(userMgr, connectionString); IcampgroundDAO cgdb = new CampgroundDAO(connectionString); cli.Run(); }
static void Main(string [] args) { IConfigurationBuilder builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); IConfigurationRoot configuration = builder.Build(); // Replace world with the key name used for your connection string in the appsettings.json file string connectionString = configuration.GetConnectionString("Project"); //string connectionString = ("Data Source=localhost\\sqlexpress;Initial Catalog=npcamground;Integrated Security=True"); CampgroundDAO campgroundDAO = new CampgroundDAO(connectionString); CampgroundCLI campgroundCLI = new CampgroundCLI(campgroundDAO); campgroundCLI.RunCLI(); }
public void CampgroundsToStringTest() { ParkDAO parkDAO = new ParkDAO(connectionString); CampgroundDAO campgroundDAO = new CampgroundDAO(connectionString); List <Park> parks = parkDAO.GetParks(); IList <Campground> campgrounds = campgroundDAO.GetCampgrounds(parks[0]); List <string> campground = campgroundDAO.campgroundsToString(campgrounds); string campName = "Camp Blue"; string openMonth = "April"; string closeMonth = "November"; string price = "$10.00"; string cg = $"{campName,-30} {openMonth,-15} {closeMonth,-15} {price,-15}"; Assert.AreEqual(cg, campground[0]); }
static void Main(string[] args) { // Get the connection string from the appsettings.json file IConfigurationBuilder builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); IConfigurationRoot configuration = builder.Build(); string connectionString = configuration.GetConnectionString("Project"); IUserSecurityDAO db = new UserSecurityDAO(connectionString); UserManager userMgr = new UserManager(db); ICampgroundDAO dbCampground = new CampgroundDAO(connectionString); CampGroundReservationCLI cli = new CampGroundReservationCLI(userMgr, dbCampground); cli.Run(); }
static void Main(string[] args) { // Get the connection string from the appsettings.json file IConfigurationBuilder builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); IConfigurationRoot configuration = builder.Build(); string connectionString = configuration.GetConnectionString("NationalParksConnection"); IParkDAO parkDAO = new ParkDAO(connectionString); IReservationDAO reservationDAO = new ReservationDAO(connectionString); ICampgroundDAO campgroundDAO = new CampgroundDAO(connectionString); NationalParkCLI application = new NationalParkCLI(parkDAO, reservationDAO, campgroundDAO); application.RunCLI(); }
public void GetCampgroundsTest() { //Arrange ParkDAO parkSqlDAL = new ParkDAO(_connectionString); CampgroundDAO campgroundDAL = new CampgroundDAO(_connectionString); //Act //gets last created park IList <Park> parks = parkSqlDAL.GetParks(); Park testPark = parks[parks.Count - 1]; IList <Campground> campgrounds = campgroundDAL.GetCampgrounds(testPark); //Assert Assert.AreEqual(1, campgrounds.Count); Assert.AreEqual("Test camp", campgrounds[0].Name); Assert.AreEqual(parkID, campgrounds[0].ParkId); Assert.AreEqual(100, campgrounds[0].DailyFee); }
static void Main(string[] args) { // Get the connection string from the appsettings.json file IConfigurationBuilder builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); IConfigurationRoot configuration = builder.Build(); string connectionString = configuration.GetConnectionString("Project"); IParkDAO parkDAO = new ParkDAO(connectionString); ICampgroundDAO campgroundDAO = new CampgroundDAO(connectionString); ISiteDAO siteDAO = new SiteDAO(connectionString); IReservationDAO reservationDAO = new ReservationDAO(connectionString); MainMenuCLI menu = new MainMenuCLI(parkDAO, campgroundDAO, siteDAO, reservationDAO); menu.Run(); }
public void SetUp() { transaction = new TransactionScope(); parkDAO = new ParkDAO(ConnectionString); campgroundDAO = new CampgroundDAO(ConnectionString); reservationDAO = new ReservationDAO(ConnectionString); using (SqlConnection conn = new SqlConnection(ConnectionString)) { conn.Open(); SqlCommand cmd = new SqlCommand($"select count(*) from park where name = '{parkName}';", conn); SqlCommand cmd2 = new SqlCommand($"select count(*) from campground where park_id = (select park_id from park where name = '{parkName}');", conn); SqlCommand cmd3 = new SqlCommand($"select count(*) from site where campground_id = (select campground_id from campground where name = '{campName}');", conn); SqlCommand cmd4 = new SqlCommand($"select count(*) from reservation where site_id = (select site_id from site where site_number = '{siteNumber}');", conn); if (Convert.ToInt32(cmd.ExecuteScalar()) == 0) { cmd = new SqlCommand($"insert into park values ('{parkName}', 'USA', '2/12/2000', 300, 2500, 'Brand new test park');", conn); cmd.ExecuteNonQuery(); } if (Convert.ToInt32(cmd2.ExecuteScalar()) == 0) { cmd2 = new SqlCommand($"insert into campground values ((select park_id from park where name = '{parkName}'), '{campName}', 1, 12, 25);", conn); cmd2.ExecuteNonQuery(); } if (Convert.ToInt32(cmd3.ExecuteScalar()) == 0) { cmd3 = new SqlCommand($"insert into site values ((select campground_id from campground where name = '{campName}'), {siteNumber}, 15, 0, 12, 1);", conn); cmd3.ExecuteNonQuery(); } if (Convert.ToInt32(cmd4.ExecuteScalar()) == 0) { cmd4 = new SqlCommand($"insert into reservation values ((select site_id from site where site_number = '{siteNumber}'), '{reservationName}', '2/21/3030', '2/25/3030', '2/10/2020');", conn); cmd4.ExecuteNonQuery(); } } }
public void GetCampgroundTest() { // Arrange CampgroundDAO campgroundDAO = new CampgroundDAO(connectionString); Park park = new Park() { ID = parkIdTest, Name = parkNameToTest, Location = parkLocationTest, EstablishedDate = parkEstablishDateTest, Area = areaTest, AnnualVisitorCount = annualVistorCountTest, Description = descriptionTest, }; // Act IList <Campground> campground = campgroundDAO.GetCampgrounds(park); // Assert Assert.IsTrue(campground.Count > 0); }
private int GetAvailableSites(int campgroundId, string arrivalDate, string departureDate, int park_id, int totalStay) { IList<Site> sites = SiteDAO.ReturnAvailableSites(campgroundId, arrivalDate, departureDate); IList<Campground> campgrounds = CampgroundDAO.GetCampgroundByParkId(park_id); decimal totalCost = 0; foreach (Campground campground in campgrounds) { totalCost = (decimal)(totalStay) * campground.Daily_Fee; } int sitesCount = sites.Count; if (sitesCount == 0) { return sitesCount; } Console.WriteLine(Site.GetHeader()); foreach (Site site in sites) { Console.WriteLine($"{site}{totalCost:C}"); } return sitesCount; }
public void UserReservationTests() { CampgroundDAO campgroundDAO = new CampgroundDAO(_connectionString); //Tests park info output var parkInfo = campgroundDAO.ParkInfo(_parkName); var testParkInfo = ($"{"Tech Elevator"}\n"); testParkInfo += string.Format("{0,-20}{1}\n", "Location: ", "Ohio"); testParkInfo += string.Format("{0,-20}{1}\n", "Established: ", "10/25/2019"); testParkInfo += string.Format("{0,-20}{1}\n", "Area(KM): ", "99999" + " SQ KM"); testParkInfo += string.Format("{0,-20}{1}\n", "Annual Visitors: ", "500000"); testParkInfo += string.Format("{0}{1,-40}\n", "Description: \n", "Lorem ipsum dolor sit amet"); Assert.AreEqual(parkInfo, testParkInfo); //Tests campground info output var campgroundInfo = campgroundDAO.CampgroundInfo(); var testCampInfo = string.Format("{0,10}{1,35}{2, 20}{3, 30}\n", "Name", "Open", "Close", "Daily Fee"); testCampInfo += string.Format("{0,-5}", _campgroundId); testCampInfo += string.Format("{0,-37}", "YYYbYYY"); testCampInfo += string.Format("{0,-19}", "3"); testCampInfo += string.Format("{0,-25}", "5"); testCampInfo += "25.00 \n"; Assert.AreEqual(campgroundInfo, testCampInfo); //Verifies user selection of a campground //Is true var campgroundChoice = campgroundDAO.VerifyCampground(_campgroundId); Assert.IsTrue(campgroundChoice); //Is false campgroundChoice = campgroundDAO.VerifyCampground(20304009); Assert.IsFalse(campgroundChoice); //Verifies user dates and campground selection have available sites //during that time DateTime arrival = new DateTime(2022, 10, 25); DateTime departure = new DateTime(2022, 10, 28); var siteAvailable = campgroundDAO.VerifySiteAvailbility(_campgroundId, arrival, departure); Assert.IsTrue(siteAvailable); //Verifies user choice as a valid site choice for campground //Is true var siteChoice = campgroundDAO.VerifySite(1); Assert.IsTrue(siteChoice); //Is false siteChoice = campgroundDAO.VerifySite(5); Assert.IsFalse(siteChoice); //Tests site display after verification var siteInfo = campgroundDAO.SiteInfo(); var testsiteInfo = string.Format("{0,-20}{1,-20}{2,-20}{3,-20}{4,-20}{5,-20}\n", "Site ", "Max Occupancy ", "Accessible ", "MaxRVLength ", "Utilities ", "Cost"); testsiteInfo += string.Format("{0,-20}", "1"); testsiteInfo += string.Format("{0,-20}", "5"); testsiteInfo += string.Format("{0,-20}", "1"); testsiteInfo += string.Format("{0,-20}", "35"); testsiteInfo += string.Format("{0,-20}", "1"); testsiteInfo += string.Format("{0,-20}", "75.00"); Assert.AreEqual(siteInfo, testsiteInfo); //Tests adding a reservation during chosen time var reservation = campgroundDAO.CreateReservation(_siteId, "Tech Elevator"); Assert.AreEqual(2, reservation); }
public CampgroundCLI(CampgroundDAO campgroundDAO) { _campgroundDAO = campgroundDAO; }