Ejemplo n.º 1
0
        public void TestMethod_addition()
        {
            var    tst = new MathOperations();
            double res = MathOperations.Addition(6, 6);

            Assert.AreEqual(res, 12);
        }
        protected void btnCalculate_Click(object sender, EventArgs e)
        {
            double firstNumber  = Convert.ToDouble(txtNumber1.Text);
            double secondNumber = Convert.ToDouble(txtNumber2.Text);

            double result = 0.0D;

            switch (rbtnOperator.Text)
            {
            case "+":
                result = MathOperations.Addition(firstNumber, secondNumber);
                break;

            case "-":
                result = MathOperations.Subtraction(firstNumber, secondNumber);
                break;

            case "*":
                result = MathOperations.Multiplication(firstNumber, secondNumber);
                break;

            case "/":
                result = MathOperations.Division(firstNumber, secondNumber);
                break;

            case "%":
                result = MathOperations.Remainder(firstNumber, secondNumber);
                break;

            default:
                break;
            }

            lblResult.Text = result.ToString();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Execute addition tests.
        /// </summary>
        private void ExecuteAdditionTests()
        {
            results.Clear();

            // Loop 0 through 10 and run the add function for each number
            for (int i = 0; i < testCount; i++)
            {
                UpdateUI(LblStatus, "Executing Addition Tests.");

                UpdateUI(LblAdditionTest, $"Addition Test: Checking {i} + {i}");
                // Run the function and add the result to the results list
                results.Add(_MathOperations.Addition(kvpElements, i.ToString(), i.ToString(), i + i));
            }

            // Verify each result is true and return passed or failed
            UpdateUI(LblAdditionTest, results.TrueForAll(b => b) ? "Addition Test: Passed" : "Addition Test: Failed");
        }
Ejemplo n.º 4
0
        private static void DoCalculationsUsingSaticClass(double firstNumber, double secondNumber)
        {
            Console.WriteLine("\n--------------Avinash Math Operations---------------------");

            MathOperations.Addition(firstNumber, secondNumber);
            MathOperations.Subtraction(firstNumber, secondNumber);
            MathOperations.Multiplication(firstNumber, secondNumber);
            MathOperations.Division(firstNumber, secondNumber);

            Console.WriteLine("-----------------------------------------------------------");
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            IMathOperations _MathOperations = new MathOperations();

            log.Info("This is Math Operations");
            Console.WriteLine("Enter Number:");
            int n1 = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("Enter another Number:");
            int n2 = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("Enter your Math Operation: \n Press 1 to Addition \n Press 2 to substract\n Press 3 to Multiplication\n Press 4 to Division\n");
            int n3 = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("Your Option is : " + n3);
            log.Info("You have entered numbers are " + n1 + " and " + n2);
            switch (n3)
            {
            case 1:
                log.Info("Your Option is Addition");
                int sum = _MathOperations.Addition(n1, n2);
                Console.WriteLine("Addition of " + n1 + " and " + n2 + " is " + sum);
                log.Info("Addition of " + n1 + " and " + n2 + " is " + sum);
                break;

            case 2:
                log.Info("Your Option is Substraction");
                int sum2 = _MathOperations.Substraction(n1, n2);
                Console.WriteLine("Substraction of " + n1 + " and " + n2 + " is " + sum2);
                log.Info("Substraction of " + n1 + " and " + n2 + " is " + sum2);
                break;

            case 3:
                log.Info("Your Option is Multiplication");
                int result = _MathOperations.Multiplication(n1, n2);
                Console.WriteLine("Multiplication of " + n1 + " and " + n2 + " is " + result);
                log.Info("Multiplication of " + n1 + " and " + n2 + " is " + result);
                break;

            case 4:
                log.Info("Your Option is Division");
                int result2 = _MathOperations.Division(n1, n2);
                Console.WriteLine("Division of " + n1 + " and " + n2 + " is " + result2);
                log.Info("Division of " + n1 + " and " + n2 + " is " + result2);
                break;

            default:
                Console.WriteLine("Invalid option!!!");
                log.Info("User has selected - Invalid option!: " + n3 + "to do operations");
                break;
            }
            Console.ReadKey();
        }
Ejemplo n.º 6
0
        public void Deduction_4and2()
        {
            // Значення які будуть передані в метод
            int a = 4;
            int b = 2;
            //очікуваний результат
            int           expected = 4;
            MathOpertions object2  = new MathOperations();
            int           actual   = object2.Addition(a, b);

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 7
0
        public void Addition()
        {
            // Значення які будуть передані в метод
            double a = 15.5;
            double b = 33;
            //очікуваний результат
            double         expected = 48.5;
            MathOperations object2  = new MathOperations();
            double         actual   = object2.Addition(a, b);

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 8
0
        public void Operators(int option, ref int val1,ref int val2 )
        {
            MathOperations mt = new MathOperations();
            switch(option)
            {

                case 1:
                    {
                        Console.WriteLine("The {0} is ... {1}",Operations.Addition,  mt.Addition(ref val1, ref val2));
                    }
                break;
                case 2:
                    {
                        Console.WriteLine("The {0} is ... {1}",Operations.Subtraction, mt.Subtraction(ref val1, ref val2));
                    }
                    break;
                case 3:
                    {
                        Console.WriteLine("The {0} is ... {1}",Operations.Multiplication, mt.Multiplication(ref val1, ref val2));
                    }
                    break;
                case 4:
                    {
                        Console.WriteLine("The {0} is ... {1}",Operations.Division, mt.Division(ref val1, ref val2));
                    }
                    break;
                case 5:
                    {
                        Console.WriteLine("the {0}  is ...{1}", Operations.Exponentation, mt.Exponentation(ref val1, ref val2));
                    }
                    break;
                case 6:
                    {
                        Console.Clear();
                        Console.WriteLine(".....");
                        Matrix mx = new Matrix();
                        mx.MainMatrix();
                    }
                    break;
                case 7:
                    {
                        LinearEquation le = new LinearEquation();
                        le.EquationSolver();
                    }
                    break;
                default:
                    Console.WriteLine("Wrong Choice");
                    break;
            }
        }
 public TestDll()
 {
     int Result = MathOperations.Addition(10, 20);
 }