public void AddExpressionConstructorTest()
        {
            Expression operand1 = new ValueExpression(4); // TODO: Initialize to an appropriate value
            Expression operand2 = new ValueExpression(5); // TODO: Initialize to an appropriate value
            AddExpression target = new AddExpression(operand1, operand2);

            Assert.AreEqual<Expression>(operand1, target.Operand1, "Operand1 set improperly.");
            Assert.AreEqual<Expression>(operand2, target.Operand2, "Operand2 set improperly.");
        }
        public void IsLeftAssociateTest()
        {
            Expression operand1 = new DummyExpression(); // TODO: Initialize to an appropriate value
            Expression operand2 = new DummyExpression(); // TODO: Initialize to an appropriate value
            AddExpression target = new AddExpression(operand1, operand2); // TODO: Initialize to an appropriate value

            bool expected = true; // TODO: Initialize to an appropriate value
            bool actual;
            actual = target.IsLeftAssociate();

            Assert.AreEqual<Boolean>(expected, actual, "Operator should be left associative");
        }
        public void GetOperatorPrecedenceTest()
        {
            Expression operand1 = new DummyExpression();
            Expression operand2 = new DummyExpression();
            AddExpression target = new AddExpression(operand1, operand2); // TODO: Initialize to an appropriate value

            int expected = 2; // TODO: Initialize to an appropriate value
            int actual;
            actual = target.GetOperatorPrecedence();

            Assert.AreEqual<int>(expected, actual, "Operator precedence not set properly.");
        }
Exemple #4
0
        static void Main(string[] args)
        {
            var variableLht = new ConstantExpression(12);
            var variableRgt = new ConstantExpression(4);

            var add = new AddExpression(variableLht, variableRgt);

            var div = new DivExpression(add, variableRgt);

            var axa = div.Clone();

            Print(div);
            Print(axa);

            Console.Read();
        }
        public void SolveTest()
        {
            Expression operand1 = new ValueExpression(3); // TODO: Initialize to an appropriate value
            Expression operand2 = new ValueExpression(4); // TODO: Initialize to an appropriate value
            AddExpression target = new AddExpression(operand1, operand2); // TODO: Initialize to an appropriate value

            Expression expected = new ValueExpression(7); // TODO: Initialize to an appropriate value
            Expression actual;
            actual = target.Solve();
            Assert.AreEqual<Double>(((ValueExpression)expected).GetValue(), ((ValueExpression)actual).GetValue());
        }