Пример #1
0
        static void Main(string[] args)
        {
            string menuSelection;
            CourseWorkUnitTesting test = new CourseWorkUnitTesting();

            do
            {
                // display menu
                Console.WriteLine("Course Work Testing Menu");
                Console.WriteLine("------------------------");
                Console.WriteLine("1 - Unit Test Category");
                Console.WriteLine("2 - Unit Test Assignment");
                Console.WriteLine("3 - Exit");
                Console.Write("Enter Choice: ");

                // read and store user's selection
                menuSelection = Console.ReadLine();

                #region unit testing
                // perform unit testing based on user's input or exit the program
                switch (menuSelection)
                {
                case "1":
                    test.UnitTestCategory();
                    break;

                case "2":
                    test.UnitTestAssignment();
                    break;

                case "3":
                    Console.WriteLine("Exiting program.\n");
                    break;

                default:
                    Console.WriteLine("Invalid input. Please enter a choice from the menu.\n");
                    break;
                }
                #endregion
            } while (menuSelection != "3"); // display menu until user enters "3" to exit
        }
Пример #2
0
        static void Main(string[] args)
        {
            //Variables
            string num;
            int    i;

            #region Do while Loop
            //Loop to loop menu
            do
            {
                Console.WriteLine("CourseWork Testing Menu");
                Console.WriteLine("-----------------------");
                Console.WriteLine("1 - Unit Test Category");
                Console.WriteLine("2 - Unit Test Assigment");
                Console.WriteLine("3 - Exit");
                Console.Write("Enter Choice: ");
                num = Console.ReadLine();
                Console.WriteLine("");

                //Parse string to int
                if (!Int32.TryParse(num, out i))
                {
                }

                //Checks if user inputed 1
                if (i == 1)
                {
                    CourseWorkUnitTesting test = new CourseWorkUnitTesting();

                    Console.WriteLine("**********************");
                    Console.WriteLine("Unit Testing: Category");
                    Console.WriteLine("**********************");
                    test.UnitTestCategory();
                    Console.WriteLine("");
                }

                //Checks if user inputed 2
                if (i == 2)
                {
                    CourseWorkUnitTesting test = new CourseWorkUnitTesting();

                    Console.WriteLine("**********************");
                    Console.WriteLine("Unit Testing: Assigment");
                    Console.WriteLine("**********************");
                    test.UnitTestAssignment();
                    Console.WriteLine("");
                }

                //Checks for vaild user input
                if (i < 1 || i > 3)
                {
                    Console.WriteLine("Invaild Input");
                    Console.WriteLine("Enter 1, 2 or 3");
                    Console.WriteLine("");
                }
            } while (i != 3); //Loop will not exit until user inputs 3
            #endregion

            //Checks if user inputed 3
            if (i == 3)
            {
                //Terminates Application
                System.Environment.Exit(1);
            }
        }