Make dotnet-sln-remove.Tests pass on localized setup

This commit is contained in:
Nick Guerrera 2017-06-13 20:22:27 -07:00
parent 419562ba95
commit 3e827fca61
4 changed files with 32 additions and 23 deletions

View file

@ -5,3 +5,5 @@ using System.Reflection;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Microsoft.DotNet.Cli.Sln.Internal.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100039ac461fa5c82c7dd2557400c4fd4e9dcdf7ac47e3d572548c04cd4673e004916610f4ea5cbf86f2b1ca1cb824f2a7b3976afecfcf4eb72d9a899aa6786effa10c30399e6580ed848231fec48374e41b3acf8811931343fc2f73acf72dae745adbcb7063cc4b50550618383202875223fc75401351cd89c44bf9b50e7fa3796")] [assembly: InternalsVisibleTo("Microsoft.DotNet.Cli.Sln.Internal.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100039ac461fa5c82c7dd2557400c4fd4e9dcdf7ac47e3d572548c04cd4673e004916610f4ea5cbf86f2b1ca1cb824f2a7b3976afecfcf4eb72d9a899aa6786effa10c30399e6580ed848231fec48374e41b3acf8811931343fc2f73acf72dae745adbcb7063cc4b50550618383202875223fc75401351cd89c44bf9b50e7fa3796")]
[assembly: InternalsVisibleTo("dotnet-sln-remove.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]

View file

@ -7,4 +7,5 @@ using System.Runtime.CompilerServices;
[assembly: AssemblyMetadataAttribute("Serviceable", "True")] [assembly: AssemblyMetadataAttribute("Serviceable", "True")]
[assembly: InternalsVisibleTo("dotnet.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("dotnet.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("dotnet-help.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("dotnet-help.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("dotnet-sln-remove.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
[assembly: InternalsVisibleTo("dotnet-msbuild.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] [assembly: InternalsVisibleTo("dotnet-msbuild.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]

View file

@ -3,6 +3,7 @@
using FluentAssertions; using FluentAssertions;
using Microsoft.DotNet.Cli.Sln.Internal; using Microsoft.DotNet.Cli.Sln.Internal;
using Microsoft.DotNet.Tools;
using Microsoft.DotNet.Tools.Test.Utilities; using Microsoft.DotNet.Tools.Test.Utilities;
using System; using System;
using System.IO; using System.IO;
@ -182,7 +183,7 @@ EndGlobal
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.ExecuteWithCapturedOutput($"sln remove {helpArg}"); .ExecuteWithCapturedOutput($"sln remove {helpArg}");
cmd.Should().Pass(); cmd.Should().Pass();
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText); cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(HelpText);
} }
[Fact] [Fact]
@ -191,7 +192,7 @@ EndGlobal
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.ExecuteWithCapturedOutput("sln one.sln two.sln three.sln remove"); .ExecuteWithCapturedOutput("sln one.sln two.sln three.sln remove");
cmd.Should().Fail(); cmd.Should().Fail();
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."); cmd.StdErr.Should().BeVisuallyEquivalentTo($"Unrecognized command or argument 'two.sln'\r\nUnrecognized command or argument 'three.sln'\r\n{CommonLocalizableStrings.SpecifyAtLeastOneProjectToRemove}");
} }
[Theory] [Theory]
@ -202,8 +203,8 @@ EndGlobal
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.ExecuteWithCapturedOutput($"sln {commandName}"); .ExecuteWithCapturedOutput($"sln {commandName}");
cmd.Should().Fail(); cmd.Should().Fail();
cmd.StdErr.Should().Be("Required command was not provided."); cmd.StdErr.Should().Be(CommonLocalizableStrings.RequiredCommandNotPassed);
cmd.StdOut.Should().BeVisuallyEquivalentTo(SlnCommandHelpText); cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(SlnCommandHelpText);
} }
[Theory] [Theory]
@ -217,8 +218,8 @@ EndGlobal
var cmd = new DotnetCommand() var cmd = new DotnetCommand()
.ExecuteWithCapturedOutput($"sln {solutionName} remove p.csproj"); .ExecuteWithCapturedOutput($"sln {solutionName} remove p.csproj");
cmd.Should().Fail(); cmd.Should().Fail();
cmd.StdErr.Should().Be($"Could not find solution or directory `{solutionName}`."); cmd.StdErr.Should().Be(string.Format(CommonLocalizableStrings.CouldNotFindSolutionOrDirectory, solutionName));
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText); cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(HelpText);
} }
[Fact] [Fact]
@ -236,8 +237,8 @@ EndGlobal
.WithWorkingDirectory(projectDirectory) .WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput($"sln InvalidSolution.sln remove {projectToRemove}"); .ExecuteWithCapturedOutput($"sln InvalidSolution.sln remove {projectToRemove}");
cmd.Should().Fail(); cmd.Should().Fail();
cmd.StdErr.Should().Be("Invalid solution `InvalidSolution.sln`. Expected file header not found."); cmd.StdErr.Should().Be(string.Format(CommonLocalizableStrings.InvalidSolutionFormatString, "InvalidSolution.sln", LocalizableStrings.FileHeaderMissingError));
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText); cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(HelpText);
} }
[Fact] [Fact]
@ -256,8 +257,8 @@ EndGlobal
.WithWorkingDirectory(projectDirectory) .WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput($"sln remove {projectToRemove}"); .ExecuteWithCapturedOutput($"sln remove {projectToRemove}");
cmd.Should().Fail(); cmd.Should().Fail();
cmd.StdErr.Should().Be($"Invalid solution `{solutionPath}`. Expected file header not found."); cmd.StdErr.Should().Be(string.Format(CommonLocalizableStrings.InvalidSolutionFormatString, solutionPath, LocalizableStrings.FileHeaderMissingError));
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText); cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(HelpText);
} }
[Fact] [Fact]
@ -274,8 +275,8 @@ EndGlobal
.WithWorkingDirectory(projectDirectory) .WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput(@"sln App.sln remove"); .ExecuteWithCapturedOutput(@"sln App.sln remove");
cmd.Should().Fail(); cmd.Should().Fail();
cmd.StdErr.Should().Be("You must specify at least one project to remove."); cmd.StdErr.Should().Be(CommonLocalizableStrings.SpecifyAtLeastOneProjectToRemove);
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText); cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(HelpText);
} }
[Fact] [Fact]
@ -293,8 +294,8 @@ EndGlobal
.WithWorkingDirectory(solutionPath) .WithWorkingDirectory(solutionPath)
.ExecuteWithCapturedOutput(@"sln remove App.csproj"); .ExecuteWithCapturedOutput(@"sln remove App.csproj");
cmd.Should().Fail(); cmd.Should().Fail();
cmd.StdErr.Should().Be($"Specified solution file {solutionPath + Path.DirectorySeparatorChar} does not exist, or there is no solution file in the directory."); cmd.StdErr.Should().Be(string.Format(CommonLocalizableStrings.SolutionDoesNotExist, solutionPath + Path.DirectorySeparatorChar));
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText); cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(HelpText);
} }
[Fact] [Fact]
@ -312,8 +313,8 @@ EndGlobal
.WithWorkingDirectory(projectDirectory) .WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput($"sln remove {projectToRemove}"); .ExecuteWithCapturedOutput($"sln remove {projectToRemove}");
cmd.Should().Fail(); cmd.Should().Fail();
cmd.StdErr.Should().Be($"Found more than one solution file in {projectDirectory + Path.DirectorySeparatorChar}. Please specify which one to use."); cmd.StdErr.Should().Be(string.Format(CommonLocalizableStrings.MoreThanOneSolutionInDirectory, projectDirectory + Path.DirectorySeparatorChar));
cmd.StdOut.Should().BeVisuallyEquivalentTo(HelpText); cmd.StdOut.Should().BeVisuallyEquivalentToIfNotLocalized(HelpText);
} }
[Fact] [Fact]
@ -332,7 +333,7 @@ EndGlobal
.WithWorkingDirectory(projectDirectory) .WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput("sln remove referenceDoesNotExistInSln.csproj"); .ExecuteWithCapturedOutput("sln remove referenceDoesNotExistInSln.csproj");
cmd.Should().Pass(); cmd.Should().Pass();
cmd.StdOut.Should().Be("Project reference `referenceDoesNotExistInSln.csproj` could not be found."); cmd.StdOut.Should().Be(string.Format(CommonLocalizableStrings.ProjectReferenceCouldNotBeFound, "referenceDoesNotExistInSln.csproj"));
File.ReadAllText(solutionPath) File.ReadAllText(solutionPath)
.Should().BeVisuallyEquivalentTo(contentBefore); .Should().BeVisuallyEquivalentTo(contentBefore);
} }
@ -356,7 +357,7 @@ EndGlobal
.WithWorkingDirectory(projectDirectory) .WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput($"sln remove {projectToRemove}"); .ExecuteWithCapturedOutput($"sln remove {projectToRemove}");
cmd.Should().Pass(); cmd.Should().Pass();
cmd.StdOut.Should().Be($"Project reference `{projectToRemove}` removed."); cmd.StdOut.Should().Be(string.Format(CommonLocalizableStrings.ProjectReferenceRemoved, projectToRemove));
slnFile = SlnFile.Read(solutionPath); slnFile = SlnFile.Read(solutionPath);
slnFile.Projects.Count.Should().Be(1); slnFile.Projects.Count.Should().Be(1);
@ -383,8 +384,8 @@ EndGlobal
.ExecuteWithCapturedOutput($"sln remove {projectToRemove}"); .ExecuteWithCapturedOutput($"sln remove {projectToRemove}");
cmd.Should().Pass(); cmd.Should().Pass();
string outputText = $@"Project reference `{projectToRemove}` removed. string outputText = string.Format(CommonLocalizableStrings.ProjectReferenceRemoved, projectToRemove);
Project reference `{projectToRemove}` removed."; outputText += Environment.NewLine + outputText;
cmd.StdOut.Should().BeVisuallyEquivalentTo(outputText); cmd.StdOut.Should().BeVisuallyEquivalentTo(outputText);
slnFile = SlnFile.Read(solutionPath); slnFile = SlnFile.Read(solutionPath);
@ -412,9 +413,10 @@ Project reference `{projectToRemove}` removed.";
.ExecuteWithCapturedOutput($"sln remove idontexist.csproj {projectToRemove} idontexisteither.csproj"); .ExecuteWithCapturedOutput($"sln remove idontexist.csproj {projectToRemove} idontexisteither.csproj");
cmd.Should().Pass(); cmd.Should().Pass();
string outputText = $@"Project reference `idontexist.csproj` could not be found. string outputText = $@"{string.Format(CommonLocalizableStrings.ProjectReferenceCouldNotBeFound, "idontexist.csproj")}
Project reference `{projectToRemove}` removed. {string.Format(CommonLocalizableStrings.ProjectReferenceRemoved, projectToRemove)}
Project reference `idontexisteither.csproj` could not be found."; {string.Format(CommonLocalizableStrings.ProjectReferenceCouldNotBeFound, "idontexisteither.csproj")}";
cmd.StdOut.Should().BeVisuallyEquivalentTo(outputText); cmd.StdOut.Should().BeVisuallyEquivalentTo(outputText);
slnFile = SlnFile.Read(solutionPath); slnFile = SlnFile.Read(solutionPath);

View file

@ -6,6 +6,9 @@
<RuntimeFrameworkVersion>$(CLI_SharedFrameworkVersion)</RuntimeFrameworkVersion> <RuntimeFrameworkVersion>$(CLI_SharedFrameworkVersion)</RuntimeFrameworkVersion>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles> <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<AssemblyName>dotnet-sln-remove.Tests</AssemblyName> <AssemblyName>dotnet-sln-remove.Tests</AssemblyName>
<AssemblyOriginatorKeyFile>../../tools/Key.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
<PackageTargetFallback>$(PackageTargetFallback);dotnet5.4;portable-net451+win8</PackageTargetFallback> <PackageTargetFallback>$(PackageTargetFallback);dotnet5.4;portable-net451+win8</PackageTargetFallback>
</PropertyGroup> </PropertyGroup>
@ -15,6 +18,7 @@
<ProjectReference Include="..\..\src\Microsoft.DotNet.Cli.Utils\Microsoft.DotNet.Cli.Utils.csproj" /> <ProjectReference Include="..\..\src\Microsoft.DotNet.Cli.Utils\Microsoft.DotNet.Cli.Utils.csproj" />
<ProjectReference Include="..\..\src\Microsoft.DotNet.InternalAbstractions\Microsoft.DotNet.InternalAbstractions.csproj" /> <ProjectReference Include="..\..\src\Microsoft.DotNet.InternalAbstractions\Microsoft.DotNet.InternalAbstractions.csproj" />
<ProjectReference Include="..\..\src\Microsoft.DotNet.TestFramework\Microsoft.DotNet.TestFramework.csproj" /> <ProjectReference Include="..\..\src\Microsoft.DotNet.TestFramework\Microsoft.DotNet.TestFramework.csproj" />
<ProjectReference Include="..\..\src\dotnet\dotnet.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>