private static void ConfirmAreaShift(AreaPtg aptg, int firstRowMoved, int lastRowMoved, int numberRowsMoved, int expectedAreaFirstRow, int expectedAreaLastRow) { FormulaShifter fs = FormulaShifter.CreateForRowShift(0, "", firstRowMoved, lastRowMoved, numberRowsMoved, SpreadsheetVersion.EXCEL2007); bool expectedChanged = aptg.FirstRow != expectedAreaFirstRow || aptg.LastRow != expectedAreaLastRow; AreaPtg copyPtg = (AreaPtg)aptg.Copy(); // clone so we can re-use aptg in calling method Ptg[] ptgs = { copyPtg, }; bool actualChanged = fs.AdjustFormula(ptgs, 0); if (expectedAreaFirstRow < 0) { Assert.AreEqual(typeof(AreaErrPtg), ptgs[0].GetType()); return; } Assert.AreEqual(expectedChanged, actualChanged); Assert.AreEqual(copyPtg, ptgs[0]); // expected to change in place (although this is not a strict requirement) Assert.AreEqual(expectedAreaFirstRow, copyPtg.FirstRow); Assert.AreEqual(expectedAreaLastRow, copyPtg.LastRow); }
private static void ConfirmAreaCopy(AreaPtg aptg, int firstRowCopied, int lastRowCopied, int rowOffset, int expectedFirstRow, int expectedLastRow, bool expectedChanged) { AreaPtg copyPtg = (AreaPtg)aptg.Copy(); // clone so we can re-use aptg in calling method Ptg[] ptgs = { copyPtg, }; FormulaShifter fs = FormulaShifter.CreateForRowCopy(0, null, firstRowCopied, lastRowCopied, rowOffset, SpreadsheetVersion.EXCEL2007); bool actualChanged = fs.AdjustFormula(ptgs, 0); // DeletedAreaRef if (expectedFirstRow < 0 || expectedLastRow < 0) { Assert.AreEqual(typeof(AreaErrPtg), ptgs[0].GetType(), "Reference should have shifted off worksheet, producing #REF! error: " + ptgs[0]); return; } Assert.AreEqual(expectedChanged, actualChanged, "Should this AreaPtg change due to row copy?"); Assert.AreEqual(copyPtg, ptgs[0], "AreaPtgs should be modified in-place when a row containing the AreaPtg is copied"); // expected to change in place (although this is not a strict requirement) Assert.AreEqual(expectedFirstRow, copyPtg.FirstRow, "AreaPtg first row"); Assert.AreEqual(expectedLastRow, copyPtg.LastRow, "AreaPtg last row"); }