Skip to content

Added one test for DragonFruit when parsing <summary> tag #2008

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/System.CommandLine.DragonFruit.Tests/CommandLineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,30 @@ public async Task When_XML_documentation_comment_contains_a_para_tag_then_help_i
.Contain($"Description:{Environment.NewLine} Help for the test program{Environment.NewLine} More help for the test program{Environment.NewLine}");
}

[Fact]
public async Task When_XML_documentation_comment_contains_a_para_tag_and_some_text_then_help_skips_text_outside_para_tag()
{
int exitCode = await CommandLine.InvokeMethodAsync(
new[] { "--help" },
TestProgram.TestMainMethodInfoWithTextAndPara,
null,
_testProgram,
_terminal);

exitCode.Should().Be(0);

var stdOut = _terminal.Out.ToString();

stdOut.Should()
.Contain("<args> These are arguments")
.And.Contain("Arguments:");
stdOut.Should()
.ContainAll("--name <name>", "Specifies the name option")
.And.Contain("Options:");
stdOut.Should()
.Contain($"Description:{Environment.NewLine} Help for the test program{Environment.NewLine} More help for the test program{Environment.NewLine}");
}

[Fact]
public void It_synchronously_shows_help_text_based_on_XML_documentation_comments()
{
Expand Down
21 changes: 21 additions & 0 deletions src/System.CommandLine.DragonFruit.Tests/TestProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public class TestProgram

public static readonly MethodInfo TestMainMethodInfoWithPara = typeof(TestProgram).GetMethod(nameof(TestMainWithPara));

public static readonly MethodInfo TestMainMethodInfoWithTextAndPara = typeof(TestProgram).GetMethod(nameof(TestMainWithTextAndPara));

public static readonly MethodInfo TestMainMethodInfoWithDefault = typeof(TestProgram).GetMethod(nameof(TestMainWithDefault));

/// <summary>
Expand All @@ -29,6 +31,25 @@ public void TestMainWithPara(string name, IConsole console, string[] args = null
}
}

/// <summary>
/// Skipped help for the test program
/// More skipped help for the test program<para>Help for the test program</para>More skipped help for the test program
/// More skipped help for the test program<para>More help for the test program</para>More skipped help for the test program
///
/// More skipped help for the test program
/// </summary>
/// <param name="name">Specifies the name option</param>
/// <param name="console"></param>
/// <param name="args">These are arguments</param>
public void TestMainWithTextAndPara(string name, IConsole console, string[] args = null)
{
console.Out.Write(name);
if (args != null && args.Length > 0)
{
console.Out.Write($"args: { string.Join(",", args) }");
}
}

/// <summary>
/// Normal summary
/// </summary>
Expand Down