public void TestAddRemoveArrayFormulas_recordUpdates() { IWorkbook wb = new HSSFWorkbook(); ISheet s = wb.CreateSheet("Sheet1"); ICellRange <ICell> cr = s.SetArrayFormula("123", CellRangeAddress.ValueOf("B5:C6")); Record[] recs; int ix; recs = RecordInspector.GetRecords(s, 0); ix = FindRecordOfType(recs, typeof(ArrayRecord), 0); ConfirmRecordClass(recs, ix - 1, typeof(FormulaRecord)); ConfirmRecordClass(recs, ix + 1, typeof(FormulaRecord)); ConfirmRecordClass(recs, ix + 2, typeof(FormulaRecord)); ConfirmRecordClass(recs, ix + 3, typeof(FormulaRecord)); // just one array record Assert.IsTrue(FindRecordOfType(recs, typeof(ArrayRecord), ix + 1) < 0); s.RemoveArrayFormula(cr.TopLeftCell); // Make sure the array formula has been Removed properly recs = RecordInspector.GetRecords(s, 0); Assert.IsTrue(FindRecordOfType(recs, typeof(ArrayRecord), 0) < 0); Assert.IsTrue(FindRecordOfType(recs, typeof(FormulaRecord), 0) < 0); RowRecordsAggregate rra = ((HSSFSheet)s).Sheet.RowsAggregate; SharedValueManager svm = TestSharedValueManager.ExtractFromRRA(rra); if (svm.GetArrayRecord(4, 1) != null) { throw new AssertionException("Array record was not cleaned up properly."); } }
public void TestUnknownContinue_bug46280() { byte[] dummtydata = Encoding.GetEncoding(1252).GetBytes("dummydata"); byte[] moredummydata = Encoding.GetEncoding(1252).GetBytes("moredummydata"); Record[] inRecs = { new RowRecord(0), new NumberRecord(), new UnknownRecord(0x5555,dummtydata), new ContinueRecord(moredummydata) //new UnknownRecord(0x5555, "dummydata".getBytes()), //new ContinueRecord("moredummydata".getBytes()), }; RecordStream rs = new RecordStream(Arrays.AsList(inRecs), 0); RowRecordsAggregate rra; try { rra = new RowRecordsAggregate(rs, SharedValueManager.CreateEmpty()); } catch (RuntimeException e) { if (e.Message.StartsWith("Unexpected record type")) { Assert.Fail("Identified bug 46280a"); } throw e; } RecordInspector.RecordCollector rv = new RecordInspector.RecordCollector(); rra.VisitContainedRecords(rv); Record[] outRecs = rv.Records; Assert.AreEqual(5, outRecs.Length); }
/** * Convenience test method for digging the {@link SharedValueManager} out of a * {@link RowRecordsAggregate}. */ public static SharedValueManager ExtractFromRRA(RowRecordsAggregate rra) { FieldInfo f; try { f = typeof(RowRecordsAggregate).GetTypeInfo().GetField("_sharedValueManager", BindingFlags.NonPublic | BindingFlags.Instance); //typeof(RowRecordsAggregate).("_sharedValueManager"); } catch (NotSupportedException e) { throw new RuntimeException(e); } //f.s //f.setAccessible(true); try { return((SharedValueManager)f.GetValue(rra)); } catch (ArgumentException e) { throw new RuntimeException(e); } catch (FieldAccessException e) { throw new RuntimeException(e); } }
public void TestRowGet() { RowRecordsAggregate rra = new RowRecordsAggregate(); RowRecord rr = new RowRecord(4); rra.InsertRow(rr); rra.InsertRow(new RowRecord(1)); RowRecord rr1 = rra.GetRow(4); Assert.IsNotNull(rr1); Assert.AreEqual(4, rr1.RowNumber, "Row number is1 1"); Assert.IsTrue(rr1 == rr, "Row record retrieved is1 identical"); }