Make dotnet-help.Tests pass on localized setup

This commit is contained in:
Nick Guerrera 2017-06-13 19:24:30 -07:00
parent 6e0cfa7839
commit 419562ba95
5 changed files with 29 additions and 5 deletions

View file

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

View file

@ -25,6 +25,16 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
return new AndConstraint<StringAssertions>(assertions);
}
public static AndConstraint<StringAssertions> BeVisuallyEquivalentToIfNotLocalized(this StringAssertions assertions, string expected, string because = "", params object[] becauseArgs)
{
if (!DotnetUnderTest.IsLocalized())
{
return BeVisuallyEquivalentTo(assertions, expected, because, becauseArgs);
}
return new AndConstraint<StringAssertions>(assertions);
}
public static AndConstraint<StringAssertions> ContainVisuallySameFragment(this StringAssertions assertions, string expected, string because = "", params object[] becauseArgs)
{
Execute.Assertion
@ -34,5 +44,15 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
return new AndConstraint<StringAssertions>(assertions);
}
public static AndConstraint<StringAssertions> ContainVisuallySameFragmentIfNotLocalized(this StringAssertions assertions, string expected, string because = "", params object[] becauseArgs)
{
if (!DotnetUnderTest.IsLocalized())
{
return ContainVisuallySameFragment(assertions, expected, because, becauseArgs);
}
return new AndConstraint<StringAssertions>(assertions);
}
}
}

View file

@ -66,7 +66,7 @@ runtime-options:
var cmd = new DotnetCommand()
.ExecuteWithCapturedOutput($"{helpArg}");
cmd.Should().Pass();
cmd.StdOut.Should().ContainVisuallySameFragment(HelpText);
cmd.StdOut.Should().ContainVisuallySameFragmentIfNotLocalized(HelpText);
}
[Fact]
@ -75,7 +75,7 @@ runtime-options:
var cmd = new HelpCommand()
.ExecuteWithCapturedOutput();
cmd.Should().Pass();
cmd.StdOut.Should().ContainVisuallySameFragment(HelpText);
cmd.StdOut.Should().ContainVisuallySameFragmentIfNotLocalized(HelpText);
}
[Fact]
@ -85,8 +85,8 @@ runtime-options:
.ExecuteWithCapturedOutput("help invalid");
cmd.Should().Fail();
cmd.StdErr.Should().ContainVisuallySameFragment($"Specified command 'invalid' is not a valid CLI command. Please specify a valid CLI commands. For more information, run dotnet help.");
cmd.StdOut.Should().ContainVisuallySameFragment(HelpText);
cmd.StdErr.Should().Contain(string.Format(Tools.Help.LocalizableStrings.CommandDoesNotExist, "invalid"));
cmd.StdOut.Should().ContainVisuallySameFragmentIfNotLocalized(HelpText);
}
[WindowsOnlyFact]

View file

@ -31,7 +31,7 @@ Options:
var cmd = new HelpCommand()
.ExecuteWithCapturedOutput($"{helpArg}");
cmd.Should().Pass();
cmd.StdOut.Should().ContainVisuallySameFragment(HelpText);
cmd.StdOut.Should().ContainVisuallySameFragmentIfNotLocalized(HelpText);
}
}
}

View file

@ -6,6 +6,9 @@
<RuntimeFrameworkVersion>$(CLI_SharedFrameworkVersion)</RuntimeFrameworkVersion>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<AssemblyName>dotnet-help.Tests</AssemblyName>
<AssemblyOriginatorKeyFile>../../tools/Key.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
<PackageTargetFallback>$(PackageTargetFallback);dnxcore50;portable-net45+win8</PackageTargetFallback>
</PropertyGroup>