public void TestFontStuff() { InternalWorkbook wb = TestHSSFWorkbook.GetInternalWorkbook(new HSSFWorkbook()); Assert.AreEqual(4, wb.NumberOfFontRecords); Assert.AreEqual(68, wb.Records.Count); FontRecord f1 = wb.GetFontRecordAt(0); FontRecord f4 = wb.GetFontRecordAt(3); Assert.AreEqual(0, wb.GetFontIndex(f1)); Assert.AreEqual(3, wb.GetFontIndex(f4)); Assert.AreEqual(f1, wb.GetFontRecordAt(0)); Assert.AreEqual(f4, wb.GetFontRecordAt(3)); // There is no 4! new ones go in at 5 FontRecord n = wb.CreateNewFont(); Assert.AreEqual(69, wb.Records.Count); Assert.AreEqual(5, wb.NumberOfFontRecords); Assert.AreEqual(5, wb.GetFontIndex(n)); Assert.AreEqual(n, wb.GetFontRecordAt(5)); // And another FontRecord n6 = wb.CreateNewFont(); Assert.AreEqual(70, wb.Records.Count); Assert.AreEqual(6, wb.NumberOfFontRecords); Assert.AreEqual(6, wb.GetFontIndex(n6)); Assert.AreEqual(n6, wb.GetFontRecordAt(6)); // Now remove the one formerly at 5 Assert.AreEqual(70, wb.Records.Count); wb.RemoveFontRecord(n); // Check that 6 has gone to 5 Assert.AreEqual(69, wb.Records.Count); Assert.AreEqual(5, wb.NumberOfFontRecords); Assert.AreEqual(5, wb.GetFontIndex(n6)); Assert.AreEqual(n6, wb.GetFontRecordAt(5)); // Check that the earlier ones are unChanged Assert.AreEqual(0, wb.GetFontIndex(f1)); Assert.AreEqual(3, wb.GetFontIndex(f4)); Assert.AreEqual(f1, wb.GetFontRecordAt(0)); Assert.AreEqual(f4, wb.GetFontRecordAt(3)); // Finally, add another one FontRecord n7 = wb.CreateNewFont(); Assert.AreEqual(70, wb.Records.Count); Assert.AreEqual(6, wb.NumberOfFontRecords); Assert.AreEqual(6, wb.GetFontIndex(n7)); Assert.AreEqual(n7, wb.GetFontRecordAt(6)); }