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()); }
public void EvaluateSimpleAdditionSymbolicAndValueResult() { var addition = new Addition(new Number("a"), new Number("4.6")); Assert.AreEqual("a+4.6", ((Number)addition.Evaluate()).ToString()); }
public void EvaluateSimpleAdditionValueResult() { var addition = new Addition(new Number("2.6"), new Number("4.8")); Assert.AreEqual("7.4", ((Number)addition.Evaluate()).ToString()); }