Esempio n. 1
0
        public void EvaluateTests(object value)
        {
            var processor  = TestExtensions.CreateProcessor();
            var expression = new ExpressionMock(() => value);
            var cell       = new Cell(default(CellAddress), expression);

            Assert.AreEqual(value, cell.Evaluate(processor));
            Assert.AreEqual(processor, expression.Processor);
        }
        public void CellRefereceExpressionTest(object value)
        {
            var cellRefereceExpression = new CellRefereceExpression(new CellAddress(0, 1));
            var processor = TestExtensions.CreateProcessor(
                cellRefereceExpression,
                new ConstantExpression(value));
            var result = cellRefereceExpression.Evaluate(processor);

            Assert.AreEqual(value, result);
        }
        public void UnaryExpressionTest(object value, object result)
        {
            var valueExpression = new ExpressionMock(() => value);
            var @operator       = new OperatorMock(() => result);
            var expression      = new Core.Cells.Expressions.UnaryExpression(@operator, valueExpression);

            var processor = TestExtensions.CreateProcessor();

            Assert.AreEqual(result, expression.Evaluate(processor));
            Assert.AreEqual(processor, valueExpression.Processor);
            Assert.AreEqual(value, @operator.Value);
        }
        public void BinaryExpressionTest(object left, object right, object result)
        {
            var leftExpression = new ExpressionMock(() => left);
            var rightExpr      = new ExpressionMock(() => right);
            var @operator      = new OperatorMock(() => result);
            var expression     = new Core.Cells.Expressions.BinaryExpression(leftExpression, @operator, rightExpr);

            var processor = TestExtensions.CreateProcessor();

            Assert.AreEqual(result, expression.Evaluate(processor));
            Assert.AreEqual(processor, leftExpression.Processor, "Left expression");
            Assert.AreEqual(processor, rightExpr.Processor, "Right expression");

            Assert.AreEqual(left, @operator.Left, "Left value");
            Assert.AreEqual(right, @operator.Right, "Right value");
        }