public void TestToString() { FormulaShifter shifter = FormulaShifter.CreateForRowShift(0, "sheet", 123, 456, 789, SpreadsheetVersion.EXCEL2007); Assert.IsNotNull(shifter); Assert.IsNotNull(shifter.ToString()); Assert.IsTrue(shifter.ToString().Contains("123")); Assert.IsTrue(shifter.ToString().Contains("456")); Assert.IsTrue(shifter.ToString().Contains("789")); }
public void TestShiftFormulasAddCondFormat_bug46547() { // Create a sheet with data validity (similar to bugzilla attachment id=23131). Sheet sheet = Sheet.CreateSheet(); IList sheetRecs = sheet.Records; Assert.AreEqual(23, sheetRecs.Count); FormulaShifter shifter = FormulaShifter.CreateForRowShift(0, 0, 0, 1); sheet.UpdateFormulasAfterCellShift(shifter, 0); if (sheetRecs.Count == 24 && sheetRecs[22] is ConditionalFormattingTable) { throw new AssertFailedException("Identified bug 46547a"); } Assert.AreEqual(23, sheetRecs.Count); }
public void TestShiftFormulasAddCondFormat_bug46547() { // Create a sheet with data validity (similar to bugzilla attachment id=23131). InternalSheet sheet = InternalSheet.CreateSheet(); IList sheetRecs = sheet.Records; //Assert.AreEqual(23, sheetRecs.Count); Assert.AreEqual(24, sheetRecs.Count); //for SheetExtRecord FormulaShifter shifter = FormulaShifter.CreateForRowShift(0, "", 0, 0, 1, SpreadsheetVersion.EXCEL97); sheet.UpdateFormulasAfterCellShift(shifter, 0); if (sheetRecs.Count == 25 && sheetRecs[22] is ConditionalFormattingTable) { throw new AssertionException("Identified bug 46547a"); } //Assert.AreEqual(23, sheetRecs.Count); Assert.AreEqual(24, sheetRecs.Count); //for SheetExtRecord }
public void TestInvalidArgument() { try { FormulaShifter.CreateForRowShift(1, "name", 1, 2, 0, SpreadsheetVersion.EXCEL97); Assert.Fail("Should catch exception here"); } catch (ArgumentException e) { // expected here } try { FormulaShifter.CreateForRowShift(1, "name", 2, 1, 2, SpreadsheetVersion.EXCEL97); Assert.Fail("Should catch exception here"); } catch (ArgumentException e) { // expected here } }
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); }
public void TestConstructor() { Assert.IsNotNull(FormulaShifter.CreateForRowShift(1, "name", 1, 2, 2)); }