public void MathProcessor_returns_one_number()
        {
            var mathProcessor   = new MathProcessor();
            var inputExpression = new List <ExpressionUnit>()
            {
                new NumberExpressionUnit("2.00")
            };

            var result = mathProcessor.Process(inputExpression, _mathOperationsContainer);

            Assert.Equal(2.00, result);
        }
        public void MathProcessor_returns_result_of_digit_with_comma()
        {
            var mathProcessor   = new MathProcessor();
            var inputExpression = new List <ExpressionUnit>()
            {
                new NumberExpressionUnit("23,50", "23.50")
            };

            var result = mathProcessor.Process(inputExpression, _mathOperationsContainer);

            Assert.Equal(23.50, result);
        }
        public void MathProcessor_returns_result_of_digit_with_unary_minus()
        {
            var mathProcessor   = new MathProcessor();
            var inputExpression = new List <ExpressionUnit>()
            {
                new NumberExpressionUnit("8.00"),
                new OperationExpressionUnit("-", "~")
            };

            var result = mathProcessor.Process(inputExpression, _mathOperationsContainer);

            Assert.Equal(-8.00, result);
        }
        public void MathProcessor_returns_result_of_div_operation()
        {
            var mathProcessor   = new MathProcessor();
            var inputExpression = new List <ExpressionUnit>()
            {
                new NumberExpressionUnit("6.00"),
                new NumberExpressionUnit("2.00"),
                new OperationExpressionUnit("/")
            };

            var result = mathProcessor.Process(inputExpression, _mathOperationsContainer);

            Assert.Equal(3.00, result);
        }
        public void MathProcessor_returns_result_of_add_operation()
        {
            var mathProcessor   = new MathProcessor();
            var inputExpression = new List <ExpressionUnit>()
            {
                new NumberExpressionUnit("2.50"),
                new NumberExpressionUnit("3.25"),
                new OperationExpressionUnit("+")
            };

            var result = mathProcessor.Process(inputExpression, _mathOperationsContainer);

            Assert.Equal(5.75, result);
        }
        public void MathProcessor_should_throw_custom_exception_for_unsupported_operation()
        {
            var mathProcessor   = new MathProcessor();
            var inputExpression = new List <ExpressionUnit>()
            {
                new NumberExpressionUnit("3.00"),
                new NumberExpressionUnit("2.00"),
                new OperationExpressionUnit("$")
            };

            Action action = () => mathProcessor.Process(inputExpression, _mathOperationsContainer);

            var exception = Assert.Throws <ArgumentException>(action);

            Assert.Equal("Invalid mathematical expression or unsupported operation.", exception.Message);
        }
        public void MathProcessor_returns_divide_by_zero_exception()
        {
            var mathProcessor   = new MathProcessor();
            var inputExpression = new List <ExpressionUnit>()
            {
                new NumberExpressionUnit("3.00"),
                new NumberExpressionUnit("0.00"),
                new OperationExpressionUnit("/")
            };

            Action action = () => mathProcessor.Process(inputExpression, _mathOperationsContainer);

            var exception = Assert.Throws <DivideByZeroException>(action);

            Assert.Equal("You cannot divide by zero.", exception.Message);
        }