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

Commit 5da3bfd

Browse files
committed
Make dotnet-sln-list.Tests pass on localized setup
1 parent 0a4e05b commit 5da3bfd

File tree

4 files changed

+25
-16
lines changed

4 files changed

+25
-16
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,5 +5,7 @@
55
using System.Runtime.CompilerServices;
66

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

11+

src/dotnet/Properties/AssemblyInfo.cs

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

test/dotnet-sln-list.Tests/GivenDotnetSlnList.cs

Lines changed: 18 additions & 16 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;
@@ -48,7 +49,7 @@ public void WhenHelpOptionIsPassedItPrintsUsage(string helpArg)
4849
var cmd = new DotnetCommand()
4950
.ExecuteWithCapturedOutput($"sln list {helpArg}");
5051
cmd.Should().Pass();
51-
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
52+
cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(HelpText);
5253
}
5354

5455
[Theory]
@@ -59,8 +60,8 @@ public void WhenNoCommandIsPassedItPrintsError(string commandName)
5960
var cmd = new DotnetCommand()
6061
.ExecuteWithCapturedOutput($"sln {commandName}");
6162
cmd.Should().Fail();
62-
cmd.StdErr.Should().Be("Required command was not provided.");
63-
cmd.StdOut.Should().BeVisuallyEquivalentTo(SlnCommandHelpText);
63+
cmd.StdErr.Should().Be(CommonLocalizableStrings.RequiredCommandNotPassed);
64+
cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(SlnCommandHelpText);
6465
}
6566

6667
[Fact]
@@ -83,8 +84,8 @@ public void WhenNonExistingSolutionIsPassedItPrintsErrorAndUsage(string solution
8384
var cmd = new DotnetCommand()
8485
.ExecuteWithCapturedOutput($"sln {solutionName} list");
8586
cmd.Should().Fail();
86-
cmd.StdErr.Should().Be($"Could not find solution or directory `{solutionName}`.");
87-
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
87+
cmd.StdErr.Should().Be(string.Format(CommonLocalizableStrings.CouldNotFindSolutionOrDirectory, solutionName));
88+
cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(HelpText);
8889
}
8990

9091
[Fact]
@@ -101,8 +102,8 @@ public void WhenInvalidSolutionIsPassedItPrintsErrorAndUsage()
101102
.WithWorkingDirectory(projectDirectory)
102103
.ExecuteWithCapturedOutput("sln InvalidSolution.sln list");
103104
cmd.Should().Fail();
104-
cmd.StdErr.Should().Be("Invalid solution `InvalidSolution.sln`. Expected file header not found.");
105-
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
105+
cmd.StdErr.Should().Be(string.Format(CommonLocalizableStrings.InvalidSolutionFormatString, "InvalidSolution.sln", LocalizableStrings.FileHeaderMissingError));
106+
cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(HelpText);
106107
}
107108

108109
[Fact]
@@ -120,8 +121,8 @@ public void WhenInvalidSolutionIsFoundItPrintsErrorAndUsage()
120121
.WithWorkingDirectory(projectDirectory)
121122
.ExecuteWithCapturedOutput("sln list");
122123
cmd.Should().Fail();
123-
cmd.StdErr.Should().Be($"Invalid solution `{solutionFullPath}`. Expected file header not found.");
124-
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
124+
cmd.StdErr.Should().Be(string.Format(CommonLocalizableStrings.InvalidSolutionFormatString, solutionFullPath, LocalizableStrings.FileHeaderMissingError));
125+
cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(HelpText);
125126
}
126127

127128
[Fact]
@@ -139,8 +140,8 @@ public void WhenNoSolutionExistsInTheDirectoryItPrintsErrorAndUsage()
139140
.WithWorkingDirectory(solutionDir)
140141
.ExecuteWithCapturedOutput("sln list");
141142
cmd.Should().Fail();
142-
cmd.StdErr.Should().Be($"Specified solution file {solutionDir + Path.DirectorySeparatorChar} does not exist, or there is no solution file in the directory.");
143-
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
143+
cmd.StdErr.Should().Be(string.Format(CommonLocalizableStrings.SolutionDoesNotExist, solutionDir + Path.DirectorySeparatorChar));
144+
cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(HelpText);
144145
}
145146

146147
[Fact]
@@ -157,8 +158,8 @@ public void WhenMoreThanOneSolutionExistsInTheDirectoryItPrintsErrorAndUsage()
157158
.WithWorkingDirectory(projectDirectory)
158159
.ExecuteWithCapturedOutput("sln list");
159160
cmd.Should().Fail();
160-
cmd.StdErr.Should().Be($"Found more than one solution file in {projectDirectory + Path.DirectorySeparatorChar}. Please specify which one to use.");
161-
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText);
161+
cmd.StdErr.Should().Be(string.Format(CommonLocalizableStrings.MoreThanOneSolutionInDirectory, projectDirectory + Path.DirectorySeparatorChar));
162+
cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(HelpText);
162163
}
163164

164165
[Fact]
@@ -175,14 +176,15 @@ public void WhenNoProjectReferencesArePresentInTheSolutionItPrintsANoProjectMess
175176
.WithWorkingDirectory(projectDirectory)
176177
.ExecuteWithCapturedOutput("sln list");
177178
cmd.Should().Pass();
178-
cmd.StdOut.Should().Be("No projects found in the solution.");
179+
cmd.StdOut.Should().Be(CommonLocalizableStrings.NoProjectsFound);
179180
}
180181

181182
[Fact]
182183
public void WhenProjectReferencesArePresentInTheSolutionItListsThem()
183184
{
184-
string OutputText = $@"Project reference(s)
185-
--------------------
185+
string OutputText = CommonLocalizableStrings.ProjectReferenceOneOrMore;
186+
OutputText += $@"
187+
{new string('-', OutputText.Length)}
186188
{Path.Combine("App", "App.csproj")}
187189
{Path.Combine("Lib", "Lib.csproj")}";
188190

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