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

Commit b922d7e

Browse files
committed
Make dotnet-remove-reference tests pass on localized setup
1 parent 273dea9 commit b922d7e

File tree

3 files changed

+35
-29
lines changed

3 files changed

+35
-29
lines changed

src/dotnet/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
[assembly: InternalsVisibleTo("dotnet-add-reference.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
1111
[assembly: InternalsVisibleTo("dotnet-help.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
1212
[assembly: InternalsVisibleTo("dotnet-list-reference.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
13+
[assembly: InternalsVisibleTo("dotnet-remove-reference.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
1314
[assembly: InternalsVisibleTo("dotnet-remove-package.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
1415
[assembly: InternalsVisibleTo("dotnet-sln-add.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
1516
[assembly: InternalsVisibleTo("dotnet-sln-list.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]

test/dotnet-remove-reference.Tests/GivenDotnetRemoveP2P.cs

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

44
using FluentAssertions;
55
using Microsoft.Build.Construction;
6+
using Microsoft.DotNet.Tools;
67
using Microsoft.DotNet.Tools.Test.Utilities;
78
using Msbuild.Tests.Utilities;
89
using System;
@@ -132,7 +133,7 @@ public void WhenHelpOptionIsPassedItPrintsUsage(string helpArg)
132133
{
133134
var cmd = new RemoveReferenceCommand().Execute(helpArg);
134135
cmd.Should().Pass();
135-
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
136+
cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(HelpText);
136137
}
137138

138139
[Theory]
@@ -143,8 +144,8 @@ public void WhenNoCommandIsPassedItPrintsError(string commandName)
143144
var cmd = new DotnetCommand()
144145
.ExecuteWithCapturedOutput($"remove {commandName}");
145146
cmd.Should().Fail();
146-
cmd.StdErr.Should().Be("Required command was not provided.");
147-
cmd.StdOut.Should().BeVisuallyEquivalentTo(RemoveCommandHelpText);
147+
cmd.StdErr.Should().Be(CommonLocalizableStrings.RequiredCommandNotPassed);
148+
cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(RemoveCommandHelpText);
148149
}
149150

150151
[Fact]
@@ -169,8 +170,8 @@ public void WhenNonExistingProjectIsPassedItPrintsErrorAndUsage(string projName)
169170
.WithProject(projName)
170171
.Execute($"\"{setup.ValidRefCsprojPath}\"");
171172
cmd.ExitCode.Should().NotBe(0);
172-
cmd.StdErr.Should().Be($"Could not find project or directory `{projName}`.");
173-
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
173+
cmd.StdErr.Should().Be(string.Format(CommonLocalizableStrings.CouldNotFindProjectOrDirectory, projName));
174+
cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(HelpText);
174175
}
175176

176177
[Fact]
@@ -184,8 +185,8 @@ public void WhenBrokenProjectIsPassedItPrintsErrorAndUsage()
184185
.WithProject(projName)
185186
.Execute($"\"{setup.ValidRefCsprojPath}\"");
186187
cmd.ExitCode.Should().NotBe(0);
187-
cmd.StdErr.Should().Be("Project `Broken/Broken.csproj` is invalid.");
188-
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
188+
cmd.StdErr.Should().Be(string.Format(CommonLocalizableStrings.ProjectIsInvalid, "Broken/Broken.csproj"));
189+
cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(HelpText);
189190
}
190191

191192
[Fact]
@@ -198,8 +199,8 @@ public void WhenMoreThanOneProjectExistsInTheDirectoryItPrintsErrorAndUsage()
198199
.WithWorkingDirectory(workingDir)
199200
.Execute($"\"{setup.ValidRefCsprojRelToOtherProjPath}\"");
200201
cmd.ExitCode.Should().NotBe(0);
201-
cmd.StdErr.Should().Be($"Found more than one project in `{workingDir + Path.DirectorySeparatorChar}`. Please specify which one to use.");
202-
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
202+
cmd.StdErr.Should().Be(string.Format(CommonLocalizableStrings.MoreThanOneProjectInDirectory, workingDir + Path.DirectorySeparatorChar));
203+
cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(HelpText);
203204
}
204205

205206
[Fact]
@@ -211,8 +212,8 @@ public void WhenNoProjectsExistsInTheDirectoryItPrintsErrorAndUsage()
211212
.WithWorkingDirectory(setup.TestRoot)
212213
.Execute($"\"{setup.ValidRefCsprojPath}\"");
213214
cmd.ExitCode.Should().NotBe(0);
214-
cmd.StdErr.Should().Be($"Could not find any project in `{setup.TestRoot + Path.DirectorySeparatorChar}`.");
215-
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
215+
cmd.StdErr.Should().Be(string.Format(CommonLocalizableStrings.CouldNotFindAnyProjectInDirectory, setup.TestRoot + Path.DirectorySeparatorChar));
216+
cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(HelpText);
216217
}
217218

218219
[Fact]
@@ -228,7 +229,7 @@ public void ItRemovesRefWithoutCondAndPrintsStatus()
228229
.WithProject(lib.CsProjPath)
229230
.Execute($"\"{libref.CsProjPath}\"");
230231
cmd.Should().Pass();
231-
cmd.StdOut.Should().Be($"Project reference `{Path.Combine("Lib", setup.LibCsprojName)}` removed.");
232+
cmd.StdOut.Should().Be(string.Format(CommonLocalizableStrings.ProjectReferenceRemoved, Path.Combine("Lib", setup.LibCsprojName)));
232233
var csproj = lib.CsProj();
233234
csproj.NumberOfItemGroupsWithoutCondition().Should().Be(noCondBefore - 1);
234235
csproj.NumberOfProjectReferencesWithIncludeContaining(libref.Name).Should().Be(0);
@@ -247,7 +248,7 @@ public void ItRemovesRefWithCondAndPrintsStatus()
247248
.WithProject(lib.CsProjPath)
248249
.Execute($"{FrameworkNet451Arg} \"{libref.CsProjPath}\"");
249250
cmd.Should().Pass();
250-
cmd.StdOut.Should().Be($"Project reference `{Path.Combine("Lib", setup.LibCsprojName)}` removed.");
251+
cmd.StdOut.Should().Be(string.Format(CommonLocalizableStrings.ProjectReferenceRemoved, Path.Combine("Lib", setup.LibCsprojName)));
251252
var csproj = lib.CsProj();
252253
csproj.NumberOfItemGroupsWithConditionContaining(ConditionFrameworkNet451).Should().Be(condBefore - 1);
253254
csproj.NumberOfProjectReferencesWithIncludeAndConditionContaining(libref.Name, ConditionFrameworkNet451).Should().Be(0);
@@ -267,7 +268,7 @@ public void WhenTwoDifferentRefsArePresentItDoesNotRemoveBoth()
267268
.WithProject(lib.CsProjPath)
268269
.Execute($"\"{libref.CsProjPath}\"");
269270
cmd.Should().Pass();
270-
cmd.StdOut.Should().Be($"Project reference `{Path.Combine("Lib", setup.LibCsprojName)}` removed.");
271+
cmd.StdOut.Should().Be(string.Format(CommonLocalizableStrings.ProjectReferenceRemoved, Path.Combine("Lib", setup.LibCsprojName)));
271272
var csproj = lib.CsProj();
272273
csproj.NumberOfItemGroupsWithoutCondition().Should().Be(noCondBefore);
273274
csproj.NumberOfProjectReferencesWithIncludeContaining(libref.Name).Should().Be(0);
@@ -286,7 +287,7 @@ public void WhenRefWithoutCondIsNotThereItPrintsMessage()
286287
.WithProject(lib.CsProjPath)
287288
.Execute($"\"{libref.CsProjPath}\"");
288289
cmd.Should().Pass();
289-
cmd.StdOut.Should().Be($"Project reference `{libref.CsProjPath}` could not be found.");
290+
cmd.StdOut.Should().Be(string.Format(CommonLocalizableStrings.ProjectReferenceCouldNotBeFound, libref.CsProjPath));
290291
lib.CsProjContent().Should().BeEquivalentTo(csprojContetntBefore);
291292
}
292293

@@ -303,7 +304,7 @@ public void WhenRefWithCondIsNotThereItPrintsMessage()
303304
.WithProject(lib.CsProjPath)
304305
.Execute($"{FrameworkNet451Arg} \"{libref.CsProjPath}\"");
305306
cmd.Should().Pass();
306-
cmd.StdOut.Should().Be($"Project reference `{libref.CsProjPath}` could not be found.");
307+
cmd.StdOut.Should().Be(string.Format(CommonLocalizableStrings.ProjectReferenceCouldNotBeFound, libref.CsProjPath));
307308
lib.CsProjContent().Should().BeEquivalentTo(csprojContetntBefore);
308309
}
309310

@@ -323,7 +324,7 @@ public void WhenRefWithAndWithoutCondArePresentAndRemovingNoCondItDoesNotRemoveO
323324
.WithProject(lib.CsProjPath)
324325
.Execute($"\"{librefNoCond.CsProjPath}\"");
325326
cmd.Should().Pass();
326-
cmd.StdOut.Should().Be($"Project reference `{Path.Combine("Lib", setup.LibCsprojName)}` removed.");
327+
cmd.StdOut.Should().Be(string.Format(CommonLocalizableStrings.ProjectReferenceRemoved, Path.Combine("Lib", setup.LibCsprojName)));
327328
var csproj = lib.CsProj();
328329
csproj.NumberOfItemGroupsWithoutCondition().Should().Be(noCondBefore - 1);
329330
csproj.NumberOfProjectReferencesWithIncludeContaining(librefNoCond.Name).Should().Be(0);
@@ -348,7 +349,7 @@ public void WhenRefWithAndWithoutCondArePresentAndRemovingCondItDoesNotRemoveOth
348349
.WithProject(lib.CsProjPath)
349350
.Execute($"{FrameworkNet451Arg} \"{librefCond.CsProjPath}\"");
350351
cmd.Should().Pass();
351-
cmd.StdOut.Should().Be($"Project reference `{Path.Combine("Lib", setup.LibCsprojName)}` removed.");
352+
cmd.StdOut.Should().Be(string.Format(CommonLocalizableStrings.ProjectReferenceRemoved, Path.Combine("Lib", setup.LibCsprojName)));
352353
var csproj = lib.CsProj();
353354
csproj.NumberOfItemGroupsWithoutCondition().Should().Be(noCondBefore);
354355
csproj.NumberOfProjectReferencesWithIncludeContaining(librefNoCond.Name).Should().Be(1);
@@ -373,7 +374,7 @@ public void WhenRefWithDifferentCondIsPresentItDoesNotRemoveIt()
373374
.WithProject(lib.CsProjPath)
374375
.Execute($"{FrameworkNet451Arg} \"{librefCondNet451.CsProjPath}\"");
375376
cmd.Should().Pass();
376-
cmd.StdOut.Should().Be($"Project reference `{Path.Combine("Lib", setup.LibCsprojName)}` removed.");
377+
cmd.StdOut.Should().Be(string.Format(CommonLocalizableStrings.ProjectReferenceRemoved, Path.Combine("Lib", setup.LibCsprojName)));
377378
var csproj = lib.CsProj();
378379
csproj.NumberOfItemGroupsWithConditionContaining(ConditionFrameworkNet451).Should().Be(condNet451Before - 1);
379380
csproj.NumberOfProjectReferencesWithIncludeAndConditionContaining(librefCondNet451.Name, ConditionFrameworkNet451).Should().Be(0);
@@ -389,8 +390,8 @@ public void WhenDuplicateReferencesArePresentItRemovesThemAll()
389390
var proj = new ProjDir(Path.Combine(setup.TestRoot, "WithDoubledRef"));
390391
var libref = GetLibRef(setup);
391392

392-
string removedText = $@"Project reference `{setup.LibCsprojRelPath}` removed.
393-
Project reference `{setup.LibCsprojRelPath}` removed.";
393+
string removedText = $@"{string.Format(CommonLocalizableStrings.ProjectReferenceRemoved, setup.LibCsprojRelPath)}
394+
{string.Format(CommonLocalizableStrings.ProjectReferenceRemoved, setup.LibCsprojRelPath)}";
394395

395396
int noCondBefore = proj.CsProj().NumberOfItemGroupsWithoutCondition();
396397
var cmd = new RemoveReferenceCommand()
@@ -418,7 +419,7 @@ public void WhenPassingRefWithRelPathItRemovesRefWithAbsolutePath()
418419
.WithProject(lib.CsProjPath)
419420
.Execute($"\"{setup.ValidRefCsprojRelToOtherProjPath}\"");
420421
cmd.Should().Pass();
421-
cmd.StdOut.Should().Be($"Project reference `{setup.ValidRefCsprojRelToOtherProjPath}` removed.");
422+
cmd.StdOut.Should().Be(string.Format(CommonLocalizableStrings.ProjectReferenceRemoved, setup.ValidRefCsprojRelToOtherProjPath));
422423
var csproj = lib.CsProj();
423424
csproj.NumberOfItemGroupsWithoutCondition().Should().Be(noCondBefore - 1);
424425
csproj.NumberOfProjectReferencesWithIncludeContaining(libref.Name).Should().Be(0);
@@ -437,7 +438,7 @@ public void WhenPassingRefWithRelPathToProjectItRemovesRefWithPathRelToProject()
437438
.WithProject(lib.CsProjPath)
438439
.Execute($"\"{setup.ValidRefCsprojRelToOtherProjPath}\"");
439440
cmd.Should().Pass();
440-
cmd.StdOut.Should().Be($"Project reference `{setup.ValidRefCsprojRelToOtherProjPath}` removed.");
441+
cmd.StdOut.Should().Be(string.Format(CommonLocalizableStrings.ProjectReferenceRemoved, setup.ValidRefCsprojRelToOtherProjPath));
441442
var csproj = lib.CsProj();
442443
csproj.NumberOfItemGroupsWithoutCondition().Should().Be(noCondBefore - 1);
443444
csproj.NumberOfProjectReferencesWithIncludeContaining(libref.Name).Should().Be(0);
@@ -456,7 +457,7 @@ public void WhenPassingRefWithAbsolutePathItRemovesRefWithRelPath()
456457
.WithProject(lib.CsProjPath)
457458
.Execute($"\"{setup.ValidRefCsprojPath}\"");
458459
cmd.Should().Pass();
459-
cmd.StdOut.Should().Be($"Project reference `{setup.ValidRefCsprojRelToOtherProjPath}` removed.");
460+
cmd.StdOut.Should().Be(string.Format(CommonLocalizableStrings.ProjectReferenceRemoved, setup.ValidRefCsprojRelToOtherProjPath));
460461
var csproj = lib.CsProj();
461462
csproj.NumberOfItemGroupsWithoutCondition().Should().Be(noCondBefore - 1);
462463
csproj.NumberOfProjectReferencesWithIncludeContaining(libref.Name).Should().Be(0);
@@ -470,8 +471,8 @@ public void WhenPassingMultipleReferencesItRemovesThemAll()
470471
var libref = AddLibRef(setup, lib);
471472
var validref = AddValidRef(setup, lib);
472473

473-
string outputText = $@"Project reference `{Path.Combine("Lib", setup.LibCsprojName)}` removed.
474-
Project reference `{Path.Combine(setup.ValidRefCsprojRelPath)}` removed.";
474+
string outputText = $@"{string.Format(CommonLocalizableStrings.ProjectReferenceRemoved, Path.Combine("Lib", setup.LibCsprojName))}
475+
{string.Format(CommonLocalizableStrings.ProjectReferenceRemoved, Path.Combine(setup.ValidRefCsprojRelPath))}";
475476

476477
int noCondBefore = lib.CsProj().NumberOfItemGroupsWithoutCondition();
477478
var cmd = new RemoveReferenceCommand()
@@ -494,16 +495,16 @@ public void WhenPassingMultipleReferencesAndOneOfThemDoesNotExistItRemovesOne()
494495
var libref = GetLibRef(setup);
495496
var validref = AddValidRef(setup, lib);
496497

497-
string OutputText = $@"Project reference `{setup.LibCsprojPath}` could not be found.
498-
Project reference `{Path.Combine(setup.ValidRefCsprojRelPath)}` removed.";
498+
string outputText = $@"{string.Format(CommonLocalizableStrings.ProjectReferenceCouldNotBeFound, setup.LibCsprojPath)}
499+
{string.Format(CommonLocalizableStrings.ProjectReferenceRemoved, Path.Combine(setup.ValidRefCsprojRelPath))}";
499500

500501
int noCondBefore = lib.CsProj().NumberOfItemGroupsWithoutCondition();
501502
var cmd = new RemoveReferenceCommand()
502503
.WithWorkingDirectory(setup.TestRoot)
503504
.WithProject(lib.CsProjPath)
504505
.Execute($"\"{libref.CsProjPath}\" \"{validref.CsProjPath}\"");
505506
cmd.Should().Pass();
506-
cmd.StdOut.Should().BeVisuallyEquivalentTo(OutputText);
507+
cmd.StdOut.Should().BeVisuallyEquivalentTo(outputText);
507508
var csproj = lib.CsProj();
508509
csproj.NumberOfItemGroupsWithoutCondition().Should().Be(noCondBefore - 1);
509510
csproj.NumberOfProjectReferencesWithIncludeContaining(validref.Name).Should().Be(0);

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

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

1215
<ItemGroup>
1316
<ProjectReference Include="..\..\src\Microsoft.DotNet.Cli.Sln.Internal\Microsoft.DotNet.Cli.Sln.Internal.csproj" />
1417
<ProjectReference Include="..\Msbuild.Tests.Utilities\Msbuild.Tests.Utilities.csproj" />
18+
<ProjectReference Include="..\..\src\dotnet\dotnet.csproj" />
1519
</ItemGroup>
1620

1721
<ItemGroup>

0 commit comments

Comments
 (0)