Пример #1
0
        public void GetAllParksAlphabeticallyTest()
        {
            //Arrange
            CampgroundSqlDAL campgroundSqlDAL = new CampgroundSqlDAL();

            //Act
            Dictionary <int, Park> parks = campgroundSqlDAL.GetAllParksAlphabetically();

            //Assert
            Assert.AreEqual(4, parks.Count);
            Assert.AreEqual(3333, parks[4].Area);
        }
        private void MainMenu()
        {
            CampgroundSqlDAL       campgroundDAL = new CampgroundSqlDAL();
            Dictionary <int, Park> parks         = campgroundDAL.GetAllParksAlphabetically();

            Console.WriteLine("Select a park for further details");
            Console.WriteLine();
            Console.WriteLine(String.Format("").PadRight(35, '='));
            foreach (KeyValuePair <int, Park> park in parks)
            {
                Console.WriteLine($"{park.Key}) {park.Value.Name}");
            }

            Console.WriteLine("Q) Quit");
            Console.WriteLine();
        }
        public void RunCLI()
        {
            int numAttempt = 0;

            do
            {
                Console.Clear();
                MainMenu();

                CampgroundSqlDAL       campgroundDAL = new CampgroundSqlDAL();
                Dictionary <int, Park> parks         = campgroundDAL.GetAllParksAlphabetically();


                if (numAttempt > 0)
                {
                    Console.WriteLine("The command provided was not a valid, please try again.");
                }

                ConsoleKeyInfo userInput = Console.ReadKey();
                string         command   = userInput.KeyChar.ToString();


                int.TryParse(command, out int parkKey);
                bool isValidUserParkChoice = parks.ContainsKey(parkKey);

                if (isValidUserParkChoice)
                {
                    bool isTurningoff = false;

                    while (!isTurningoff)
                    {
                        int park = int.Parse(command);
                        isTurningoff = GetParkInfo(park);
                    }
                }
                else if (command.ToLower() == command_Quit)
                {
                    return;
                }
                numAttempt++;
            } while (true);
        }