private Exception ExceptionTest(Exception value)
 {
     var expression = new ExpressionMock(() => { throw value; });
     var processor = CreateProcessor(expression);
     var results = processor.Evaluate(new SimpleProcessingStrategy()).Values.ToArray();
     Assert.AreEqual(processor, expression.Processor);
     return Cast<Exception>(results.First());
 }
        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 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 EvaluateTest(object value)
 {
     var expression = new ExpressionMock(() => value);
     var processor = CreateProcessor(expression);
     for (var i = 0; i < 5; i++)
     {
         var result = processor.Evaluate(new SimpleProcessingStrategy());
         Assert.AreEqual(value, result.Values.First());
         Assert.AreEqual(processor, expression.Processor);
         
         //check that value cashed, and expression Evaluate method calls only once.
         Assert.AreEqual(1, expression.EvaluateCallCount);
     }
 }
        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");
        }