33
44using FluentAssertions ;
55using Microsoft . DotNet . Cli . Sln . Internal ;
6+ using Microsoft . DotNet . Tools ;
67using Microsoft . DotNet . Tools . Test . Utilities ;
78using System ;
89using System . IO ;
@@ -48,7 +49,7 @@ public void WhenHelpOptionIsPassedItPrintsUsage(string helpArg)
4849 var cmd = new DotnetCommand ( )
4950 . ExecuteWithCapturedOutput ( $ "sln list { helpArg } ") ;
5051 cmd . Should ( ) . Pass ( ) ;
51- cmd . StdOut . Should ( ) . BeVisuallyEquivalentTo ( HelpText ) ;
52+ cmd . StdOut . Should ( ) . BeVisuallyEquivalentToIfNotLocalized ( HelpText ) ;
5253 }
5354
5455 [ Theory ]
@@ -59,8 +60,8 @@ public void WhenNoCommandIsPassedItPrintsError(string commandName)
5960 var cmd = new DotnetCommand ( )
6061 . ExecuteWithCapturedOutput ( $ "sln { commandName } ") ;
6162 cmd . Should ( ) . Fail ( ) ;
62- cmd . StdErr . Should ( ) . Be ( "Required command was not provided." ) ;
63- cmd . StdOut . Should ( ) . BeVisuallyEquivalentTo ( SlnCommandHelpText ) ;
63+ cmd . StdErr . Should ( ) . Be ( CommonLocalizableStrings . RequiredCommandNotPassed ) ;
64+ cmd . StdOut . Should ( ) . BeVisuallyEquivalentToIfNotLocalized ( SlnCommandHelpText ) ;
6465 }
6566
6667 [ Fact ]
@@ -83,8 +84,8 @@ public void WhenNonExistingSolutionIsPassedItPrintsErrorAndUsage(string solution
8384 var cmd = new DotnetCommand ( )
8485 . ExecuteWithCapturedOutput ( $ "sln { solutionName } list") ;
8586 cmd . Should ( ) . Fail ( ) ;
86- cmd . StdErr . Should ( ) . Be ( $ "Could not find solution or directory ` { solutionName } `." ) ;
87- cmd . StdOut . Should ( ) . BeVisuallyEquivalentTo ( HelpText ) ;
87+ cmd . StdErr . Should ( ) . Be ( string . Format ( CommonLocalizableStrings . CouldNotFindSolutionOrDirectory , solutionName ) ) ;
88+ cmd . StdOut . Should ( ) . BeVisuallyEquivalentToIfNotLocalized ( HelpText ) ;
8889 }
8990
9091 [ Fact ]
@@ -101,8 +102,8 @@ public void WhenInvalidSolutionIsPassedItPrintsErrorAndUsage()
101102 . WithWorkingDirectory ( projectDirectory )
102103 . ExecuteWithCapturedOutput ( "sln InvalidSolution.sln list" ) ;
103104 cmd . Should ( ) . Fail ( ) ;
104- cmd . StdErr . Should ( ) . Be ( "Invalid solution ` InvalidSolution.sln`. Expected file header not found." ) ;
105- cmd . StdOut . Should ( ) . BeVisuallyEquivalentTo ( HelpText ) ;
105+ cmd . StdErr . Should ( ) . Be ( string . Format ( CommonLocalizableStrings . InvalidSolutionFormatString , " InvalidSolution.sln" , LocalizableStrings . FileHeaderMissingError ) ) ;
106+ cmd . StdOut . Should ( ) . BeVisuallyEquivalentToIfNotLocalized ( HelpText ) ;
106107 }
107108
108109 [ Fact ]
@@ -120,8 +121,8 @@ public void WhenInvalidSolutionIsFoundItPrintsErrorAndUsage()
120121 . WithWorkingDirectory ( projectDirectory )
121122 . ExecuteWithCapturedOutput ( "sln list" ) ;
122123 cmd . Should ( ) . Fail ( ) ;
123- cmd . StdErr . Should ( ) . Be ( $ "Invalid solution ` { solutionFullPath } `. Expected file header not found." ) ;
124- cmd . StdOut . Should ( ) . BeVisuallyEquivalentTo ( HelpText ) ;
124+ cmd . StdErr . Should ( ) . Be ( string . Format ( CommonLocalizableStrings . InvalidSolutionFormatString , solutionFullPath , LocalizableStrings . FileHeaderMissingError ) ) ;
125+ cmd . StdOut . Should ( ) . BeVisuallyEquivalentToIfNotLocalized ( HelpText ) ;
125126 }
126127
127128 [ Fact ]
@@ -139,8 +140,8 @@ public void WhenNoSolutionExistsInTheDirectoryItPrintsErrorAndUsage()
139140 . WithWorkingDirectory ( solutionDir )
140141 . ExecuteWithCapturedOutput ( "sln list" ) ;
141142 cmd . Should ( ) . Fail ( ) ;
142- cmd . StdErr . Should ( ) . Be ( $ "Specified solution file { solutionDir + Path . DirectorySeparatorChar } does not exist, or there is no solution file in the directory." ) ;
143- cmd . StdOut . Should ( ) . BeVisuallyEquivalentTo ( HelpText ) ;
143+ cmd . StdErr . Should ( ) . Be ( string . Format ( CommonLocalizableStrings . SolutionDoesNotExist , solutionDir + Path . DirectorySeparatorChar ) ) ;
144+ cmd . StdOut . Should ( ) . BeVisuallyEquivalentToIfNotLocalized ( HelpText ) ;
144145 }
145146
146147 [ Fact ]
@@ -157,8 +158,8 @@ public void WhenMoreThanOneSolutionExistsInTheDirectoryItPrintsErrorAndUsage()
157158 . WithWorkingDirectory ( projectDirectory )
158159 . ExecuteWithCapturedOutput ( "sln list" ) ;
159160 cmd . Should ( ) . Fail ( ) ;
160- cmd . StdErr . Should ( ) . Be ( $ "Found more than one solution file in { projectDirectory + Path . DirectorySeparatorChar } . Please specify which one to use." ) ;
161- cmd . StdOut . Should ( ) . BeVisuallyEquivalentTo ( HelpText ) ;
161+ cmd . StdErr . Should ( ) . Be ( string . Format ( CommonLocalizableStrings . MoreThanOneSolutionInDirectory , projectDirectory + Path . DirectorySeparatorChar ) ) ;
162+ cmd . StdOut . Should ( ) . BeVisuallyEquivalentToIfNotLocalized ( HelpText ) ;
162163 }
163164
164165 [ Fact ]
@@ -175,14 +176,15 @@ public void WhenNoProjectReferencesArePresentInTheSolutionItPrintsANoProjectMess
175176 . WithWorkingDirectory ( projectDirectory )
176177 . ExecuteWithCapturedOutput ( "sln list" ) ;
177178 cmd . Should ( ) . Pass ( ) ;
178- cmd . StdOut . Should ( ) . Be ( "No projects found in the solution." ) ;
179+ cmd . StdOut . Should ( ) . Be ( CommonLocalizableStrings . NoProjectsFound ) ;
179180 }
180181
181182 [ Fact ]
182183 public void WhenProjectReferencesArePresentInTheSolutionItListsThem ( )
183184 {
184- string OutputText = $@ "Project reference(s)
185- --------------------
185+ string OutputText = CommonLocalizableStrings . ProjectReferenceOneOrMore ;
186+ OutputText += $@ "
187+ { new string ( '-' , OutputText . Length ) }
186188{ Path . Combine ( "App" , "App.csproj" ) }
187189{ Path . Combine ( "Lib" , "Lib.csproj" ) } ";
188190
0 commit comments