Ejemplo n.º 1
0
        public void SecondPoint()
        {
            // Arrange
            string secondPoint = "25,23,23+245,23,13";
            var    exp         = new ExpressionProcessor();

            // Act
            exp.ComputeExpression(secondPoint);

            // Assert
            Assert.True(exp.GetErrorSize() == 2);
            Assert.Equal((new ErrorClass(ErrorType.SecondPoint, 6)).PrintError(), exp.GetError(0).PrintError());
            Assert.Equal((new ErrorClass(ErrorType.SecondPoint, 16)).PrintError(), exp.GetError(1).PrintError());
        }
Ejemplo n.º 2
0
        public void ToMuchOpeningBrakets()
        {
            // Arrange
            string openingBrakets = "25+5*(25+23*(35+5)+(35";
            var    exp            = new ExpressionProcessor();

            // Act
            exp.ComputeExpression(openingBrakets);

            // Assert
            Assert.True(exp.GetErrorSize() == 1);
            Assert.Equal((new ErrorClass(ErrorType.OpeningBrakets, 2)).PrintError(), exp.GetError(0).PrintError());
        }
Ejemplo n.º 3
0
        public void ToMuchClosingBrakets()
        {
            // Arrange
            string soloBraket   = "123)+23";
            string excessBraket = "(1+1)*(3+2))+24";
            var    exp          = new ExpressionProcessor();
            var    exp2         = new ExpressionProcessor();

            // Act
            exp.ComputeExpression(soloBraket);
            exp2.ComputeExpression(excessBraket);
            bool soloB   = exp.GetErrorSize() == 1;
            bool excessB = exp2.GetErrorSize() == 1;

            // Assert
            Assert.True(soloB);
            Assert.True(excessB);
            Assert.Equal((new ErrorClass(ErrorType.ClosingBrakets, 4)).PrintError(), exp.GetError(0).PrintError());
            Assert.Equal((new ErrorClass(ErrorType.ClosingBrakets, 12)).PrintError(), exp2.GetError(0).PrintError());
        }
Ejemplo n.º 4
0
        public void UnsupportedSymbol()
        {
            // Arrange
            string unsupportedSymbol = "25a+24v";
            var    exp = new ExpressionProcessor();

            // Act
            exp.ComputeExpression(unsupportedSymbol);

            // Assert
            Assert.True(exp.GetErrorSize() == 2);
            Assert.Equal((new ErrorClass(ErrorType.UnsopportedSymbol, 'a', 3)).PrintError(), exp.GetError(0).PrintError());
            Assert.Equal((new ErrorClass(ErrorType.UnsopportedSymbol, 'v', 7)).PrintError(), exp.GetError(1).PrintError());
        }
Ejemplo n.º 5
0
        public void UnexpectedOperator()
        {
            // Arrange
            string unexpectedOperators = "*2+(/4)+(-5)+(5*)+*5";
            var    exp = new ExpressionProcessor();

            // Act
            exp.ComputeExpression(unexpectedOperators);

            // Assert
            Assert.True(exp.GetErrorSize() == 4);
            Assert.Equal((new ErrorClass(ErrorType.UnexpectedOperator, '*', 1)).PrintError(), exp.GetError(0).PrintError());
            Assert.Equal((new ErrorClass(ErrorType.UnexpectedOperator, '/', 5)).PrintError(), exp.GetError(1).PrintError());
            Assert.Equal((new ErrorClass(ErrorType.UnexpectedOperator, '*', 16)).PrintError(), exp.GetError(2).PrintError());
            Assert.Equal((new ErrorClass(ErrorType.UnexpectedOperator, '*', 19)).PrintError(), exp.GetError(3).PrintError());
        }
Ejemplo n.º 6
0
        public void NotEnoughOperators()
        {
            // Arrange
            string notEnoughOperators = "24+52(242)+24";
            var    exp = new ExpressionProcessor();

            // Act
            exp.ComputeExpression(notEnoughOperators);

            // Assert
            Assert.True(exp.GetErrorSize() == 1);
            Assert.Equal((new ErrorClass(ErrorType.NotEnoughOperators)).PrintError(), exp.GetError(0).PrintError());
        }