Ejemplo n.º 1
0
        public void UserInput2Test()
        {
            var calc = new CalculatorApp.Program();

            //Here I am simulating the console to validate a simulated input string with an the expected output.

            /*var output = new StringWriter();
             * string expectedresult = (string.Format("Type another number, and then press Enter\r\n5\r\n", Environment.NewLine));
             * Console.SetOut(output);
             * var input = new StringReader("5");
             * Console.SetIn(input);
             * var input2 = new StringReader("5");
             * Console.SetIn(input2);
             *
             * calc.UserInput2();
             * //num1 = (float)Convert.ToDecimal(output);
             *
             * Assert.That(output.ToString(), Is.EqualTo(expectedresult));*/

            //Assert input values are accurately parsed into decimals.  Assert false if the values don't parse to their expected outcome.
            Assert.That(calc.UserInput2("3").Equals(3));
            Assert.False(calc.UserInput2("1").Equals(1.1));
            Assert.False(calc.UserInput2("1").Equals("1"));
        }
Ejemplo n.º 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();
        }