Exemplo n.º 1
0
        public void AddmetodeVerificationNonSybole()
        {
            int number1 = 1;
            int number2 = 2;

            double result = _calculatorEngine.Calculate("add", number1, number2);
        }
Exemplo n.º 2
0
        public void AddTwoNumbersAndReturnValidResultForNonSymbol()
        {
            int    number1 = 2;
            int    number2 = 4;
            double result  = _calculatorEngine.Calculate("Add", number1, number2);

            Assert.AreEqual(6, result);
        }
        public void AddsTwoNumbersAndReturnsValidResultForNonSymbolOperations()
        {
            int    number1 = 1;
            int    number2 = 2;
            double result  = _calculatorEngine.Calculate("add", number1, number2);

            Assert.AreEqual(3, result);
        }
        public void AddsTwoNumbersAndReturnsValidResultForNonSymbolOperation()
        {
            double number1 = 1;
            double number2 = 5;

            double result = _calculatorEngine.Calculate(number1, number2, "add");

            Assert.AreEqual(6, result);
        }
        public void AddsTwoNumbersAndReturnsValidResultForNonSymbolOperation()
        {
            int    n_number1 = 1;
            int    n_number2 = 2;
            double d_result  = ce_calculatorEngine.Calculate("add", n_number1, n_number2);

            // Assert is another way to check if the result matches the outcome it's meant to be
            Assert.AreEqual(3, d_result);
        }
        public void AddsTwoNumbersAndReturnsValindResultForNonSymbolOperation()
        {
            int number1 = 1;
            int number2 = 2;

            double result = _calculatorengine.Calculate(number1, number2, "add");

            Assert.AreEqual(result, 3);
        }
        public void AddsTwoNumbersAndReturnsValidResultForNonSymbolOperation()
        {
            //1. setting up the data:
            int number1 = 1;
            int number2 = 2;
            //2. processing the data through the method that you want to test:
            double result = _calculatorEngine.Calculate("add", number1, number2);

            //3. comparing the result against our assumption:
            Assert.AreEqual(3, result);
        }
Exemplo n.º 8
0
        public void AddsTwoNumbersAndReturnsValidResultForNonSymbolOperation()
        {
            //Setting up the data
            int number1 = 1;
            int number2 = 2;
            //Processing data
            double result = _calculatorEngine.Calculate(number1, number2, "add");

            //Comparision
            Assert.AreEqual(3, result);
        }
        public void AddTwoNumbersUsingNonSymbolOperator()
        {
            int    intNum1   = 1;
            int    intNum2   = 2;
            double dblResult = _calculatorEngine.Calculate("add", intNum1, intNum2);

            Assert.AreEqual(3, dblResult);
        }
Exemplo n.º 10
0
        public void Can_Add_Two_Numbers_For_Non_Symbol_Operation()
        {
            int    number1 = 5;
            int    number2 = 10;
            double result  = calculatorEngine.Calculate("add", number1, number2);

            Assert.AreEqual(15, result);
        }
Exemplo n.º 11
0
        public void AddsTwoNumbersAndReturnsValidResultForNonSymbolOperation()
        {
            // setting up the test data
            int number1 = 1;
            int number2 = 2;

            // processing data
            double result = _calculatorEngine.Calculate("add", number1, number2);

            // compare result against our assumption
            Assert.AreEqual(3, result);   // takes expected and actual result
        }
Exemplo n.º 12
0
        public void AddsTwoNumbersAndReturnsValidResultForNonSymbolOperation()
        {
            //First step is setting up the data for your unit tests.
            //Second step is processing that data through the method that you want to test.


            int    number1 = 1;
            int    number2 = 2;
            double result  = _calculatorEngine.Calculate("add", number1, number2);

            Assert.AreEqual(3, result);         //Third step is comparing the result that you got from the processing against your assumption.
        }
        public void AddsTwoNumbersAndReturnsValidResultsForNonSymbolOperation()
        {
            // Arrange
            int number1 = 1;
            int number2 = 2;

            // Act
            double result = _calculatorEngine.Calculate("add", number1, number2);

            // Assert
            Assert.AreEqual(3, result);
        }
Exemplo n.º 14
0
        public void AddsTwoNumbersAndReturnsValidResultForNonSymbolOperation()
        {
            //setting up data for unit tests
            //processing the data through the method that is to be tested
            //comparing the result gotten from processing against original assumption.

            int number1 = 1;
            int number2 = 2;

            double result = _calculatorEngine.Calculate("add", number1, number2);

            Assert.AreEqual(3, result);
        }
Exemplo n.º 15
0
        static void Main(string[] args)
        {
            try {
                InputConverter   inputConverter   = new InputConverter();
                CalculatorEngine calculatorEngine = new CalculatorEngine();

                System.Console.WriteLine("Enter operation");

                // Read the first number and converts it
                double firstNumber = inputConverter.ConvertInputToNumeric(Console.ReadLine());

                // Read the second number and converts it
                double secondNumber = inputConverter.ConvertInputToNumeric(Console.ReadLine());

                // Read the operator
                string operation = Console.ReadLine();

                // Do the calculation that returns a result
                double result = calculatorEngine.Calculate(operation, firstNumber, secondNumber);

                // Print the result
                System.Console.WriteLine("{0} + {1} = {2}", firstNumber, secondNumber, result);
            } catch (Exception ex) {
                System.Console.WriteLine(ex.Message);
            }
        }
Exemplo n.º 16
0
        public void AddsTwoNumbersAndReturnsValidResult()
        {
            double actual   = calculatorEngine.Calculate("add", 1, 2);
            double expected = 3;

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 17
0
 public CalculatorViewModel(CalculatorEngine calculatorEngine)
 {
     _calculatorEngine = calculatorEngine;
     Result            = _calculatorEngine.Calculate('=').ToString();
     INotifyPropertyChanged("Result");
     KeyCommand   = new RelayCommand(o => CalculatorKeyClicked(o));
     CloseCommand = new RelayCommand(o => Close(o));
 }
Exemplo n.º 18
0
        public void AddsTwoNumbersAndReturnsValidResultForNonSymbolOpeartion()

        /* 3 steps to a unit test
         *  1) Setting up data for unit test
         *  2) Process data through the method that you want to test
         *  3) compare result of the unit test to your assumption */
        {
            //This is step 1
            int num1 = 1;
            int num2 = 2;

            //*** & step 2
            double result = _calculatorEngine.Calculate("add", num1, num2);

            //Step 3
            Assert.AreEqual(3, result);
        }
Exemplo n.º 19
0
        private async void EvalAndAddVariable()
        {
            Calculating = true;
            var result = await _engine.Calculate(Formula.Trim());

            Formula     = string.Empty;
            Calculating = false;
            switch (result.Status)
            {
            case Status.ResultOk:
                Engine.SetVariable(GenerateName(), result.RawObject);
                break;

            default:
                await _app.ShowMessageBox("Error", "Can't add variable, because operation didn't had a result", DialogButtons.Ok);

                break;
            }
            Variables.UpdateWith(Engine.GetMemory());
        }
Exemplo n.º 20
0
        public void Calculator_Multiplies_Three_With_Five_And_Returns_Fifteen()
        {
            // 1. Arrange
            var first    = 3;
            var second   = 5;
            var op       = "*";
            var expected = 15;
            // 2. Act
            var actual = engine.Calculate(first, second, op);

            // 3. Assert
            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 21
0
        public void AddsTwoNumbersAndReturnValidResultForNonSymbolOperation()
        {
            //ARRANGE
            int number1 = 1;
            int number2 = 2;

            //ACT
            double result = calculator.Calculate(EnumApp.CalcOperations.Add, number1, number2);

            //ASSERT
            Assert.AreEqual(expected: 3, actual: result);
        }
Exemplo n.º 22
0
 public void CalculatorKeyClicked(object parameter)
 {
     try
     {
         Result = _calculatorEngine.Calculate((Char.Parse((string)parameter))).ToString();
     }
     catch (Exception ex)
     {
         Result = ex.Message;
     }
     INotifyPropertyChanged("Result");
 }
        public void Calculuate_WhenCalled_ReturnCalculatedResult(string argOperation, double argFirstNumber, double argSecondNumber, double expectedResult)
        {
            var result = _calculator.Calculate(argOperation, argFirstNumber, argSecondNumber);

            Assert.That(result, Is.EqualTo(expectedResult));
        }