public void Write(StringBuilder sb, SchemaComparison data) { sb.AppendLine("### Properties from `<m:properties>`"); sb.AppendLine(); sb.AppendLine("The following elements are available on every known server implementation."); sb.AppendLine(); _markdownTableWriter.Write( sb, new[] { "Property Element", "Type" }, data .DirectPropertiesOnAllTypes .OrderBy(x => x) .Select(x => new[] { $"`<d:{x}>`", data.PropertyTypes[x] })); sb.AppendLine(); sb.AppendLine("The following properties vary from one server implementation to the next."); sb.AppendLine(); _markdownTableWriter.Write( sb, new[] { "Property Element", "Type", "[Availability](#quirk-abbreviations)" }, data .DirectPropertiesOnSomeTypes .OrderBy(x => x.Key) .Select(x => new[] { $"`<d:{x.Key}>`", data.PropertyTypes[x.Key], string.Join(" ", x .Value .Select(y => _abbreviations.AbbreviatePackageSourceType(y)) .OrderBy(y => y)) })); sb.AppendLine(); sb.AppendLine("The following properties must be fetched from Atom elements, instead of from the `<m:properties>` element. In other"); sb.AppendLine("words, clients must check child elements of `<entry>` to get all package metadata on different server implementations."); sb.AppendLine(); _markdownTableWriter.Write( sb, new[] { "Equivalent Property Element", "Atom Element", "[Availability](#quirk-abbreviations)" }, data .OnlyUsesTargetPaths .SelectMany(x => x .Value .Select(y => new[] { $"`<d:{x.Key}>`", TargetPathToDisplay[y.Key], string.Join(" ", y .Value .Select(z => _abbreviations.AbbreviatePackageSourceType(z)) .OrderBy(z => z)) })) .OrderBy(x => x[0])); }
public void Write_GeneratesExpectedTable() { // Arrange var target = new MarkdownTableWriter(); var header = new[] { "Short", "Header longer than the data", "A" }; var data = new[] { new[] { "B", "C", "Third cell" }, new[] { "Longer than the header", string.Empty, "LOL" } }; var sb = new StringBuilder(); // Act target.Write(sb, header, data); // Act var actual = sb.ToString(); var expected = "Short | Header longer than the data | A" + Environment.NewLine + "----------------------- | ---------------------------- | -----------" + Environment.NewLine + "B | C | Third cell" + Environment.NewLine + "Longer than the header | | LOL" + Environment.NewLine; Assert.Equal(expected, actual); }