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(); }
public void GetParksTest() { ParkDAO parkDAO = new ParkDAO(connectionString); List <Park> parks = parkDAO.GetParks(); Assert.AreEqual(3, parks.Count); }
public void GetParksTests() { ParkDAO dao = new ParkDAO(connectionString); //arrange IList <Park> parks = dao.GetParks(); //act Assert.AreEqual(1, parks.Count); //assert }
/// <summary> /// Entry point for the park reservation cli /// </summary> /// <param name="args">Command line arguments which are currently ignored</param> static void Main(string[] args) { CLIHelper.EnableDebugInfo = true; try { var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); IConfigurationRoot configuration = builder.Build(); string connectionString = configuration.GetConnectionString("npcampground"); IParkDAO parkDb = new ParkDAO(connectionString); IUserSecurityDAO userSecurityDb = new UserSecurityDAO(connectionString); UserManager userMgr = new UserManager(userSecurityDb); ParkReservationCLI cli = new ParkReservationCLI(userMgr, parkDb); cli.StartMenu(); } catch (Exception e) { CLIHelper.DisplayDebugInfo(e); } }
public void DisplayParkTest() { ParkDAO parkDAO = new ParkDAO(connectionString); List <Park> parks = parkDAO.GetParks(); List <string> parksStrings = parkDAO.DisplayParkList(parks); Assert.AreEqual(3, parksStrings.Count); }
public void GetParkDetailsTest_ShouldReturnParkDetails() { //Arrange ParkDAO dao = new ParkDAO(ConnectionString); //Act IList <Park> parks = dao.GetParkDetails(ParkId); //Assert Assert.AreEqual(1, parks.Count); }
public void DisplayParkDetailsTest() { ParkDAO parkDAO = new ParkDAO(connectionString); List <Park> parks = parkDAO.GetParks(); string parkDetails = parkDAO.DisplayParkDetails(parks[0]); string displayPark = "Crystal" + " Park\nLocation: " + "Michigan" + "\nEstablished: " + "1/1/2000" + "\nArea: " + "45" + " sq km \nAnnual Visitors: " + "500" + "\n\n" + "Fantastico"; Assert.AreEqual(displayPark, parkDetails); }
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); }
public void GetParksTest() { //Arrange ParkDAO parkSqlDAL = new ParkDAO(_connectionString); //Act IList <Park> parks = parkSqlDAL.GetParks(); //Assert Assert.AreEqual(mypark, parks.Count); Assert.AreEqual("Test Park", parks[parks.Count - 1].Name); }
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"); IDAO DAO = new DbDAO(connectionString); ParkIDAO parkDAO = new ParkDAO(connectionString); CLI cli = new CLI(DAO, parkDAO); cli.ShowMain(); }
private void ViewParksInterface() { bool exit = false; while (!exit) { Console.Clear(); ParkDAO dao = new ParkDAO(_connectionString); IList <Park> parks = dao.GetParks(); //Dictionary created for passing into ParkInformationInterface Method Dictionary <int, Park> parkDict = new Dictionary <int, Park>(); if (parks.Count > 0) { Console.WriteLine("Select a Park for Further Details..."); foreach (Park p in parks) { Console.WriteLine($"{p.ParkId}) {p.Name.PadRight(8)}"); parkDict.Add(p.ParkId, p); } Console.WriteLine($"{parks.Count+1}) Exit"); int selection = CLIHelper.GetSingleInteger("Selection...", 1, parks.Count + 1); if (selection == parks.Count + 1) { exit = true; } else { ParkInformationInterface(parkDict, selection); } } else { Console.Clear(); Console.WriteLine("****** NO RESULTS ******"); Console.WriteLine("Press any key to continue..."); Console.ReadKey(); exit = true; } } }
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 db = new ParkDAO(connectionString); IUserSecurityDAO security = new UserSecurityDAO(connectionString); UserManager userMgr = new UserManager(security); ParkReservationCLI cli = new ParkReservationCLI(userMgr, db); cli.Run(); }
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("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 MainMenu() { bool exit = false; while (!exit) { Console.Clear(); ParkDAO dao = new ParkDAO(_connectionString); IList <Park> parks = dao.GetParks(); //Adds One to parks.Count to pass into CLIHelper.GetSingleInteger int exitCli = parks.Count + 1; //Dictionary created for passing into ParkInformationInterface Method Dictionary <int, Park> parkDict = new Dictionary <int, Park>(); if (parks.Count > 0) { Console.WriteLine("Select a Park for Further Details..."); foreach (Park p in parks) { Console.WriteLine($"{p.ParkId}) {p.Name.PadRight(8)}"); parkDict.Add(p.ParkId, p); } // Console.WriteLine($"{exitCli}) Exit"); int selection = CLIHelper.GetSingleInteger("Selection...", 1, exitCli); if (selection == exitCli) { exit = true; } else { ParkInformationInterface(parkDict[selection]); } } else { NoResults(exit); } } }
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(); } } }