public void op_TabularData_HtmlDocument_whenDuplicateId() { var html = new HtmlDocument(); html.Load(new FileInfo("tabular-duplicate.html").FullName); Assert.NotNull(html.TabularData().Tables["duplicate"]); }
public void op_TabularData_HtmlDocument_whenEmptyTable() { var html = new HtmlDocument(); html.Load(new FileInfo("tabular-empty-table.html").FullName); var table = html.TabularData().Tables["empty-table"]; Assert.Empty(table.Rows); }
public void op_TabularData_HtmlDocument_whenCaption() { var html = new HtmlDocument(); html.Load(new FileInfo("tabular-caption.html").FullName); var table = html.TabularData().Tables["Caption"]; Assert.Equal(1, table.Rows.Count); Assert.Equal("data", table.Rows[0].Field<HtmlNode>(0).InnerText); }
public void op_TabularData_HtmlDocument_whenCellColumnSpanning() { var html = new HtmlDocument(); html.Load(new FileInfo("tabular-cell-colspan.html").FullName); var table = html.TabularData().Tables["cell-colspan"]; Assert.Equal(2, table.Rows.Count); Assert.Equal("1A", table.Rows[0].Field<HtmlNode>(0).InnerText); Assert.Equal("1B", table.Rows[0].Field<HtmlNode>(1).InnerText); Assert.Equal("1C", table.Rows[0].Field<HtmlNode>(2).InnerText); Assert.Equal("1D", table.Rows[0].Field<HtmlNode>(3).InnerText); Assert.Equal("2A", table.Rows[1].Field<HtmlNode>("Column A").InnerText); Assert.Equal("2B + 2C", table.Rows[1].Field<HtmlNode>("Column B").InnerText); Assert.Equal("2B + 2C", table.Rows[1].Field<HtmlNode>("Column C").InnerText); Assert.Equal("2D", table.Rows[1].Field<HtmlNode>("Column D").InnerText); }
public override IEnumerable<object[]> GetData(MethodInfo methodUnderTest, Type[] parameterTypes) { if (null == methodUnderTest) { throw new ArgumentNullException("methodUnderTest"); } if (null == parameterTypes) { throw new ArgumentNullException("parameterTypes"); } #if NET20 if (IEnumerableExtensionMethods.Count(Files) != parameterTypes.Length) { throw new InvalidOperationException(StringExtensionMethods.FormatWith(Resources.Attribute_CountsDiffer, IEnumerableExtensionMethods.Count(Files), parameterTypes.Length)); } #else if (Files.Count() != parameterTypes.Length) { throw new InvalidOperationException(Resources.Attribute_CountsDiffer.FormatWith(Files.Count(), parameterTypes.Length)); } #endif var list = new List<object>(); var index = -1; foreach (var file in Files) { var info = new FileInfo(file); index++; if (parameterTypes[index] == typeof(HtmlDocument) || parameterTypes[index] == typeof(IXPathNavigable)) { var html = new HtmlDocument(); html.Load(info.FullName); list.Add(html); continue; } if (parameterTypes[index] == typeof(XPathNavigator)) { var html = new HtmlDocument(); html.Load(info.FullName); list.Add(html.CreateNavigator()); continue; } if (parameterTypes[index] == typeof(DataSet)) { var html = new HtmlDocument(); html.Load(info.FullName); #if NET20 list.Add(HtmlDocumentExtensionMethods.TabularData(html)); #else list.Add(html.TabularData()); #endif continue; } throw new InvalidOperationException(Resources.HtmlAttribute_UnsupportedParameterType); } yield return list.ToArray(); }
public void op_TabularData_HtmlDocument_whenHeadingColumnId() { var html = new HtmlDocument(); html.Load(new FileInfo("tabular-heading-id.html").FullName); var table = html.TabularData().Tables["heading-id"]; Assert.Equal(2, table.Rows.Count); Assert.Equal("1A", table.Rows[0].Field<HtmlNode>(0).InnerText); Assert.Equal("2A", table.Rows[1].Field<HtmlNode>("A").InnerText); }
public void op_TabularData_HtmlDocument_withoutTables() { var html = new HtmlDocument(); html.Load(new FileInfo("tabular-empty.html").FullName); Assert.Empty(html.TabularData().Tables); }
public void op_TabularData_HtmlDocument_whenVerticalHeadingRowSpanning() { var html = new HtmlDocument(); html.Load(new FileInfo("tabular-vertical-heading-rowspan.html").FullName); var table = html.TabularData().Tables["vertical-heading-rowspan"]; Assert.Equal(2, table.Rows.Count); Assert.Equal("1A", table.Rows[0].Field<HtmlNode>(0).InnerText); Assert.Equal("2A", table.Rows[1].Field<HtmlNode>(0).InnerText); Assert.Equal("1B", table.Rows[0].Field<HtmlNode>("Value B, C (1)").InnerText); Assert.Equal("2B", table.Rows[1].Field<HtmlNode>("Value B, C (1)").InnerText); Assert.Equal("1C", table.Rows[0].Field<HtmlNode>("Value B, C (2)").InnerText); Assert.Equal("2C", table.Rows[1].Field<HtmlNode>("Value B, C (2)").InnerText); Assert.Equal("1D", table.Rows[0].Field<HtmlNode>("Value D").InnerText); Assert.Equal("2D", table.Rows[1].Field<HtmlNode>("Value D").InnerText); }
public void op_TabularData_HtmlDocument_whenVertical() { var html = new HtmlDocument(); html.Load(new FileInfo("tabular-vertical.html").FullName); var table = html.TabularData().Tables["vertical"]; Assert.Equal(2, table.Rows.Count); Assert.Equal("1A", table.Rows[0].Field<HtmlNode>(0).InnerText); Assert.Equal("2A", table.Rows[1].Field<HtmlNode>(0).InnerText); Assert.Equal("2B", table.Rows[1].Field<HtmlNode>("Value B").InnerText); }
public void op_TabularData_HtmlDocument_whenUnnamed() { var html = new HtmlDocument(); html.Load(new FileInfo("tabular-unnamed.html").FullName); var table = html.TabularData().Tables[0]; Assert.Equal(1, table.Rows.Count); Assert.Equal("_<em>_</em>_", table.Rows[0].Field<HtmlNode>(0).InnerHtml); }
public void op_TabularData_HtmlDocument_whenHeadingComplex() { var html = new HtmlDocument(); html.Load(new FileInfo("tabular-heading-complex.html").FullName); var table = html.TabularData().Tables["heading-complex"]; Assert.Equal(2, table.Rows.Count); Assert.Equal("Friday, January 01, 2010", table.Rows[0].Field<HtmlNode>(0).InnerText); Assert.Equal("26.6", table.Rows[0].Field<HtmlNode>(1).InnerText); Assert.Equal("31.8", table.Rows[0].Field<HtmlNode>(2).InnerText); Assert.Equal("35.8", table.Rows[0].Field<HtmlNode>(3).InnerText); Assert.Equal("Saturday, December 31, 2011", table.Rows[1].Field<HtmlNode>("date").InnerText); Assert.Equal("40.5", table.Rows[1].Field<HtmlNode>("minimum-temperature").InnerText); Assert.Equal("52.8", table.Rows[1].Field<HtmlNode>("mean-temperature").InnerText); Assert.Equal("55.4", table.Rows[1].Field<HtmlNode>("maximum-temperature").InnerText); }