Exemplo n.º 1
0
        public void AllOperators()
        {
            var tree = new SubstrationTreeNode
            {
                new AdditionTreeNode
                {
                    new MultiplicationTreeNode
                    {
                        new NumberTreeNode(5),
                        new MultiplicationTreeNode
                        {
                            new NumberTreeNode(2),
                            new NumberTreeNode(3)
                        }
                    },
                    new NumberTreeNode(10)
                },
                new AdditionTreeNode
                {
                    new DivisionTreeNode
                    {
                        new NumberTreeNode(10),
                        new NumberTreeNode(2)
                    },
                    new NumberTreeNode(5)
                }
            };

            Assert.AreEqual(30, tree.Compute());
        }
Exemplo n.º 2
0
        public void AdditionAndSubstraction()
        {
            var tree = new SubstrationTreeNode
            {
                new AdditionTreeNode
                {
                    new NumberTreeNode(4),
                    new NumberTreeNode(6)
                },
                new NumberTreeNode(9)
            };

            Assert.AreEqual(1, tree.Compute());
        }