コード例 #1
0
ファイル: TestHSSFWorkbook.cs プロジェクト: mdjasim/npoi
 public void TestSheetSerializeSizeMisMatch_bug45066()
 {
     HSSFWorkbook wb = new HSSFWorkbook();
     InternalSheet sheet = ((HSSFSheet)wb.CreateSheet("Sheet1")).Sheet;
     IList sheetRecords = sheet.Records;
     // one way (of many) to cause the discrepancy is with a badly behaved record:
     sheetRecords.Add(new BadlyBehavedRecord());
     // There is also much logic inside Sheet that (if buggy) might also cause the discrepancy
     try
     {
         wb.GetBytes();
         throw new AssertionException("Identified bug 45066 a");
     }
     catch (InvalidOperationException e)
     {
         // Expected badly behaved sheet record to cause exception
         Assert.IsTrue(e.Message.StartsWith("Actual serialized sheet size"));
     }
 }