예제 #1
0
        public void UserAnswer()
        {
            var calc   = new CalculatorApp.Program();
            var output = new StringWriter();
            //This sort of works like an integration test because it simulates the console
            //Below, validate that when num1 & num2 are 0, the response is as expected on the console when you try to do addition arithmetic.
            string expectedresult = (string.Format("Your result: 0 + 0 = 0\r\n", Environment.NewLine));

            Console.SetOut(output);
            var input = new StringReader("a");

            Console.SetIn(input);

            calc.UserAnswer();
            Assert.That(output.ToString(), Is.EqualTo(expectedresult));
            //Assert.False(calc.UserAnswer("t").Equals("Invalid input please try again\r\n"));
            Assert.That(calc.UserAnswer("a").Equals("a"));
        }
예제 #2
0
        public static void Main(string[] args)
        {
            // Display title as the C# console calculator app.

            Console.WriteLine("Console Calculator in C#\r");
            Console.WriteLine("------------------------\n");
            //Console.ReadKey();
            var program = new Program();

            // execute program functions
            program.PromptUserQuestion();
            program.UserInput1();
            program.UserInput2();
            program.UserOption();
            program.UserAnswer();
            program.PromptUserExit();
        }