77using FluentAssertions ;
88using NuGet . CommandLine . XPlat . Commands ;
99using NuGet . CommandLine . XPlat . Commands . Why ;
10+ using Spectre . Console ;
1011using Spectre . Console . Testing ;
1112using Xunit ;
1213
@@ -19,9 +20,10 @@ public void WhyCommand_HasHelpUrl()
1920 {
2021 // Arrange
2122 Command rootCommand = new ( "nuget" ) ;
23+ var console = new Lazy < IAnsiConsole > ( ( ) => new TestConsole ( ) ) ;
2224
2325 // Act
24- WhyCommand . Register ( rootCommand , new TestConsole ( ) ) ;
26+ WhyCommand . Register ( rootCommand , console ) ;
2527
2628 // Assert
2729 rootCommand . Subcommands [ 0 ] . Should ( ) . BeAssignableTo < DocumentedCommand > ( ) ;
@@ -33,8 +35,10 @@ public void WithTwoArguments_PathAndPackageAreSet()
3335 {
3436 // Arrange
3537 Command rootCommand = new ( "nuget" ) ;
38+ var console = new Lazy < IAnsiConsole > ( ( ) => new TestConsole ( ) ) ;
3639
37- WhyCommand . Register ( rootCommand , new TestConsole ( ) , whyCommandArgs =>
40+
41+ WhyCommand . Register ( rootCommand , console , whyCommandArgs =>
3842 {
3943 // Assert
4044 whyCommandArgs . Path . Should ( ) . Be ( @"path\to\my.proj" ) ;
@@ -54,8 +58,9 @@ public void WithOneArguments_PackageIsSet()
5458 {
5559 // Arrange
5660 Command rootCommand = new ( "nuget" ) ;
61+ var console = new Lazy < IAnsiConsole > ( ( ) => new TestConsole ( ) ) ;
5762
58- WhyCommand . Register ( rootCommand , new TestConsole ( ) , whyCommandArgs =>
63+ WhyCommand . Register ( rootCommand , console , whyCommandArgs =>
5964 {
6065 // Assert
6166 whyCommandArgs . Path . Should ( ) . NotBeNull ( ) ;
@@ -75,8 +80,9 @@ public void WithZeroArguments_HasParseError()
7580 {
7681 // Arrange
7782 Command rootCommand = new ( "nuget" ) ;
83+ var console = new Lazy < IAnsiConsole > ( ( ) => new TestConsole ( ) ) ;
7884
79- WhyCommand . Register ( rootCommand , new TestConsole ( ) , whyCommandArgs =>
85+ WhyCommand . Register ( rootCommand , console , whyCommandArgs =>
8086 {
8187 // Assert
8288 throw new Exception ( "Should not get here" ) ;
@@ -92,8 +98,9 @@ public void WithThreeArguments_HasParseError()
9298 {
9399 // Arrange
94100 Command rootCommand = new ( "nuget" ) ;
101+ var console = new Lazy < IAnsiConsole > ( ( ) => new TestConsole ( ) ) ;
95102
96- WhyCommand . Register ( rootCommand , new TestConsole ( ) , whyCommandArgs =>
103+ WhyCommand . Register ( rootCommand , console , whyCommandArgs =>
97104 {
98105 // Assert
99106 throw new Exception ( "Should not get here" ) ;
@@ -112,8 +119,9 @@ public void FrameworkOption_CanBeAtAnyPosition(string args)
112119 {
113120 // Arrange
114121 Command rootCommand = new ( "nuget" ) ;
122+ var console = new Lazy < IAnsiConsole > ( ( ) => new TestConsole ( ) ) ;
115123
116- WhyCommand . Register ( rootCommand , new TestConsole ( ) , whyCommandArgs =>
124+ WhyCommand . Register ( rootCommand , console , whyCommandArgs =>
117125 {
118126 // Assert
119127 whyCommandArgs . Path . Should ( ) . Be ( "my.proj" ) ;
@@ -135,8 +143,9 @@ public void FrameworkOption_CanBeLongOrShortForm(string arg)
135143 {
136144 // Arrange
137145 Command rootCommand = new ( "nuget" ) ;
146+ var console = new Lazy < IAnsiConsole > ( ( ) => new TestConsole ( ) ) ;
138147
139- WhyCommand . Register ( rootCommand , new TestConsole ( ) , whyCommandArgs =>
148+ WhyCommand . Register ( rootCommand , console , whyCommandArgs =>
140149 {
141150 // Assert
142151 whyCommandArgs . Path . Should ( ) . Be ( "my.proj" ) ;
@@ -156,8 +165,9 @@ public void FrameworkOption_AcceptsMultipleValues()
156165 {
157166 // Arrange
158167 Command rootCommand = new ( "nuget" ) ;
168+ var console = new Lazy < IAnsiConsole > ( ( ) => new TestConsole ( ) ) ;
159169
160- WhyCommand . Register ( rootCommand , new TestConsole ( ) , whyCommandArgs =>
170+ WhyCommand . Register ( rootCommand , console , whyCommandArgs =>
161171 {
162172 // Assert
163173 whyCommandArgs . Path . Should ( ) . Be ( "my.proj" ) ;
@@ -177,8 +187,9 @@ public void HelpOption_ShowsHelp()
177187 {
178188 // Arrange
179189 Command rootCommand = new ( "nuget" ) ;
190+ var console = new Lazy < IAnsiConsole > ( ( ) => new TestConsole ( ) ) ;
180191
181- WhyCommand . Register ( rootCommand , new TestConsole ( ) , whyCommandArgs =>
192+ WhyCommand . Register ( rootCommand , console , whyCommandArgs =>
182193 {
183194 // Assert
184195 whyCommandArgs . Path . Should ( ) . Be ( "my.proj" ) ;
0 commit comments