44using FluentAssertions ;
55using Microsoft . Build . Construction ;
66using Microsoft . DotNet . Cli . Sln . Internal ;
7+ using Microsoft . DotNet . Tools ;
78using Microsoft . DotNet . Tools . Test . Utilities ;
89using System ;
910using System . IO ;
@@ -198,7 +199,7 @@ public void WhenHelpOptionIsPassedItPrintsUsage(string helpArg)
198199 var cmd = new DotnetCommand ( )
199200 . ExecuteWithCapturedOutput ( $ "sln add { helpArg } ") ;
200201 cmd . Should ( ) . Pass ( ) ;
201- cmd . StdOut . Should ( ) . BeVisuallyEquivalentTo ( HelpText ) ;
202+ cmd . StdOut . Should ( ) . BeVisuallyEquivalentToIfNotLocalized ( HelpText ) ;
202203 }
203204
204205 [ Theory ]
@@ -209,8 +210,8 @@ public void WhenNoCommandIsPassedItPrintsError(string commandName)
209210 var cmd = new DotnetCommand ( )
210211 . ExecuteWithCapturedOutput ( $ "sln { commandName } ") ;
211212 cmd . Should ( ) . Fail ( ) ;
212- cmd . StdErr . Should ( ) . Be ( "Required command was not provided." ) ;
213- cmd . StdOut . Should ( ) . BeVisuallyEquivalentTo ( SlnCommandHelpText ) ;
213+ cmd . StdErr . Should ( ) . Be ( CommonLocalizableStrings . RequiredCommandNotPassed ) ;
214+ cmd . StdOut . Should ( ) . BeVisuallyEquivalentToIfNotLocalized ( SlnCommandHelpText ) ;
214215 }
215216
216217 [ Fact ]
@@ -219,7 +220,7 @@ public void WhenTooManyArgumentsArePassedItPrintsError()
219220 var cmd = new DotnetCommand ( )
220221 . ExecuteWithCapturedOutput ( "sln one.sln two.sln three.sln add" ) ;
221222 cmd . Should ( ) . Fail ( ) ;
222- 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 add. " ) ;
223+ cmd . StdErr . Should ( ) . BeVisuallyEquivalentTo ( $ "Unrecognized command or argument 'two.sln'\r \n Unrecognized command or argument 'three.sln'\r \n { CommonLocalizableStrings . SpecifyAtLeastOneProjectToAdd } ") ;
223224 }
224225
225226 [ Theory ]
@@ -233,8 +234,8 @@ public void WhenNonExistingSolutionIsPassedItPrintsErrorAndUsage(string solution
233234 var cmd = new DotnetCommand ( )
234235 . ExecuteWithCapturedOutput ( $ "sln { solutionName } add p.csproj") ;
235236 cmd . Should ( ) . Fail ( ) ;
236- cmd . StdErr . Should ( ) . Be ( $ "Could not find solution or directory ` { solutionName } `." ) ;
237- cmd . StdOut . Should ( ) . BeVisuallyEquivalentTo ( HelpText ) ;
237+ cmd . StdErr . Should ( ) . Be ( string . Format ( CommonLocalizableStrings . CouldNotFindSolutionOrDirectory , solutionName ) ) ;
238+ cmd . StdOut . Should ( ) . BeVisuallyEquivalentToIfNotLocalized ( HelpText ) ;
238239 }
239240
240241 [ Fact ]
@@ -252,8 +253,8 @@ public void WhenInvalidSolutionIsPassedItPrintsErrorAndUsage()
252253 . WithWorkingDirectory ( projectDirectory )
253254 . ExecuteWithCapturedOutput ( $ "sln InvalidSolution.sln add { projectToAdd } ") ;
254255 cmd . Should ( ) . Fail ( ) ;
255- cmd . StdErr . Should ( ) . Be ( "Invalid solution ` InvalidSolution.sln`. Expected file header not found." ) ;
256- cmd . StdOut . Should ( ) . BeVisuallyEquivalentTo ( HelpText ) ;
256+ cmd . StdErr . Should ( ) . Be ( string . Format ( CommonLocalizableStrings . InvalidSolutionFormatString , " InvalidSolution.sln" , LocalizableStrings . FileHeaderMissingError ) ) ;
257+ cmd . StdOut . Should ( ) . BeVisuallyEquivalentToIfNotLocalized ( HelpText ) ;
257258 }
258259
259260 [ Fact ]
@@ -272,8 +273,8 @@ public void WhenInvalidSolutionIsFoundItPrintsErrorAndUsage()
272273 . WithWorkingDirectory ( projectDirectory )
273274 . ExecuteWithCapturedOutput ( $ "sln add { projectToAdd } ") ;
274275 cmd . Should ( ) . Fail ( ) ;
275- cmd . StdErr . Should ( ) . Be ( $ "Invalid solution ` { solutionPath } `. Expected file header not found." ) ;
276- cmd . StdOut . Should ( ) . BeVisuallyEquivalentTo ( HelpText ) ;
276+ cmd . StdErr . Should ( ) . Be ( string . Format ( CommonLocalizableStrings . InvalidSolutionFormatString , solutionPath , LocalizableStrings . FileHeaderMissingError ) ) ;
277+ cmd . StdOut . Should ( ) . BeVisuallyEquivalentToIfNotLocalized ( HelpText ) ;
277278 }
278279
279280 [ Fact ]
@@ -290,14 +291,14 @@ public void WhenNoProjectIsPassedItPrintsErrorAndUsage()
290291 . WithWorkingDirectory ( projectDirectory )
291292 . ExecuteWithCapturedOutput ( @"sln App.sln add" ) ;
292293 cmd . Should ( ) . Fail ( ) ;
293- cmd . StdErr . Should ( ) . Be ( "You must specify at least one project to add." ) ;
294+ cmd . StdErr . Should ( ) . Be ( CommonLocalizableStrings . SpecifyAtLeastOneProjectToAdd ) ;
294295
295296 _output . WriteLine ( "[STD OUT]" ) ;
296297 _output . WriteLine ( cmd . StdOut ) ;
297298 _output . WriteLine ( "[HelpText]" ) ;
298299 _output . WriteLine ( HelpText ) ;
299300
300- cmd . StdOut . Should ( ) . BeVisuallyEquivalentTo ( HelpText ) ;
301+ cmd . StdOut . Should ( ) . BeVisuallyEquivalentToIfNotLocalized ( HelpText ) ;
301302 }
302303
303304 [ Fact ]
@@ -315,8 +316,8 @@ public void WhenNoSolutionExistsInTheDirectoryItPrintsErrorAndUsage()
315316 . WithWorkingDirectory ( solutionPath )
316317 . ExecuteWithCapturedOutput ( @"sln add App.csproj" ) ;
317318 cmd . Should ( ) . Fail ( ) ;
318- cmd . StdErr . Should ( ) . Be ( $ "Specified solution file { solutionPath + Path . DirectorySeparatorChar } does not exist, or there is no solution file in the directory." ) ;
319- cmd . StdOut . Should ( ) . BeVisuallyEquivalentTo ( HelpText ) ;
319+ cmd . StdErr . Should ( ) . Be ( string . Format ( CommonLocalizableStrings . SolutionDoesNotExist , solutionPath + Path . DirectorySeparatorChar ) ) ;
320+ cmd . StdOut . Should ( ) . BeVisuallyEquivalentToIfNotLocalized ( HelpText ) ;
320321 }
321322
322323 [ Fact ]
@@ -334,8 +335,8 @@ public void WhenMoreThanOneSolutionExistsInTheDirectoryItPrintsErrorAndUsage()
334335 . WithWorkingDirectory ( projectDirectory )
335336 . ExecuteWithCapturedOutput ( $ "sln add { projectToAdd } ") ;
336337 cmd . Should ( ) . Fail ( ) ;
337- cmd . StdErr . Should ( ) . Be ( $ "Found more than one solution file in { projectDirectory + Path . DirectorySeparatorChar } . Please specify which one to use." ) ;
338- cmd . StdOut . Should ( ) . BeVisuallyEquivalentTo ( HelpText ) ;
338+ cmd . StdErr . Should ( ) . Be ( string . Format ( CommonLocalizableStrings . MoreThanOneSolutionInDirectory , projectDirectory + Path . DirectorySeparatorChar ) ) ;
339+ cmd . StdOut . Should ( ) . BeVisuallyEquivalentToIfNotLocalized ( HelpText ) ;
339340 }
340341
341342 [ Fact ]
@@ -476,7 +477,7 @@ public void WhenValidProjectIsPassedItGetsAdded(string testAsset)
476477 . WithWorkingDirectory ( projectDirectory )
477478 . ExecuteWithCapturedOutput ( $ "sln App.sln add { projectToAdd } ") ;
478479 cmd . Should ( ) . Pass ( ) ;
479- cmd . StdOut . Should ( ) . Be ( $ "Project ` { projectPath } ` added to the solution." ) ;
480+ cmd . StdOut . Should ( ) . Be ( string . Format ( CommonLocalizableStrings . ProjectAddedToTheSolution , projectPath ) ) ;
480481 cmd . StdErr . Should ( ) . BeEmpty ( ) ;
481482 }
482483
@@ -503,7 +504,7 @@ public void WhenInvalidProjectIsPassedItDoesNotGetAdded(string testAsset)
503504 . ExecuteWithCapturedOutput ( $ "sln App.sln add { projectToAdd } ") ;
504505 cmd . Should ( ) . Pass ( ) ;
505506 cmd . StdOut . Should ( ) . BeEmpty ( ) ;
506- cmd . StdErr . Should ( ) . Match ( "Invalid project `*`. The project file could not be loaded.*" ) ;
507+ cmd . StdErr . Should ( ) . Match ( string . Format ( CommonLocalizableStrings . InvalidProjectWithExceptionMessage , '*' , '*' ) ) ;
507508
508509 slnFile = SlnFile . Read ( Path . Combine ( projectDirectory , "App.sln" ) ) ;
509510 slnFile . Projects . Count ( ) . Should ( ) . Be ( expectedNumberOfProjects ) ;
@@ -576,7 +577,7 @@ public void WhenSolutionAlreadyContainsProjectItDoesntDuplicate(string testAsset
576577 . WithWorkingDirectory ( projectDirectory )
577578 . ExecuteWithCapturedOutput ( $ "sln App.sln add { projectToAdd } ") ;
578579 cmd . Should ( ) . Pass ( ) ;
579- cmd . StdOut . Should ( ) . Be ( $ "Solution { solutionPath } already contains project { projectToAdd } ." ) ;
580+ cmd . StdOut . Should ( ) . Be ( string . Format ( CommonLocalizableStrings . SolutionAlreadyContainsProject , solutionPath , projectToAdd ) ) ;
580581 cmd . StdErr . Should ( ) . BeEmpty ( ) ;
581582 }
582583
@@ -598,7 +599,7 @@ public void WhenPassedMultipleProjectsAndOneOfthemDoesNotExistItCancelsWholeOper
598599 . WithWorkingDirectory ( projectDirectory )
599600 . ExecuteWithCapturedOutput ( $ "sln App.sln add { projectToAdd } idonotexist.csproj") ;
600601 cmd . Should ( ) . Fail ( ) ;
601- cmd . StdErr . Should ( ) . Be ( "Project ` idonotexist.csproj` does not exist." ) ;
602+ cmd . StdErr . Should ( ) . Be ( string . Format ( CommonLocalizableStrings . ProjectDoesNotExist , " idonotexist.csproj" ) ) ;
602603
603604 File . ReadAllText ( slnFullPath )
604605 . Should ( ) . BeVisuallyEquivalentTo ( contentBefore ) ;
@@ -654,7 +655,7 @@ public void WhenPassedAProjectItAddsCorrectProjectTypeGuid(
654655 . WithWorkingDirectory ( projectDirectory )
655656 . ExecuteWithCapturedOutput ( $ "sln App.sln add { projectToAdd } ") ;
656657 cmd . Should ( ) . Pass ( ) ;
657- cmd . StdOut . Should ( ) . Be ( $ "Project ` { projectToAdd } ` added to the solution." ) ;
658+ cmd . StdOut . Should ( ) . Be ( string . Format ( CommonLocalizableStrings . ProjectAddedToTheSolution , projectToAdd ) ) ;
658659 cmd . StdErr . Should ( ) . BeEmpty ( ) ;
659660
660661 var slnFile = SlnFile . Read ( Path . Combine ( projectDirectory , "App.sln" ) ) ;
0 commit comments