/// <summary> /// Performs arithmetic calculation depending on operator. /// </summary> /// <returns>Calculation result</returns> /// <exception cref="System.NotSupportedException">Thrown in case of operator is not recognized</exception> private double MakeArithmeticCalculation() { if (Operator == OperatorType.Addition) { return(ArithmeticCalculator.Add((double)FirstOperand, (double)SecondOperand)); } else if (Operator == OperatorType.Subtraction) { return(ArithmeticCalculator.Subtract((double)FirstOperand, (double)SecondOperand)); } else if (Operator == OperatorType.Multiplication) { return(ArithmeticCalculator.Multiply((double)FirstOperand, (double)SecondOperand)); } else if (Operator == OperatorType.Division) { try { return(ArithmeticCalculator.Divide((double)FirstOperand, (double)SecondOperand)); } catch (System.DivideByZeroException) { State = ExecutorState.Error; return(0); } } else if (Operator == OperatorType.Inversion) { try { return(ArithmeticCalculator.Invert((double)FirstOperand)); } catch (System.DivideByZeroException) { State = ExecutorState.Error; return(0); } } else if (Operator == OperatorType.SquareRoot) { try { return(ArithmeticCalculator.SquareRoot((double)FirstOperand)); } catch (SquareRootOfNegativeException) { State = ExecutorState.Error; return(0); } } throw new System.NotSupportedException("unknown operation type"); }
public void PassingMultiplicationTest() { Assert.Equal(20, _arithmeticCalculator.Multiply(5, 4)); }
public void PassingMultiplicationTest() { Assert.IsTrue(_arithmeticCalculator.Multiply(5, 4) == 20); }