Пример #1
0
        public void EmptyLiteral()
        {
            var doc       = new TestCompiledDocument();
            var evaluator = new SyntaxEvaluator(doc, Substitute.For <IFunctionProvider>());

            Assert.Equal(0, evaluator.GetCell <int>(new Cell("A1")));
        }
Пример #2
0
        public void SingleLiteral()
        {
            var doc = new TestCompiledDocument
            {
                { new Cell("A1"), Statement.NewLiteral(Literal.NewNumber(Number.NewInt(2))) }
            };

            var evaluator = new SyntaxEvaluator(doc, Substitute.For <IFunctionProvider>());

            Assert.Equal(2, evaluator.GetCell <int>(new Cell("A1")));
        }
Пример #3
0
        public void SingleBinaryAddition()
        {
            var doc = new TestCompiledDocument
            {
                { new Cell("A1"), Statement.NewFormula(
                      Expression.NewBinaryExpression(
                          Expression.NewLiteralExpression(
                              Literal.NewNumber(Number.NewInt(2))),
                          Operation.Add,
                          Expression.NewLiteralExpression(
                              Literal.NewNumber(Number.NewInt(3))))) }
            };

            var evaluator = new SyntaxEvaluator(doc, Substitute.For <IFunctionProvider>());

            Assert.Equal(5, evaluator.GetCell <int>(new Cell("A1")));
        }