public void can_generate_widget() { var data = new[] { new { Name = "Q", IsValid = false, Cost = 10.0 }, new { Name = "U", IsValid = false, Cost = 5.0 }, new { Name = "E", IsValid = true, Cost = 10.0 }, new { Name = "S", IsValid = false, Cost = 10.0 }, new { Name = "T", IsValid = false, Cost = 10.0 } }; var explorer = new DataExplorer(data); var formatted = explorer.ToDisplayString(HtmlFormatter.MimeType); var htmlDoc = new HtmlDocument(); htmlDoc.LoadHtml(formatted); var scripts = htmlDoc.DocumentNode.SelectNodes("//div/script").Single(); using var _ = new AssertionScope(); scripts.InnerText.Should().Contain(data.ToTabularData().ToString()); scripts.InnerText.Should().Contain("getExtensionRequire('nteract','1.0.0')(['nteract/lib'], (nteract) => {"); }
public void it_emits_html_fragment() { SandDanceExtensions.RegisterFormatters(); var explorer = new DataExplorer(() => new[] { new { a = 12, b = new DateTime(1977, 2, 12) }, new { a = 14, b = new DateTime(1977, 2, 13) }, new { a = 16, b = new DateTime(1977, 2, 14) } }); var formatted = explorer.ToDisplayString(HtmlFormatter.MimeType); var htmlDoc = new HtmlDocument(); htmlDoc.LoadHtml(formatted); var scripts = htmlDoc.DocumentNode.SelectNodes("//div/script"); scripts.Count.Should().Be(1); }