Example #1
0
        public void IsFirstSubExpInBracketsCorrect()
        {
            Expression target = new Expression(parserMock.Object, operationsMock.Object);

            string result = target.GetFirstSubExpInBrackets(exp);

            Assert.AreEqual(result, subExp);
        }
Example #2
0
        public void FindFirstOperationByPriorityCorrect()
        {
            Expression target = new Expression(parserMock.Object, operationsMock.Object);

            OperationInfo result = target.FindFirstOperationByPriority(subExp);

            Assert.AreEqual(result.OperandLeft, -4);
            Assert.AreEqual(result.OperandRight, -8);
            Assert.IsTrue(result.OperationSymbol == '*');
        }
Example #3
0
        public void IsReplaceFirstExpInBracketsCorrect()
        {
            string expFirsResult = "-10+10-44";
            string[] splitExpFirstResult = new[] { "-10", "+", "10", "-", "44" };
            parserMock.Setup(j => j.Join(splitExpFirstResult)).Returns(expFirsResult);
            Expression target = new Expression(parserMock.Object, operationsMock.Object);

            string result = target.ReplaceFirstExpInBrackets(exp, "44");

            Assert.AreEqual(result, expFirsResult);
        }
Example #4
0
        public void IsReplaceFirstOperationByPriorityCorrect()
        {
            string subExpFirstResult = "32+12";
            string[] splitSubExpFirstResult = new[] { "32", "+", "12" };
            parserMock.Setup(j => j.Join(splitSubExpFirstResult)).Returns(subExpFirstResult);

            Expression target = new Expression(parserMock.Object, operationsMock.Object);

            string result = target.ReplaceFirstOperationByPriority(subExp, "32");

            Assert.AreEqual(result, subExpFirstResult);
        }