Skip to content

Commit 7911c78

Browse files
committed
add another test
1 parent c14ed4c commit 7911c78

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

src/System.CommandLine.Tests/CommandExtensionsTests.cs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

4+
using System.CommandLine.Builder;
45
using System.CommandLine.IO;
56
using FluentAssertions;
67
using Xunit;
@@ -10,7 +11,7 @@ namespace System.CommandLine.Tests
1011
public class CommandExtensionsTests
1112
{
1213
[Fact]
13-
public void Mulitple_invocations_via_Invoke_extension_will_not_reconfigure_implicit_parser()
14+
public void Command_Invoke_can_be_called_more_than_once_for_the_same_command()
1415
{
1516
var command = new RootCommand("Root command description")
1617
{
@@ -22,12 +23,34 @@ public void Mulitple_invocations_via_Invoke_extension_will_not_reconfigure_impli
2223
command.Invoke("-h", console1);
2324

2425
console1.Out.ToString().Should().Contain(command.Description);
25-
26+
2627
var console2 = new TestConsole();
2728

2829
command.Invoke("-h", console2);
2930

3031
console2.Out.ToString().Should().Contain(command.Description);
3132
}
33+
34+
[Fact]
35+
public void When_CommandLineBuilder_is_used_then_Command_Invoke_uses_its_configuration()
36+
{
37+
var command = new RootCommand();
38+
39+
new CommandLineBuilder(command)
40+
.UseMiddleware(context =>
41+
{
42+
context.Console.Out.Write("hello!");
43+
})
44+
.Build();
45+
46+
var console = new TestConsole();
47+
48+
command.Invoke("", console);
49+
50+
console.Out
51+
.ToString()
52+
.Should()
53+
.Contain("hello!");
54+
}
3255
}
3356
}

0 commit comments

Comments
 (0)