public void Test45338() { HSSFWorkbook wb = new HSSFWorkbook(); Assert.AreEqual(4, wb.NumberOfFonts); ISheet s = wb.CreateSheet(); s.CreateRow(0); s.CreateRow(1); ICell c1 = s.GetRow(0).CreateCell(0); ICell c2 = s.GetRow(1).CreateCell(0); Assert.AreEqual(4, wb.NumberOfFonts); IFont f1 = wb.GetFontAt((short)0); Assert.AreEqual(400, f1.Boldweight); // Check that asking for the same font // multiple times gives you the same thing. // Otherwise, our Tests wouldn't work! Assert.AreEqual( wb.GetFontAt((short)0), wb.GetFontAt((short)0) ); Assert.AreEqual( wb.GetFontAt((short)2), wb.GetFontAt((short)2) ); Assert.IsTrue( wb.GetFontAt((short)0) != wb.GetFontAt((short)2) ); // Look for a new font we have // yet to Add Assert.IsNull( wb.FindFont( (short)11, (short)123, (short)22, "Thingy", false, true, (short)2, (byte)2 ) ); IFont nf = wb.CreateFont(); Assert.AreEqual(5, wb.NumberOfFonts); Assert.AreEqual(5, nf.Index); Assert.AreEqual(nf, wb.GetFontAt((short)5)); nf.Boldweight = ((short)11); nf.Color = ((short)123); nf.FontHeight = ((short)22); nf.FontName = ("Thingy"); nf.IsItalic = (false); nf.IsStrikeout = (true); nf.TypeOffset = ((short)2); nf.Underline = ((byte)2); Assert.AreEqual(5, wb.NumberOfFonts); Assert.AreEqual(nf, wb.GetFontAt((short)5)); // Find it now Assert.IsNotNull( wb.FindFont( (short)11, (short)123, (short)22, "Thingy", false, true, (short)2, (byte)2 ) ); Assert.AreEqual( 5, wb.FindFont( (short)11, (short)123, (short)22, "Thingy", false, true, (short)2, (byte)2 ).Index ); Assert.AreEqual(nf, wb.FindFont( (short)11, (short)123, (short)22, "Thingy", false, true, (short)2, (byte)2 ) ); }