public void TestExceptions() { NPOI.SS.Formula.Functions.Function func = new Function2(); try { FunctionEval.RegisterFunction("SUM", func); Assert.Fail("expectecd exception"); } catch (ArgumentException e) { Assert.AreEqual("POI already implememts SUM" + ". You cannot override POI's implementations of Excel functions", e.Message); } try { FunctionEval.RegisterFunction("SUMXXX", func); Assert.Fail("expectecd exception"); } catch (ArgumentException e) { Assert.AreEqual("Unknown function: SUMXXX", e.Message); } try { FunctionEval.RegisterFunction("ISODD", func); Assert.Fail("expectecd exception"); } catch (ArgumentException e) { Assert.AreEqual("ISODD is a function from the Excel Analysis Toolpack. " + "Use AnalysisToolpack.RegisterFunction(String name, FreeRefFunction func) instead.", e.Message); } FreeRefFunction atpFunc = new FreeRefFunction2();/*FreeRefFunction() { public ValueEval Evaluate(ValueEval[] args, OperationEvaluationContext ec) { return ErrorEval.NUM_ERROR; } };*/ try { AnalysisToolPak.RegisterFunction("ISODD", atpFunc); Assert.Fail("expectecd exception"); } catch (ArgumentException e) { Assert.AreEqual("POI already implememts ISODD" + ". You cannot override POI's implementations of Excel functions", e.Message); } try { AnalysisToolPak.RegisterFunction("ISODDXXX", atpFunc); Assert.Fail("expectecd exception"); } catch (ArgumentException e) { Assert.AreEqual("ISODDXXX is not a function from the Excel Analysis Toolpack.", e.Message); } try { AnalysisToolPak.RegisterFunction("SUM", atpFunc); Assert.Fail("expectecd exception"); } catch (ArgumentException e) { Assert.AreEqual("SUM is a built-in Excel function. " + "Use FunctoinEval.RegisterFunction(String name, Function func) instead.", e.Message); } }
public void TestExceptions() { NPOI.SS.Formula.Functions.Function func = new Function2(); try { FunctionEval.RegisterFunction("SUM", func); Assert.Fail("expectecd exception"); } catch (ArgumentException e) { Assert.AreEqual("POI already implememts SUM" + ". You cannot override POI's implementations of Excel functions", e.Message); } try { FunctionEval.RegisterFunction("SUMXXX", func); Assert.Fail("expectecd exception"); } catch (ArgumentException e) { Assert.AreEqual("Unknown function: SUMXXX", e.Message); } try { FunctionEval.RegisterFunction("ISODD", func); Assert.Fail("expectecd exception"); } catch (ArgumentException e) { Assert.AreEqual("ISODD is a function from the Excel Analysis Toolpack. " + "Use AnalysisToolpack.RegisterFunction(String name, FreeRefFunction func) instead.", e.Message); } FreeRefFunction atpFunc = new FreeRefFunction2();/*FreeRefFunction() { * public ValueEval Evaluate(ValueEval[] args, OperationEvaluationContext ec) { * return ErrorEval.NUM_ERROR; * } * };*/ try { AnalysisToolPak.RegisterFunction("ISODD", atpFunc); Assert.Fail("expectecd exception"); } catch (ArgumentException e) { Assert.AreEqual("POI already implememts ISODD" + ". You cannot override POI's implementations of Excel functions", e.Message); } try { AnalysisToolPak.RegisterFunction("ISODDXXX", atpFunc); Assert.Fail("expectecd exception"); } catch (ArgumentException e) { Assert.AreEqual("ISODDXXX is not a function from the Excel Analysis Toolpack.", e.Message); } try { AnalysisToolPak.RegisterFunction("SUM", atpFunc); Assert.Fail("expectecd exception"); } catch (ArgumentException e) { Assert.AreEqual("SUM is a built-in Excel function. " + "Use FunctoinEval.RegisterFunction(String name, Function func) instead.", e.Message); } }