Ejemplo n.º 1
0
        public void testUnimplemented()
        {
            IWorkbook         wb = new HSSFWorkbook();
            IFormulaEvaluator fe = wb.GetCreationHelper().CreateFormulaEvaluator();
            ISheet            sh = wb.CreateSheet();
            ICell             a3 = sh.CreateRow(3).CreateCell(1);

            a3.CellFormula = ("SUBTOTAL(8,B2:B3)");
            try
            {
                fe.EvaluateAll();
                Assert.Fail("Should catch an NotImplementedFunctionException here, adjust these tests if it was actually implemented");
            }
            catch (NotImplementedException)
            {
                // expected here
            }
            a3.CellFormula = ("SUBTOTAL(10,B2:B3)");
            try
            {
                fe.EvaluateAll();
                Assert.Fail("Should catch an NotImplementedFunctionException here, adjust these tests if it was actually implemented");
            }
            catch (NotImplementedException)
            {
                // expected here
            }
            a3.CellFormula = ("SUBTOTAL(11,B2:B3)");
            try
            {
                fe.EvaluateAll();
                Assert.Fail("Should catch an NotImplementedFunctionException here, adjust these tests if it was actually implemented");
            }
            catch (NotImplementedException)
            {
                // expected here
            }
            a3.CellFormula = ("SUBTOTAL(107,B2:B3)");
            try
            {
                fe.EvaluateAll();
                Assert.Fail("Should catch an NotImplementedFunctionException here, adjust these tests if it was actually implemented");
            }
            catch (NotImplementedException)
            {
                // expected here
            }
            a3.CellFormula = ("SUBTOTAL(0,B2:B3)");
            fe.EvaluateAll();
            Assert.AreEqual(FormulaError.VALUE.Code, a3.ErrorCellValue);
            try
            {
                a3.CellFormula = ("SUBTOTAL(9)");
                Assert.Fail("Should catch an exception here");
            }
            catch (FormulaParseException)
            {
                // expected here
            }
            try
            {
                a3.CellFormula = ("SUBTOTAL()");
                Assert.Fail("Should catch an exception here");
            }
            catch (FormulaParseException)
            {
                // expected here
            }
            Subtotal subtotal = new Subtotal();

            Assert.AreEqual(ErrorEval.VALUE_INVALID, subtotal.Evaluate(new ValueEval[] { }, 0, 0));
        }