Esempio n. 1
0
        public void TestAddTwoNumbersStringNull2()
        {
            // add 1 and 2
            var string1 = "1";
            var string2 = string.Empty;
            var total   = Calcultions.AddTwoNumbers(string1, string2);

            Assert.AreEqual(total, 3);
        }
Esempio n. 2
0
        public void TestAddTwoNumbersInts()
        {
            // add 1 and 2
            var int1  = 1;
            var int2  = 2;
            var total = Calcultions.AddTwoNumbers(int1, int2);

            Assert.AreEqual(total, 3);
        }
Esempio n. 3
0
    static void Main(string[] args)
    {
        int row = 0;

        do
        {
            if (row == 0 || row >= 25)
            {
                ResetConsole();
            }

            Console.WriteLine("Welcome to my adding machine!");

            Console.WriteLine("Enter the first number...");
            var num1 = Console.ReadLine();
            if (string.IsNullOrEmpty(num1))
            {
                break;
            }

            Console.WriteLine("Enter the second number...");
            var num2 = Console.ReadLine();
            if (string.IsNullOrEmpty(num2))
            {
                break;
            }

            var total = Calcultions.AddTwoNumbers(num1, num2);

            Console.WriteLine("Your total is: " + total.ToString());

            row += 3;
        } while (true);
        return;

        // Declare a ResetConsole local method
        void ResetConsole()
        {
            if (row > 0)
            {
                Console.WriteLine("Press any key to continue...");
                Console.ReadKey();
            }
            Console.Clear();
            Console.WriteLine("\nPress <Enter> only to exit; otherwise, enter a string and press <Enter>:\n");
            row = 3;
        }
    }