public void ShouldIncludeParameterNamesAsText() { var formatter = new SlashdocSummaryHtmlFormatter(DummyAssembly, DummyLanguage); Assert.That(formatter.FormatSummary("<summary>Hello, <paramref name=\"World\" />!</summary>"), Is.EqualTo("Hello, World!")); Assert.That(formatter.FormatSummary("<summary>Hello, <typeparamref name=\"World\" />!</summary>"), Is.EqualTo("Hello, World!")); Assert.That(formatter.FormatSummary("<summary>Hello, <paramref />!</summary>"), Is.EqualTo("Hello, !"), "The parser doesn't choke when the attribute is missing."); }
public void ShouldOnlyIncludeContentWithinSummaryTags() { var formatter = new SlashdocSummaryHtmlFormatter(DummyAssembly, DummyLanguage); Assert.That(formatter.FormatSummary("<far-out>dude</far-out>"), Is.EqualTo(string.Empty)); Assert.That(formatter.FormatSummary("<far-out><summary>dude</summary></far-out>"), Is.EqualTo("dude")); Assert.That(formatter.FormatSummary("<summary>first</summary><summary><summary>second<summary/></summary></summary>"), Is.EqualTo("firstsecond")); Assert.That(formatter.FormatSummary("irrelevant <summary/> irrelevant"), Is.EqualTo(string.Empty)); }
private void WriteTypesOverviewTable(IAssemblyReflector assembly, SlashdocSummaryHtmlFormatter formatter) { WriteDescriptionTableHeader("Types"); foreach (var type in assembly.Types .Where(t => ReflectionHelper.IsVisible(t)) .OrderBy(t => _language.GetDisplayName(t))) { var displayName = _language.GetDisplayName(type); _writer.WriteStartElement("tr"); _writer.WriteStartElement("td"); _writer.WriteStartElement("a"); _writer.WriteAttributeString("href", "#" + displayName); _writer.WriteString(displayName); _writer.WriteEndElement(); // a _writer.WriteString(" " + _language.GetMetaTypeName(type)); _writer.WriteEndElement(); // td _writer.WriteStartElement("td"); var slashdocSummaryHtml = formatter.FormatSummary(LookupXmlDescription( SlashdocIdentifierProvider.GetId(type), displayName + " " + _language.GetMetaTypeName(type))); _writer.WriteRaw(slashdocSummaryHtml); _writer.WriteEndElement(); // td _writer.WriteEndElement(); // tr } WriteDescriptionTableFooter(); }
public void ShouldCreateFragmentLinksForTypeReferencesWithinTheSameAssembly() { var assemblyReflectorMock = new Mock<IAssemblyReflector>(); assemblyReflectorMock.Setup(x => x.LookupType("System.Guid")).Returns(typeof(System.Guid)); var formatter = new SlashdocSummaryHtmlFormatter(assemblyReflectorMock.Object, new CSharpSignatureProvider()); // T:System.Guid: type lookup is successful Assert.That(formatter.FormatSummary("<summary>Hello, <see cref=\"T:System.Guid\" />!</summary>"), Is.EqualTo("Hello, <a href=\"#System.Guid\">Guid</a>!")); Assert.That(formatter.FormatSummary("<summary>Hello, <seealso cref=\"T:System.Guid\" />!</summary>"), Is.EqualTo("Hello, <a href=\"#System.Guid\">Guid</a>!")); // T:System.EventArgs: type lookup fails Assert.That(formatter.FormatSummary("<summary>Hello, <see cref=\"T:System.EventArgs\" />!</summary>"), Is.EqualTo("Hello, System.EventArgs!")); Assert.That(formatter.FormatSummary("<summary>Hello, <seealso cref=\"T:System.EventArgs\" />!</summary>"), Is.EqualTo("Hello, System.EventArgs!")); // !:Error, E:Foo.Bar: no type lookup, just strip the meta-type identifier Assert.That(formatter.FormatSummary("<summary>Hello, <see cref=\"!:Error\" />!</summary>"), Is.EqualTo("Hello, Error!")); Assert.That(formatter.FormatSummary("<summary>Hello, <seealso cref=\"!:Error\" />!</summary>"), Is.EqualTo("Hello, Error!")); Assert.That(formatter.FormatSummary("<summary>Hello, <see cref=\"E:Foo.Bar\" />!</summary>"), Is.EqualTo("Hello, Foo.Bar!")); Assert.That(formatter.FormatSummary("<summary>Hello, <see />!</summary>"), Is.EqualTo("Hello, !"), "The parser doesn't choke when the attribute is missing."); }
private void WriteSection <T>(string sectionHeading, IEnumerable <T> items, Func <T, string> signatureProvider, Func <T, string> slashdocIdProvider, Func <T, string> contextProvider, SlashdocSummaryHtmlFormatter formatter) { if (items.Count() > 0) { WriteDescriptionTableHeader(sectionHeading); foreach (var item in items) { _writer.WriteStartElement("tr"); WriteTextElement("td", signatureProvider(item)); _writer.WriteStartElement("td"); var slashdocSummaryHtml = formatter.FormatSummary(LookupXmlDescription( slashdocIdProvider(item), contextProvider(item))); _writer.WriteRaw(slashdocSummaryHtml); _writer.WriteEndElement(); // td _writer.WriteEndElement(); // tr } WriteDescriptionTableFooter(); } }
private void WriteTypeHeader(Type type, string displayName, string metaType, SlashdocSummaryHtmlFormatter formatter) { WriteTextElement("h2", string.Format(CultureInfo.InvariantCulture, "{0} {1}", displayName, metaType)); _writer.WriteStartElement("table"); _writer.WriteAttributeString("class", "typeheader"); _writer.WriteStartElement("tr"); _writer.WriteStartElement("td"); var slashdocSummaryHtml = formatter.FormatSummary(LookupXmlDescription( SlashdocIdentifierProvider.GetId(type), _language.GetDisplayName(type) + " " + _language.GetMetaTypeName(type))); _writer.WriteRaw(slashdocSummaryHtml); WriteInfo("Namespace", type.Namespace); WriteInfo("Signature", _language.GetSignature(type)); _writer.WriteEndElement(); // td _writer.WriteEndElement(); // tr _writer.WriteEndElement(); // table }
public void ShouldReturnAnEmptySummaryWhenTheXmlDescriptionIsNullOrEmpty() { var formatter = new SlashdocSummaryHtmlFormatter(DummyAssembly, DummyLanguage); Assert.That(formatter.FormatSummary(null), Is.EqualTo(string.Empty)); Assert.That(formatter.FormatSummary(string.Empty), Is.EqualTo(string.Empty)); }
public void ShouldMarkupParagraphs() { var formatter = new SlashdocSummaryHtmlFormatter(DummyAssembly, DummyLanguage); Assert.That(formatter.FormatSummary("<summary><para>Hello</para>!</summary>"), Is.EqualTo("<p>Hello</p>!")); }
public void ShouldMarkupCode() { var formatter = new SlashdocSummaryHtmlFormatter(DummyAssembly, DummyLanguage); Assert.That(formatter.FormatSummary("<summary><c>Hello</c>!</summary>"), Is.EqualTo("<code>Hello</code>!")); Assert.That(formatter.FormatSummary("<summary><code>Hello</code>!</summary>"), Is.EqualTo("<code>Hello</code>!")); }
public void ShouldEscapeXmlDocumentEscapeCharacters() { var formatter = new SlashdocSummaryHtmlFormatter(DummyAssembly, DummyLanguage); Assert.That(formatter.FormatSummary("<summary><hello> & goodbye</summary>"), Is.EqualTo("<hello> & goodbye")); }