コード例 #1
0
        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.");
        }
コード例 #2
0
        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");
        }
コード例 #3
0
        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.");
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: Stan-Kudri/Expressions
        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();
        }
コード例 #5
0
        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());
        }