static void Main(string[] args) { CountryAppUnitTesting c = new CountryAppUnitTesting(); string userInput; // Menu user input int intVal; // Converted user input do { // Main Menu Console.WriteLine("Country Testing Menu"); Console.WriteLine("--------------------"); Console.WriteLine("1 - Unit Test Currency \n2 - Unit Test Language \n3 - Exit"); Console.Write("Enter Choice: "); userInput = Console.ReadLine(); // Converts to integer type intVal = Convert.ToInt32(userInput); #region Unit testing calls switch statment switch (intVal) { case 1: c.UnitTestCurrency(); break; case 2: c.UnitTestLanguage(); break; case 3: break; default: Console.WriteLine("\nPlease enter valid input!\n"); break; } #endregion } while (intVal != 3); }
static void Main(string[] args) { int selection = 0; CountryAppUnitTesting unitTestObj = new CountryAppUnitTesting(); // couldn't call first time, forgot to do final build while (true) // main loop { selection = userSelection(); // calls a function selection loop, could just have one have a little less cluttered main like this if (selection == 1) { unitTestObj.UnitTestCurrency(); // calls unit test on currency // user is prompted in the userSelction function } if (selection == 2) { unitTestObj.UnitTestCurrency(); // calls unit test on currency } if (selection == 3) // can't actually get here would have exited on other loop { Environment.Exit(-1); } } }
//*************************************************************************** //Method: Main // //Purpose: To run the Main method that will display menu to run unit test. //*************************************************************************** static void Main(string[] args) { CountryAppUnitTesting c = new CountryAppUnitTesting(); // To call unit testing methods string userChoice; // For switch statement // Loop to display menu until user decides to end program do { //********************************************************************** // Display the menu to the user // User has the option to run unit test on dynamic library classes // If 3 is selected, loop will end //********************************************************************** Console.WriteLine("\nCountry Testing Menu"); Console.WriteLine("--------------------"); Console.WriteLine("1 - Unit Test Currency"); Console.WriteLine("2 - Unit Test Language"); Console.WriteLine("3 - Exit"); Console.Write("Enter Choice: "); // Read Choice userChoice = Console.ReadLine(); // Switch Statement to call a method that will run the user's choice switch (Convert.ToInt32(userChoice)) { case 1: c.UnitTestCurrency(); // Calls UnitTestCurrency Method break; case 2: c.UnitTestLanguage(); // Calls UnitTestLanguage Method break; case 3: break; default: Console.WriteLine("\nChoice/Option must be a number from 1-3.\n"); break; } } while (Convert.ToInt32(userChoice) != 3); Console.Write("\nPress any key to continue..."); Console.ReadLine(); }