Пример #1
0
 public void EvaluateSimpleSubtractionSymbolicAndValueResult()
 {
     var operat = new Subtraction(new Number("a"), new Number("4.6"));
     Assert.AreEqual("a-4.6", ((Number)operat.Evaluate()).ToString());
 }
Пример #2
0
        public void EvaluateNestedExpressionSymbolic()
        {
            var symbol = new Addition(new Multiplication(new Number("a"), new Number("b")), new Number("c"));
            Assert.AreEqual("a*b+c", ((Number)symbol.Evaluate()).ToString());

            symbol = new Addition(new Multiplication(new Number("4"), new Number("5.6")), new Number("c"));
            Assert.AreEqual("22.4+c", ((Number)symbol.Evaluate()).ToString());

            symbol = new Addition(new Multiplication(new Number("a"), new Number("b")), new Number("c"));
            Assert.AreEqual("a*b+c", ((Number)symbol.Evaluate()).ToString());

            symbol = new Addition(new Multiplication(new Number("a"), new Number("5")), new Number("c"));
            Assert.AreEqual("a*5+c", ((Number)symbol.Evaluate()).ToString());

            symbol = new Addition(new Multiplication(new Number("a"), new Number("5")), new Number("c"));
            Assert.AreEqual("a*5+c", ((Number)symbol.Evaluate()).ToString());

            var symbolNestedFunction = new Subtraction(new Addition(new Division(new Number("a"), new Number("b")), 
                                    new Multiplication(new Number("c"), new Number("d"))),
               new Addition(new Number("e"), new Number("f")));
            Assert.AreEqual("a/b+c*d-e+f", ((Number)symbolNestedFunction.Evaluate()).ToString());
        }
Пример #3
0
 public void EvaluateSimpleSubtractionValueResult()
 {
     var operat = new Subtraction(new Number("2.6"), new Number("4.8"));
     Assert.AreEqual("-2.2", ((Number)operat.Evaluate()).ToString());
 }