Exemple #1
0
        /**
         * @param areaRefString in Excel notation e.g. 'D2:E97'
         * @param dValues array of evaluated values for the area reference
         * @param rowNum 1-based
         * @param colNum 1-based, pass -1 to signify argument not present
         */
        private static void ConfirmAreaEval(String areaRefString, double[] dValues,
                                            int rowNum, int colNum, double expectedResult)
        {
            ValueEval[] values = new ValueEval[dValues.Length];
            for (int i = 0; i < values.Length; i++)
            {
                values[i] = new NumberEval(dValues[i]);
            }
            AreaEval arg0 = EvalFactory.CreateAreaEval(areaRefString, values);


            ValueEval[] args;
            if (colNum > 0)
            {
                args = new ValueEval[] { arg0, new NumberEval(rowNum), new NumberEval(colNum), };
            }
            else
            {
                args = new ValueEval[] { arg0, new NumberEval(rowNum), };
            }

            double actual = NumericFunctionInvoker.Invoke(new Index(), args);

            Assert.AreEqual(expectedResult, actual, 0D);
        }
Exemple #2
0
        private static void ConfirmCountIf(int expected, AreaEval range, ValueEval criteria)
        {
            ValueEval[] args   = { range, criteria, };
            double      result = NumericFunctionInvoker.Invoke(new Countif(), args);

            Assert.AreEqual(expected, result, 0);
        }
Exemple #3
0
        private static void ConfirmRowsFunc(String areaRefStr, int nCols, int nRows)
        {
            ValueEval[] args = { EvalFactory.CreateAreaEval(areaRefStr, new ValueEval[nCols * nRows]), };

            double actual = NumericFunctionInvoker.Invoke(new Rows(), args);

            Assert.AreEqual(nRows, actual, 0D);
        }
Exemple #4
0
        public void TestRows()
        {
            ConfirmRowsFunc("A1:F1", 6, 1);
            ConfirmRowsFunc("A1:C2", 3, 2);
            ConfirmRowsFunc("A1:B3", 2, 3);
            ConfirmRowsFunc("A1:A6", 1, 6);

            ValueEval[] args   = { EvalFactory.CreateRefEval("C5"), };
            double      actual = NumericFunctionInvoker.Invoke(new Rows(), args);

            Assert.AreEqual(1, actual, 0D);
        }
Exemple #5
0
 public void TestRow()
 {
     Function tarGet = new Row();
     {
         ValueEval[] args   = { EvalFactory.CreateRefEval("C5"), };
         double      actual = NumericFunctionInvoker.Invoke(tarGet, args);
         Assert.AreEqual(5, actual, 0D);
     }
     {
         ValueEval[] args   = { EvalFactory.CreateAreaEval("E2:H12", new ValueEval[44]), };
         double      actual = NumericFunctionInvoker.Invoke(tarGet, args);
         Assert.AreEqual(2, actual, 0D);
     }
 }
Exemple #6
0
        public void TestCountIfWithCriteriaReference()
        {
            ValueEval[] values =
            {
                new NumberEval(22),
                new NumberEval(25),
                new NumberEval(21),
                new NumberEval(25),
                new NumberEval(25),
                new NumberEval(25),
            };
            AreaEval arg0 = EvalFactory.CreateAreaEval("C1:C6", values);

            ValueEval criteriaArg = EvalFactory.CreateRefEval("A1", new NumberEval(25));

            ValueEval[] args = { arg0, criteriaArg, };

            double actual = NumericFunctionInvoker.Invoke(new Countif(), args);

            Assert.AreEqual(4, actual, 0D);
        }
Exemple #7
0
        private static void ConfirmCountA(int expected, ValueEval[] args)
        {
            double result = NumericFunctionInvoker.Invoke(new Counta(), args);

            Assert.AreEqual(expected, result, 0);
        }