Esempio n. 1
0
        public void TestComplexExpression()
        {
            IMathExpressionSolver solver = ExpressionSolverFactory.GetSolver(Solver.CSharpMathSolver);
            string expression            = "2+1*3/2+12";

            double result = solver.Solve(expression);

            Assert.AreEqual(15.5d, result);
        }
Esempio n. 2
0
        public void TestDivision()
        {
            IMathExpressionSolver solver = ExpressionSolverFactory.GetSolver(Solver.CSharpMathSolver);
            string expression            = "25/2";

            double result = solver.Solve(expression);

            Assert.AreEqual(12.5d, result);
        }
Esempio n. 3
0
        public void TestMultiplication()
        {
            IMathExpressionSolver solver = ExpressionSolverFactory.GetSolver(Solver.CSharpMathSolver);
            string expression            = "20*5";

            double result = solver.Solve(expression);

            Assert.AreEqual(100d, result);
        }
Esempio n. 4
0
        public void TestSubtraction()
        {
            IMathExpressionSolver solver = ExpressionSolverFactory.GetSolver(Solver.CSharpMathSolver);
            string expression            = "10-1";

            double result = solver.Solve(expression);

            Assert.AreEqual(9d, result);
        }
Esempio n. 5
0
        public void TestException()
        {
            IMathExpressionSolver solver = ExpressionSolverFactory.GetSolver(Solver.CSharpMathSolver);
            string expression            = "assadsad";

            Assert.ThrowsException <ArgumentException>(() =>
            {
                double result = solver.Solve(expression);
            });
        }
Esempio n. 6
0
        private static IMathExpressionSolver GetEngine(int option)
        {
            switch (option)
            {
            case 2:
                return(ExpressionSolverFactory.GetSolver(Solver.CSharpMathSolver));

            default:
                return(ExpressionSolverFactory.GetSolver(Solver.ExpressionMathSolver));
            }
        }
        public void TestExpressionMathSolverCreation()
        {
            IMathExpressionSolver solver = ExpressionSolverFactory.GetSolver(Solver.ExpressionMathSolver);

            Assert.IsInstanceOfType(solver, typeof(ExpressionMathSolver));
        }