コード例 #1
0
 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());
 }
コード例 #2
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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
 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);
     }
 }
コード例 #5
0
        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");
        }