예제 #1
0
        public void TestBlankCellChangedToValueCell()
        {
            TestCases.CultureShim.SetCurrentCulture("en-US");

            MySheet ms = new MySheet();

            ms.SetCellFormula("A1", "B1+2.2");
            ms.SetCellValue("B1", 1.5);
            ms.ClearAllCachedResultValues();
            ms.ClearCell("B1");
            ms.GetAndClearLog();

            ConfirmEvaluate(ms, "A1", 2.2);
            ConfirmLog(ms, new String[] {
                "start A1 B1+2.2",
                "end A1 2.2",
            });
            ms.SetCellValue("B1", 0.4);
            ConfirmLog(ms, new String[] {
                "changeFromBlank B1 0.4",
                "clear A1",
            });

            ConfirmEvaluate(ms, "A1", 2.6);
            ConfirmLog(ms, new String[] {
                "start A1 B1+2.2",
                "hit B1 0.4",
                "end A1 2.6",
            });
        }
예제 #2
0
        private static MySheet CreateMediumComplex()
        {
            MySheet ms = new MySheet();

            // plain data in D1:F3
            ms.SetCellValue("D1", 12);
            ms.SetCellValue("E1", 13);
            ms.SetCellValue("D2", 14);
            ms.SetCellValue("E2", 15);
            ms.SetCellValue("D3", 16);
            ms.SetCellValue("E3", 17);


            ms.SetCellFormula("C1", "SUM(D1:E2)");
            ms.SetCellFormula("C2", "SUM(D2:E3)");
            ms.SetCellFormula("C3", "SUM(D3:E4)");

            ms.SetCellFormula("B1", "C2-C1");
            ms.SetCellFormula("B2", "B3*C1-C2");
            ms.SetCellFormula("B3", "2");

            ms.SetCellFormula("A1", "MAX(B1:B2)");
            ms.SetCellFormula("A2", "MIN(B3,D2:F2)");
            ms.SetCellFormula("A3", "B3*C3");

            // Clear all the logging from the above initialisation
            ms.GetAndClearLog();
            ms.ClearAllCachedResultValues();
            return(ms);
        }
예제 #3
0
        public void TestBlankCellChangedToValueCell()
        {
            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US");

            MySheet ms = new MySheet();

            ms.SetCellFormula("A1", "B1+2.2");
            ms.SetCellValue("B1", 1.5);
            ms.ClearAllCachedResultValues();
            ms.ClearCell("B1");
            ms.GetAndClearLog();

            ConfirmEvaluate(ms, "A1", 2.2);
            ConfirmLog(ms, new String[] {
                "start A1 B1+2.2",
                "end A1 2.2",
            });
            ms.SetCellValue("B1", 0.4);
            ConfirmLog(ms, new String[] {
                "changeFromBlank B1 0.4",
                "clear A1",
            });

            ConfirmEvaluate(ms, "A1", 2.6);
            ConfirmLog(ms, new String[] {
                "start A1 B1+2.2",
                "hit B1 0.4",
                "end A1 2.6",
            });
        }
예제 #4
0
        public void TestSimpleWithDependencyChange()
        {
            MySheet ms = new MySheet();

            ms.SetCellFormula("A1", "INDEX(C1:E1,1,B1)");
            ms.SetCellValue("B1", 1);
            ms.SetCellValue("C1", 17);
            ms.SetCellValue("D1", 18);
            ms.SetCellValue("E1", 19);
            ms.ClearAllCachedResultValues();
            ms.GetAndClearLog();

            ConfirmEvaluate(ms, "A1", 17);
            ConfirmLog(ms, new String[] {
                "start A1 INDEX(C1:E1,1,B1)",
                "value B1 1",
                "value C1 17",
                "end A1 17",
            });
            ms.SetCellValue("B1", 2);
            ms.GetAndClearLog();

            ConfirmEvaluate(ms, "A1", 18);
            ConfirmLog(ms, new String[] {
                "start A1 INDEX(C1:E1,1,B1)",
                "hit B1 2",
                "value D1 18",
                "end A1 18",
            });

            // change C1. Note - last time A1 Evaluated C1 was not used
            ms.SetCellValue("C1", 15);
            ms.GetAndClearLog();
            ConfirmEvaluate(ms, "A1", 18);
            ConfirmLog(ms, new String[] {
                "hit A1 18",
            });

            // but A1 still uses D1, so if it changes...
            ms.SetCellValue("D1", 25);
            ms.GetAndClearLog();
            ConfirmEvaluate(ms, "A1", 25);
            ConfirmLog(ms, new String[] {
                "start A1 INDEX(C1:E1,1,B1)",
                "hit B1 2",
                "hit D1 25",
                "end A1 25",
            });
        }
예제 #5
0
        public void TestBlankCells()
        {
            MySheet ms = new MySheet();

            ms.SetCellFormula("A1", "sum(B1:D4,B5:E6)");
            ms.SetCellValue("B1", 12);
            ms.ClearAllCachedResultValues();
            ms.GetAndClearLog();

            ConfirmEvaluate(ms, "A1", 12);
            ConfirmLog(ms, new String[] {
                "start A1 SUM(B1:D4,B5:E6)",
                "value B1 12",
                "end A1 12",
            });
            ms.SetCellValue("B6", 2);
            ms.GetAndClearLog();

            ConfirmEvaluate(ms, "A1", 14);
            ConfirmLog(ms, new String[] {
                "start A1 SUM(B1:D4,B5:E6)",
                "hit B1 12",
                "hit B6 2",
                "end A1 14",
            });
            ms.SetCellValue("E4", 2);
            ms.GetAndClearLog();

            ConfirmEvaluate(ms, "A1", 14);
            ConfirmLog(ms, new String[] {
                "hit A1 14",
            });

            ms.SetCellValue("D1", 1);
            ms.GetAndClearLog();

            ConfirmEvaluate(ms, "A1", 15);
            ConfirmLog(ms, new String[] {
                "start A1 SUM(B1:D4,B5:E6)",
                "hit B1 12",
                "hit D1 1",
                "hit B6 2",
                "end A1 15",
            });
        }