示例#1
0
        static void Main(string[] args)
        {
            var expression = ReadStringFromFile();

            var tree = new Tree.ExpressionTree(expression);

            Console.Write("Calculated value: ");
            Console.WriteLine(tree.Value);

            Console.Write("Tree representation: ");
            Console.WriteLine(tree.ToString());

            Console.Write("Infix representation: ");
            Console.WriteLine(tree.GetInfixRepresentation());
        }
示例#2
0
        public void CorrectTests()
        {
            var tree = new Tree.ExpressionTree((string)TestContext.DataRow[0]);

            Assert.AreEqual(
                double.Parse((string)TestContext.DataRow["Result"]),
                tree.Value);

            Assert.AreEqual(
                (string)TestContext.DataRow[0],
                tree.ToString());

            Assert.AreEqual(
                (string)TestContext.DataRow["Infix"],
                tree.GetInfixRepresentation());
        }