Exemplo n.º 1
0
        public void DivisionByZero(string input, string error)
        {
            var result = CalculateHelper.Calculate(input);

            Assert.IsFalse(result.IsSuccess());
            Assert.AreEqual(error, result.Error);
        }
Exemplo n.º 2
0
        public void InvalidBrackets(string input, string error)
        {
            var result = CalculateHelper.Calculate(input);

            Assert.IsFalse(result.IsSuccess());
            Assert.AreEqual(error, result.Error);
        }
Exemplo n.º 3
0
        public void MisuseOfOperator(string input, string error)
        {
            var result = CalculateHelper.Calculate(input);

            Assert.IsFalse(result.IsSuccess());
            Assert.AreEqual(error, result.Error);
        }
        public void NotationWithBrackets(string input, double result)
        {
            var calculationResult = CalculateHelper.Calculate(input);

            Assert.IsTrue(calculationResult.IsSuccess());
            Assert.AreEqual(result, calculationResult.Result);
        }
        public void DecimalFractions(string input, double result)
        {
            var calculationResult = CalculateHelper.Calculate(input);

            Assert.IsTrue(calculationResult.IsSuccess());
            Assert.AreEqual(result, calculationResult.Result);
        }
        public void TwoOperationWithDifferentPriority(string input, double result)
        {
            var calculationResult = CalculateHelper.Calculate(input);

            Assert.IsTrue(calculationResult.IsSuccess());
            Assert.AreEqual(result, calculationResult.Result);
        }
 public void Calculate_SubtractingTwoValidWholeNumbers_ReturnsCorrectDifference()
 {
     var calculateHelper = new CalculateHelper
      {
     Operation = Operation.Subtract,
     Operand1 = 4,
     Operand2 = 6
      };
      Assert.AreEqual( -2, calculateHelper.Calculate() );
 }
 public void Calculate_MultiplyingTwoValidWholeNumbers_ReturnsCorrectProduct()
 {
     var calculateHelper = new CalculateHelper
      {
     Operation = Operation.Multiply,
     Operand1 = -4,
     Operand2 = 2
      };
      Assert.AreEqual( -8, calculateHelper.Calculate() );
 }
 public void Calculate_DividingTwoValidWholeNumbers_ReturnsCorrectQuotient()
 {
     var calculateHelper = new CalculateHelper
      {
     Operation = Operation.Divide,
     Operand1 = 5,
     Operand2 = 2
      };
      Assert.AreEqual( 2.5, calculateHelper.Calculate(), 0.01 );
 }
Exemplo n.º 10
0
 public void Calculate_AddingTwoValidWholeNumbers_ReturnsCorrectSum()
 {
     var calculateHelper = new CalculateHelper
      {
     Operation = Operation.Add,
     Operand1 = 2,
     Operand2 = 3
      };
      Assert.AreEqual( 5, calculateHelper.Calculate() );
 }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            while (true)
            {
                var expression = Console.ReadLine();
                var result     = CalculateHelper.Calculate(expression);

                if (result.IsSuccess())
                {
                    Console.WriteLine(result.Result);
                }
                else
                {
                    Console.WriteLine(result.Error);
                }
            }
        }