Exemplo n.º 1
0
        public void TestMissingInputCell()
        {
            HSSFWorkbook wb = CreateWorkbook();

            ForkedEvaluator fe = ForkedEvaluator.Create(wb, null, null);

            // attempt update input at cell A2 (which is missing)
            try
            {
                fe.UpdateCell("Inputs", 1, 0, new NumberEval(4.0));
                throw new AssertionException(
                          "Expected exception to be thrown due to missing input cell");
            }
            catch (NullReferenceException e)
            {
                // TODO: Port
                //if (e.TargetSite.Equals("IdentityKey"))
                //{
                //    throw new AssertionException("Identified bug with update of missing input cell");
                //}
                throw e;
            }
            catch (InvalidOperationException e)
            {
                if (e.Message.Equals(
                        "Underlying cell 'A2' is missing in master sheet."))
                {
                    // expected during successful Test
                }
                else
                {
                    throw e;
                }
            }
        }
Exemplo n.º 2
0
        public void TestBasic()
        {
            IWorkbook wb = CreateWorkbook();

            // The stability classifier is useful to reduce memory consumption of caching logic
            IStabilityClassifier stabilityClassifier = new StabilityClassifier();

            ForkedEvaluator fe1 = ForkedEvaluator.Create(wb, stabilityClassifier, null);
            ForkedEvaluator fe2 = ForkedEvaluator.Create(wb, stabilityClassifier, null);

            // fe1 and fe2 can be used concurrently on separate threads

            fe1.UpdateCell("Inputs", 0, 0, new NumberEval(4.0));
            fe1.UpdateCell("Inputs", 0, 1, new NumberEval(1.1));

            fe2.UpdateCell("Inputs", 0, 0, new NumberEval(1.2));
            fe2.UpdateCell("Inputs", 0, 1, new NumberEval(2.0));

            Assert.AreEqual(18.9, ((NumberEval)fe1.Evaluate("Calculations", 0, 0)).NumberValue, 0.0);
            Assert.AreEqual(4.0, ((NumberEval)fe2.Evaluate("Calculations", 0, 0)).NumberValue, 0.0);
            fe1.UpdateCell("Inputs", 0, 0, new NumberEval(3.0));
            Assert.AreEqual(13.9, ((NumberEval)fe1.Evaluate("Calculations", 0, 0)).NumberValue, 0.0);

            wb.Close();
        }