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 ;
@@ -182,7 +183,7 @@ public void WhenHelpOptionIsPassedItPrintsUsage(string helpArg)
182183 var cmd = new DotnetCommand ( )
183184 . ExecuteWithCapturedOutput ( $ "sln remove { helpArg } ") ;
184185 cmd . Should ( ) . Pass ( ) ;
185- cmd . StdOut . Should ( ) . BeVisuallyEquivalentTo ( HelpText ) ;
186+ cmd . StdOut . Should ( ) . BeVisuallyEquivalentToIfNotLocalized ( HelpText ) ;
186187 }
187188
188189 [ Fact ]
@@ -191,7 +192,7 @@ public void WhenTooManyArgumentsArePassedItPrintsError()
191192 var cmd = new DotnetCommand ( )
192193 . ExecuteWithCapturedOutput ( "sln one.sln two.sln three.sln remove" ) ;
193194 cmd . Should ( ) . Fail ( ) ;
194- cmd . StdErr . Should ( ) . BeVisuallyEquivalentTo ( "Unrecognized command or argument 'two.sln'\r \n Unrecognized command or argument 'three.sln'\r \n You must specify at least one project to remove. " ) ;
195+ cmd . StdErr . Should ( ) . BeVisuallyEquivalentTo ( $ "Unrecognized command or argument 'two.sln'\r \n Unrecognized command or argument 'three.sln'\r \n { CommonLocalizableStrings . SpecifyAtLeastOneProjectToRemove } ") ;
195196 }
196197
197198 [ Theory ]
@@ -202,8 +203,8 @@ public void WhenNoCommandIsPassedItPrintsError(string commandName)
202203 var cmd = new DotnetCommand ( )
203204 . ExecuteWithCapturedOutput ( $ "sln { commandName } ") ;
204205 cmd . Should ( ) . Fail ( ) ;
205- cmd . StdErr . Should ( ) . Be ( "Required command was not provided." ) ;
206- cmd . StdOut . Should ( ) . BeVisuallyEquivalentTo ( SlnCommandHelpText ) ;
206+ cmd . StdErr . Should ( ) . Be ( CommonLocalizableStrings . RequiredCommandNotPassed ) ;
207+ cmd . StdOut . Should ( ) . BeVisuallyEquivalentToIfNotLocalized ( SlnCommandHelpText ) ;
207208 }
208209
209210 [ Theory ]
@@ -217,8 +218,8 @@ public void WhenNonExistingSolutionIsPassedItPrintsErrorAndUsage(string solution
217218 var cmd = new DotnetCommand ( )
218219 . ExecuteWithCapturedOutput ( $ "sln { solutionName } remove p.csproj") ;
219220 cmd . Should ( ) . Fail ( ) ;
220- cmd . StdErr . Should ( ) . Be ( $ "Could not find solution or directory ` { solutionName } `." ) ;
221- cmd . StdOut . Should ( ) . BeVisuallyEquivalentTo ( HelpText ) ;
221+ cmd . StdErr . Should ( ) . Be ( string . Format ( CommonLocalizableStrings . CouldNotFindSolutionOrDirectory , solutionName ) ) ;
222+ cmd . StdOut . Should ( ) . BeVisuallyEquivalentToIfNotLocalized ( HelpText ) ;
222223 }
223224
224225 [ Fact ]
@@ -236,8 +237,8 @@ public void WhenInvalidSolutionIsPassedItPrintsErrorAndUsage()
236237 . WithWorkingDirectory ( projectDirectory )
237238 . ExecuteWithCapturedOutput ( $ "sln InvalidSolution.sln remove { projectToRemove } ") ;
238239 cmd . Should ( ) . Fail ( ) ;
239- cmd . StdErr . Should ( ) . Be ( "Invalid solution ` InvalidSolution.sln`. Expected file header not found." ) ;
240- cmd . StdOut . Should ( ) . BeVisuallyEquivalentTo ( HelpText ) ;
240+ cmd . StdErr . Should ( ) . Be ( string . Format ( CommonLocalizableStrings . InvalidSolutionFormatString , " InvalidSolution.sln" , LocalizableStrings . FileHeaderMissingError ) ) ;
241+ cmd . StdOut . Should ( ) . BeVisuallyEquivalentToIfNotLocalized ( HelpText ) ;
241242 }
242243
243244 [ Fact ]
@@ -256,8 +257,8 @@ public void WhenInvalidSolutionIsFoundItPrintsErrorAndUsage()
256257 . WithWorkingDirectory ( projectDirectory )
257258 . ExecuteWithCapturedOutput ( $ "sln remove { projectToRemove } ") ;
258259 cmd . Should ( ) . Fail ( ) ;
259- cmd . StdErr . Should ( ) . Be ( $ "Invalid solution ` { solutionPath } `. Expected file header not found." ) ;
260- cmd . StdOut . Should ( ) . BeVisuallyEquivalentTo ( HelpText ) ;
260+ cmd . StdErr . Should ( ) . Be ( string . Format ( CommonLocalizableStrings . InvalidSolutionFormatString , solutionPath , LocalizableStrings . FileHeaderMissingError ) ) ;
261+ cmd . StdOut . Should ( ) . BeVisuallyEquivalentToIfNotLocalized ( HelpText ) ;
261262 }
262263
263264 [ Fact ]
@@ -274,8 +275,8 @@ public void WhenNoProjectIsPassedItPrintsErrorAndUsage()
274275 . WithWorkingDirectory ( projectDirectory )
275276 . ExecuteWithCapturedOutput ( @"sln App.sln remove" ) ;
276277 cmd . Should ( ) . Fail ( ) ;
277- cmd . StdErr . Should ( ) . Be ( "You must specify at least one project to remove." ) ;
278- cmd . StdOut . Should ( ) . BeVisuallyEquivalentTo ( HelpText ) ;
278+ cmd . StdErr . Should ( ) . Be ( CommonLocalizableStrings . SpecifyAtLeastOneProjectToRemove ) ;
279+ cmd . StdOut . Should ( ) . BeVisuallyEquivalentToIfNotLocalized ( HelpText ) ;
279280 }
280281
281282 [ Fact ]
@@ -293,8 +294,8 @@ public void WhenNoSolutionExistsInTheDirectoryItPrintsErrorAndUsage()
293294 . WithWorkingDirectory ( solutionPath )
294295 . ExecuteWithCapturedOutput ( @"sln remove App.csproj" ) ;
295296 cmd . Should ( ) . Fail ( ) ;
296- cmd . StdErr . Should ( ) . Be ( $ "Specified solution file { solutionPath + Path . DirectorySeparatorChar } does not exist, or there is no solution file in the directory." ) ;
297- cmd . StdOut . Should ( ) . BeVisuallyEquivalentTo ( HelpText ) ;
297+ cmd . StdErr . Should ( ) . Be ( string . Format ( CommonLocalizableStrings . SolutionDoesNotExist , solutionPath + Path . DirectorySeparatorChar ) ) ;
298+ cmd . StdOut . Should ( ) . BeVisuallyEquivalentToIfNotLocalized ( HelpText ) ;
298299 }
299300
300301 [ Fact ]
@@ -312,8 +313,8 @@ public void WhenMoreThanOneSolutionExistsInTheDirectoryItPrintsErrorAndUsage()
312313 . WithWorkingDirectory ( projectDirectory )
313314 . ExecuteWithCapturedOutput ( $ "sln remove { projectToRemove } ") ;
314315 cmd . Should ( ) . Fail ( ) ;
315- cmd . StdErr . Should ( ) . Be ( $ "Found more than one solution file in { projectDirectory + Path . DirectorySeparatorChar } . Please specify which one to use." ) ;
316- cmd . StdOut . Should ( ) . BeVisuallyEquivalentTo ( HelpText ) ;
316+ cmd . StdErr . Should ( ) . Be ( string . Format ( CommonLocalizableStrings . MoreThanOneSolutionInDirectory , projectDirectory + Path . DirectorySeparatorChar ) ) ;
317+ cmd . StdOut . Should ( ) . BeVisuallyEquivalentToIfNotLocalized ( HelpText ) ;
317318 }
318319
319320 [ Fact ]
@@ -332,7 +333,7 @@ public void WhenPassedAReferenceNotInSlnItPrintsStatus()
332333 . WithWorkingDirectory ( projectDirectory )
333334 . ExecuteWithCapturedOutput ( "sln remove referenceDoesNotExistInSln.csproj" ) ;
334335 cmd . Should ( ) . Pass ( ) ;
335- cmd . StdOut . Should ( ) . Be ( "Project reference ` referenceDoesNotExistInSln.csproj` could not be found." ) ;
336+ cmd . StdOut . Should ( ) . Be ( string . Format ( CommonLocalizableStrings . ProjectReferenceCouldNotBeFound , " referenceDoesNotExistInSln.csproj" ) ) ;
336337 File . ReadAllText ( solutionPath )
337338 . Should ( ) . BeVisuallyEquivalentTo ( contentBefore ) ;
338339 }
@@ -356,7 +357,7 @@ public void WhenPassedAReferenceItRemovesTheReferenceButNotOtherReferences()
356357 . WithWorkingDirectory ( projectDirectory )
357358 . ExecuteWithCapturedOutput ( $ "sln remove { projectToRemove } ") ;
358359 cmd . Should ( ) . Pass ( ) ;
359- cmd . StdOut . Should ( ) . Be ( $ "Project reference ` { projectToRemove } ` removed." ) ;
360+ cmd . StdOut . Should ( ) . Be ( string . Format ( CommonLocalizableStrings . ProjectReferenceRemoved , projectToRemove ) ) ;
360361
361362 slnFile = SlnFile . Read ( solutionPath ) ;
362363 slnFile . Projects . Count . Should ( ) . Be ( 1 ) ;
@@ -383,8 +384,8 @@ public void WhenDuplicateReferencesArePresentItRemovesThemAll()
383384 . ExecuteWithCapturedOutput ( $ "sln remove { projectToRemove } ") ;
384385 cmd . Should ( ) . Pass ( ) ;
385386
386- string outputText = $@ "Project reference ` { projectToRemove } ` removed.
387- Project reference ` { projectToRemove } ` removed." ;
387+ string outputText = string . Format ( CommonLocalizableStrings . ProjectReferenceRemoved , projectToRemove ) ;
388+ outputText += Environment . NewLine + outputText ;
388389 cmd . StdOut . Should ( ) . BeVisuallyEquivalentTo ( outputText ) ;
389390
390391 slnFile = SlnFile . Read ( solutionPath ) ;
@@ -412,9 +413,10 @@ public void WhenPassedMultipleReferencesAndOneOfThemDoesNotExistItRemovesTheOneT
412413 . ExecuteWithCapturedOutput ( $ "sln remove idontexist.csproj { projectToRemove } idontexisteither.csproj") ;
413414 cmd . Should ( ) . Pass ( ) ;
414415
415- string outputText = $@ "Project reference `idontexist.csproj` could not be found.
416- Project reference `{ projectToRemove } ` removed.
417- Project reference `idontexisteither.csproj` could not be found." ;
416+ string outputText = $@ "{ string . Format ( CommonLocalizableStrings . ProjectReferenceCouldNotBeFound , "idontexist.csproj" ) }
417+ { string . Format ( CommonLocalizableStrings . ProjectReferenceRemoved , projectToRemove ) }
418+ { string . Format ( CommonLocalizableStrings . ProjectReferenceCouldNotBeFound , "idontexisteither.csproj" ) } ";
419+
418420 cmd . StdOut . Should ( ) . BeVisuallyEquivalentTo ( outputText ) ;
419421
420422 slnFile = SlnFile . Read ( solutionPath ) ;
0 commit comments