Exemplo n.º 1
0
        public void TestAddCleanColIntoCols()
        {
            CT_Worksheet worksheet = new CT_Worksheet();
            ColumnHelper helper    = new ColumnHelper(worksheet);

            CT_Cols cols1 = new CT_Cols();
            CT_Col  col1  = cols1.AddNewCol();

            col1.min    = (1);
            col1.max    = (1);
            col1.width  = (88);
            col1.hidden = (true);
            CT_Col col2 = cols1.AddNewCol();

            col2.min = (2);
            col2.max = (3);
            CT_Col col3 = cols1.AddNewCol();

            col3.min = (13);
            col3.max = (16750);
            Assert.AreEqual(3, cols1.sizeOfColArray());
            CT_Col col4 = cols1.AddNewCol();

            col4.min = (8);
            col4.max = (9);
            Assert.AreEqual(4, cols1.sizeOfColArray());

            // No overlap
            helper.addCleanColIntoCols(cols1, createCol(4, 5));
            Assert.AreEqual(5, cols1.sizeOfColArray());

            // Overlaps with 8 - 9 (overlap and after replacements required)
            CT_Col col6 = createCol(8, 11);

            col6.hidden = (true);
            helper.AddCleanColIntoCols(cols1, col6);
            Assert.AreEqual(6, cols1.sizeOfColArray());

            // Overlaps with 8 - 9 (before and overlap replacements required)
            CT_Col col7 = createCol(6, 8);

            col7.width = (17.0);
            helper.AddCleanColIntoCols(cols1, col7);
            Assert.AreEqual(8, cols1.sizeOfColArray());

            // Overlaps with 13 - 16750 (before, overlap and after replacements required)
            helper.addCleanColIntoCols(cols1, createCol(20, 30));
            Assert.AreEqual(10, cols1.sizeOfColArray());

            // Overlaps with 20 - 30 (before, overlap and after replacements required)
            helper.addCleanColIntoCols(cols1, createCol(25, 27));

            // TODO - assert something interesting
            Assert.AreEqual(12, cols1.col.Count);
            Assert.AreEqual(1u, cols1.GetColArray(0).min);
            Assert.AreEqual(16750u, cols1.GetColArray(11).max);
        }
Exemplo n.º 2
0
        /**
         * Creates and adds a hidden column and then a best fit column with the given min/max pairs.
         * Suitable for testing handling of overlap.
         */
        private CT_Cols createHiddenAndBestFitColsWithHelper(int hiddenMin, int hiddenMax, int bestFitMin, int bestFitMax)
        {
            CT_Worksheet worksheet = new CT_Worksheet();
            ColumnHelper helper    = new ColumnHelper(worksheet);
            CT_Cols      cols      = worksheet.GetColsArray(0);
            CT_Col       hidden    = createCol(hiddenMin, hiddenMax);

            hidden.hidden = (true);
            helper.addCleanColIntoCols(cols, hidden);
            CT_Col bestFit = createCol(bestFitMin, bestFitMax);

            bestFit.bestFit = (true);
            helper.addCleanColIntoCols(cols, bestFit);
            return(cols);
        }