Ejemplo n.º 1
0
        public void IfSimpleExpressionNotCorrectThenException()
        {
            string exp = "256 # (-2)";
            Parser target = new Parser(mathOperations.Object);

            target.ParseSimpleExp(exp);
        }
Ejemplo n.º 2
0
        public void IsJoinCorrect()
        {
            string exp = "-10+10-(-4+(-8))";
            string[] expArr = new[] {"-10", "+", "10", "-", "(", "-4", "+", "-8", ")" };
            Parser target = new Parser(mathOperations.Object);

            string result = target.Join(expArr);

            Assert.AreEqual(exp, result);
        }
Ejemplo n.º 3
0
        public void IsParseSimleExpressionCorrect()
        {
            string exp = "256 * (-2)";
            Parser target = new Parser(mathOperations.Object);

            OperationInfo result = target.ParseSimpleExp(exp);

            Assert.AreEqual(result.OperandLeft, 256);
            Assert.AreEqual(result.OperandRight, -2);
            Assert.AreEqual(result.OperationSymbol, '*');
        }
Ejemplo n.º 4
0
        public void IsSplitCorrect()
        {
            string exp = "-10 + 10 - (-4 + (-8))";
            string exp2 = "-223423";
            Parser target = new Parser(mathOperations.Object);

            string[] result = target.Split(exp).ToArray();
            string[] result2 = target.Split(exp2).ToArray();

            Assert.AreEqual(result[1], "+");
            Assert.AreEqual(result[5], "-4");
            Assert.AreEqual(result[7], "-8");
            Assert.AreEqual(result.Length, 9);
            Assert.IsTrue(result2.Length == 1);
            Assert.AreEqual(result2[0], exp2);
        }