Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.

Commit 3e827fc

Browse files
committed
Make dotnet-sln-remove.Tests pass on localized setup
1 parent 419562b commit 3e827fc

File tree

4 files changed

+32
-23
lines changed

4 files changed

+32
-23
lines changed

src/Microsoft.DotNet.Cli.Sln.Internal/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@
55
using System.Runtime.CompilerServices;
66

77
[assembly: InternalsVisibleTo("Microsoft.DotNet.Cli.Sln.Internal.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100039ac461fa5c82c7dd2557400c4fd4e9dcdf7ac47e3d572548c04cd4673e004916610f4ea5cbf86f2b1ca1cb824f2a7b3976afecfcf4eb72d9a899aa6786effa10c30399e6580ed848231fec48374e41b3acf8811931343fc2f73acf72dae745adbcb7063cc4b50550618383202875223fc75401351cd89c44bf9b50e7fa3796")]
8+
[assembly: InternalsVisibleTo("dotnet-sln-remove.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
9+

src/dotnet/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@
77
[assembly: AssemblyMetadataAttribute("Serviceable", "True")]
88
[assembly: InternalsVisibleTo("dotnet.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
99
[assembly: InternalsVisibleTo("dotnet-help.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
10+
[assembly: InternalsVisibleTo("dotnet-sln-remove.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
1011
[assembly: InternalsVisibleTo("dotnet-msbuild.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]

test/dotnet-sln-remove.Tests/GivenDotnetSlnRemove.cs

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using FluentAssertions;
55
using Microsoft.DotNet.Cli.Sln.Internal;
6+
using Microsoft.DotNet.Tools;
67
using Microsoft.DotNet.Tools.Test.Utilities;
78
using System;
89
using 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\nUnrecognized command or argument 'three.sln'\r\nYou must specify at least one project to remove.");
195+
cmd.StdErr.Should().BeVisuallyEquivalentTo($"Unrecognized command or argument 'two.sln'\r\nUnrecognized 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);

test/dotnet-sln-remove.Tests/dotnet-sln-remove.Tests.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
<RuntimeFrameworkVersion>$(CLI_SharedFrameworkVersion)</RuntimeFrameworkVersion>
77
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
88
<AssemblyName>dotnet-sln-remove.Tests</AssemblyName>
9+
<AssemblyOriginatorKeyFile>../../tools/Key.snk</AssemblyOriginatorKeyFile>
10+
<SignAssembly>true</SignAssembly>
11+
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
912
<PackageTargetFallback>$(PackageTargetFallback);dotnet5.4;portable-net451+win8</PackageTargetFallback>
1013
</PropertyGroup>
1114

@@ -15,6 +18,7 @@
1518
<ProjectReference Include="..\..\src\Microsoft.DotNet.Cli.Utils\Microsoft.DotNet.Cli.Utils.csproj" />
1619
<ProjectReference Include="..\..\src\Microsoft.DotNet.InternalAbstractions\Microsoft.DotNet.InternalAbstractions.csproj" />
1720
<ProjectReference Include="..\..\src\Microsoft.DotNet.TestFramework\Microsoft.DotNet.TestFramework.csproj" />
21+
<ProjectReference Include="..\..\src\dotnet\dotnet.csproj" />
1822
</ItemGroup>
1923

2024
<ItemGroup>

0 commit comments

Comments
 (0)