Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo n.º 5
0
        public void TestException()
        {
            IMathExpressionSolver solver = ExpressionSolverFactory.GetSolver(Solver.CSharpMathSolver);
            string expression            = "assadsad";

            Assert.ThrowsException <ArgumentException>(() =>
            {
                double result = solver.Solve(expression);
            });
        }
Ejemplo 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));
        }