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

Commit 273dea9

Browse files
committed
Make dotnet-list-reference tests pass on localized setup
1 parent 20e0a46 commit 273dea9

File tree

3 files changed

+24
-16
lines changed

3 files changed

+24
-16
lines changed

src/dotnet/Properties/AssemblyInfo.cs

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

test/dotnet-list-reference.Tests/GivenDotnetListReference.cs

Lines changed: 19 additions & 16 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;
@@ -50,7 +51,7 @@ public void WhenHelpOptionIsPassedItPrintsUsage(string helpArg)
5051
{
5152
var cmd = new ListReferenceCommand().Execute(helpArg);
5253
cmd.Should().Pass();
53-
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
54+
cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(HelpText);
5455
}
5556

5657
[Theory]
@@ -61,8 +62,8 @@ public void WhenNoCommandIsPassedItPrintsError(string commandName)
6162
var cmd = new DotnetCommand()
6263
.ExecuteWithCapturedOutput($"list {commandName}");
6364
cmd.Should().Fail();
64-
cmd.StdErr.Should().Be("Required command was not provided.");
65-
cmd.StdOut.Should().BeVisuallyEquivalentTo(ListCommandHelpText);
65+
cmd.StdErr.Should().Be(CommonLocalizableStrings.RequiredCommandNotPassed);
66+
cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(ListCommandHelpText);
6667
}
6768

6869
[Fact]
@@ -88,8 +89,8 @@ public void WhenNonExistingProjectIsPassedItPrintsErrorAndUsage(string projName)
8889
.WithProject(projName)
8990
.Execute($"\"{setup.ValidRefCsprojPath}\"");
9091
cmd.ExitCode.Should().NotBe(0);
91-
cmd.StdErr.Should().Be($"Could not find project or directory `{projName}`.");
92-
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
92+
cmd.StdErr.Should().Be(string.Format(CommonLocalizableStrings.CouldNotFindProjectOrDirectory, projName));
93+
cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(HelpText);
9394
}
9495

9596
[Fact]
@@ -103,8 +104,8 @@ public void WhenBrokenProjectIsPassedItPrintsErrorAndUsage()
103104
.WithProject(projName)
104105
.Execute($"\"{setup.ValidRefCsprojPath}\"");
105106
cmd.ExitCode.Should().NotBe(0);
106-
cmd.StdErr.Should().Be("Project `Broken/Broken.csproj` is invalid.");
107-
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
107+
cmd.StdErr.Should().Be(string.Format(CommonLocalizableStrings.ProjectIsInvalid, "Broken/Broken.csproj"));
108+
cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(HelpText);
108109
}
109110

110111
[Fact]
@@ -117,8 +118,8 @@ public void WhenMoreThanOneProjectExistsInTheDirectoryItPrintsErrorAndUsage()
117118
.WithWorkingDirectory(workingDir)
118119
.Execute($"\"{setup.ValidRefCsprojRelToOtherProjPath}\"");
119120
cmd.ExitCode.Should().NotBe(0);
120-
cmd.StdErr.Should().Be($"Found more than one project in `{workingDir + Path.DirectorySeparatorChar}`. Please specify which one to use.");
121-
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
121+
cmd.StdErr.Should().Be(string.Format(CommonLocalizableStrings.MoreThanOneProjectInDirectory, workingDir + Path.DirectorySeparatorChar));
122+
cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(HelpText);
122123
}
123124

124125
[Fact]
@@ -130,8 +131,8 @@ public void WhenNoProjectsExistsInTheDirectoryItPrintsErrorAndUsage()
130131
.WithWorkingDirectory(setup.TestRoot)
131132
.Execute($"\"{setup.ValidRefCsprojPath}\"");
132133
cmd.ExitCode.Should().NotBe(0);
133-
cmd.StdErr.Should().Be($"Could not find any project in `{setup.TestRoot + Path.DirectorySeparatorChar}`.");
134-
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
134+
cmd.StdErr.Should().Be(string.Format(CommonLocalizableStrings.CouldNotFindAnyProjectInDirectory, setup.TestRoot + Path.DirectorySeparatorChar));
135+
cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(HelpText);
135136
}
136137

137138
[Fact]
@@ -143,14 +144,15 @@ public void WhenNoProjectReferencesArePresentInTheProjectItPrintsError()
143144
.WithProject(lib.CsProjPath)
144145
.Execute();
145146
cmd.Should().Pass();
146-
cmd.StdOut.Should().Be($"There are no Project to Project references in project {lib.CsProjPath}. ;; Project to Project is the type of the item being requested (project, package, p2p) and {lib.CsProjPath} is the object operated on (a project file or a solution file). ");
147+
cmd.StdOut.Should().Be(string.Format(CommonLocalizableStrings.NoReferencesFound, CommonLocalizableStrings.P2P, lib.CsProjPath));
147148
}
148149

149150
[Fact]
150151
public void ItPrintsSingleReference()
151152
{
152-
const string OutputText = @"Project reference(s)
153-
--------------------
153+
string OutputText = CommonLocalizableStrings.ProjectReferenceOneOrMore;
154+
OutputText += $@"
155+
{new string('-', OutputText.Length)}
154156
..\ref\ref.csproj";
155157

156158
var lib = NewLib("lib");
@@ -167,8 +169,9 @@ public void ItPrintsSingleReference()
167169
[Fact]
168170
public void ItPrintsMultipleReferences()
169171
{
170-
const string OutputText = @"Project reference(s)
171-
--------------------
172+
string OutputText = CommonLocalizableStrings.ProjectReferenceOneOrMore;
173+
OutputText += $@"
174+
{new string('-', OutputText.Length)}
172175
..\ref1\ref1.csproj
173176
..\ref2\ref2.csproj
174177
..\ref3\ref3.csproj";

test/dotnet-list-reference.Tests/dotnet-list-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-list-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)