public void TestGetSetTopBorderColor() { //defaults Assert.AreEqual(IndexedColors.Black.Index, cellStyle.TopBorderColor); Assert.IsNull(cellStyle.GetTopBorderXSSFColor()); int num = stylesTable.GetBorders().Count; XSSFColor clr; //setting indexed color cellStyle.TopBorderColor = (IndexedColors.BlueGrey.Index); Assert.AreEqual(IndexedColors.BlueGrey.Index, cellStyle.TopBorderColor); clr = cellStyle.GetTopBorderXSSFColor(); Assert.IsTrue(clr.GetCTColor().IsSetIndexed()); Assert.AreEqual(IndexedColors.BlueGrey.Index, clr.Indexed); //a new border was added to the styles table Assert.AreEqual(num + 1, stylesTable.GetBorders().Count); //id of the Created border int borderId = (int)cellStyle.GetCoreXf().borderId; Assert.IsTrue(borderId > 0); //check Changes in the underlying xml bean CT_Border ctBorder = stylesTable.GetBorderAt(borderId).GetCTBorder(); Assert.AreEqual((uint)IndexedColors.BlueGrey.Index, ctBorder.top.color.indexed); //setting XSSFColor num = stylesTable.GetBorders().Count; clr = new XSSFColor(Color.Cyan); cellStyle.SetTopBorderColor(clr); Assert.AreEqual(clr.GetCTColor().ToString(), cellStyle.GetTopBorderXSSFColor().GetCTColor().ToString()); byte[] rgb = cellStyle.GetTopBorderXSSFColor().GetRgb(); Assert.AreEqual(Color.Cyan.ToArgb(), Color.FromArgb(rgb[0], rgb[1], rgb[2]).ToArgb()); //another border was added to the styles table Assert.AreEqual(num, stylesTable.GetBorders().Count); //passing null unsets the color cellStyle.SetTopBorderColor(null); Assert.IsNull(cellStyle.GetTopBorderXSSFColor()); }