public static string ToHtml <T>(this UniversalGrid <T> grid, string tableClass = null) { using (var output = new StringWriter()) { grid.ToHtml(output, tableClass); return(output.ToString()); } }
public void ToHtml_ReturnsValidXhtmlTable() { var grid = new UniversalGrid <string>(10, 10); grid.SetObject("X", 5, 5); var html = grid.ToHtml(tableClass: "tbl"); var htmlDoc = XDocument.Parse(html); Assert.That(htmlDoc.Root.Name.LocalName, Is.EqualTo("table")); Assert.That(htmlDoc.Root.Attribute("class").Value, Is.EqualTo("tbl")); Assert.That(htmlDoc.Root.Elements().ElementAt(5).Elements().ElementAt(5).Value, Is.EqualTo("X")); Console.WriteLine(htmlDoc); }
public void ToHtml_SetsColour() { var grid = new UniversalGrid <string>(10, 10); var obj = grid.SetObject("X", 5, 5); obj.Colour = new Drawing.Colour() { R = 255, A = 255 }; var html = grid.ToHtml(); var htmlDoc = XDocument.Parse(html); Assert.That(htmlDoc.Root.Elements().ElementAt(5).Elements().ElementAt(5).Attribute("style").Value, Is.EqualTo("color: #ff0000")); Console.WriteLine(htmlDoc); }