public bool MultipleExpressionsTest(string expression, double result)
        {
            bool testResult = Math.Abs(Calculator.CountAnExpression(expression, new StackArray()).Item1 - result) < 1e-4;

            return(testResult && Math.Abs(Calculator.CountAnExpression(expression, new StackList()).Item1 - result) < 1e-4);
        }
 public bool IncorrectExpressionsTest(string expression)
 {
     return(Calculator.CountAnExpression(expression, new StackArray()).Item2&& Calculator.CountAnExpression(expression, new StackList()).Item2);
 }
Beispiel #3
0
        public void TestOperation(string operation, double left, double right, double result)
        {
            ICalculator calculator = new Calculator();

            Assert.AreEqual(calculator.Actions[operation].Invoke(left, right), result);
        }
 public CalculatorDegreesTests()
 {
     this._calculator = new Calculator();
 }
        public void Add2Numbers()
        {
            int result = Calculator.Add(10, 5);

            Assert.AreEqual(15, result);
        }
Beispiel #6
0
 public CalculatorShould()
 {
     _calculator = new Calculator();
 }
 public void NoNegatives()
 {
     Assert.ThrowsException <ArgumentException>(() => Calculator.Add(-1, 10));
     Assert.ThrowsException <ArgumentException>(() => Calculator.Add(10, -1));
 }
        public void Square2Numbers()
        {
            double result = Calculator.Exponent(10, 0);

            Assert.AreEqual(1, result);
        }
        public void Divide2Numbers()
        {
            int result = Calculator.Divide(10, 5);

            Assert.AreEqual(2, result);
        }
        public void Multiply2Numbers()
        {
            int result = Calculator.Multiply(10, 5);

            Assert.AreEqual(50, result);
        }
        public void Subtract2Numbers()
        {
            int result = Calculator.Subtract(10, 5);

            Assert.AreEqual(5, result);
        }