public void TestGridSortHeaderRenderer() { var settings = new QueryStringSortSettings(); var renderer = new QueryStringSortColumnHeaderRenderer(settings); var column = new GridColumn <TestModel, string>(c => c.Title, new TestGrid(Enumerable.Empty <TestModel>())); var htmlstring = renderer.Render(column); Assert.IsNotNull(htmlstring); var html = htmlstring.ToHtmlString(); Assert.IsTrue(!html.Contains("<a")); Assert.IsTrue(html.Contains("<span")); column.Sortable(true); htmlstring = renderer.Render(column); Assert.IsNotNull(htmlstring); html = htmlstring.ToHtmlString(); Assert.IsTrue(!string.IsNullOrWhiteSpace(html)); Assert.IsTrue(html.Contains("<a")); Assert.IsTrue(html.Contains("class=\"grid-header-title\"")); }
public void TestGridSortHeaderRenderer() { var settings = new QueryStringSortSettings(_query); var renderer = new QueryStringSortColumnHeaderRenderer(settings); var column = new GridColumn <TestModel, string>(c => c.Title, new TestGrid(Enumerable.Empty <TestModel>())); var htmlstring = renderer.Render(column); Assert.IsNotNull(htmlstring); string html; using (var sw = new StringWriter()) { htmlstring.WriteTo(sw, HtmlEncoder.Default); html = sw.ToString(); }; Assert.IsTrue(!html.Contains("<a")); Assert.IsTrue(html.Contains("<span")); column.Sortable(true); htmlstring = renderer.Render(column); Assert.IsNotNull(htmlstring); using (var sw = new StringWriter()) { htmlstring.WriteTo(sw, HtmlEncoder.Default); html = sw.ToString(); }; Assert.IsTrue(!string.IsNullOrWhiteSpace(html)); Assert.IsTrue(html.Contains("<a")); Assert.IsTrue(html.Contains("class=\"grid-header-title\"")); }