示例#1
0
        public void TestDivision()
        {
            var cal    = new DoCalculate();
            var result = cal.DoOperation(5, 2, "/");

            Assert.AreEqual(2.5d, result);
        }
示例#2
0
        public void TestSubtraction()
        {
            var cal    = new DoCalculate();
            var result = cal.DoOperation(5, 2, "-");

            Assert.AreEqual(3, result);
        }
示例#3
0
        public void TestMultiplication()
        {
            var cal    = new DoCalculate();
            var result = cal.DoOperation(2, 5, "*");

            Assert.AreEqual(10, result);
        }
示例#4
0
        public void TestAddition()
        {
            var cal    = new DoCalculate();
            var result = cal.DoOperation(2, 5, "+");

            Assert.AreEqual(7, result);
        }
示例#5
0
        static void Main(string[] args)
        {
            // Display title as the C# console calculator app.
            Console.WriteLine("Welcome to Console Calculator.\n");

            // Declare variables and Ask the User to enter inputs.
            double input_1 = Convert.ToDouble(Console.ReadLine());
            double input_2 = Convert.ToDouble(Console.ReadLine());

            // Ask the user to enter an operator.
            Console.WriteLine("Enter an operator:");
            string op = Console.ReadLine();

            var cal = new DoCalculate();

            Console.WriteLine(cal.DoOperation(input_1, input_2, op));
        }