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

Commit 419562b

Browse files
committed
Make dotnet-help.Tests pass on localized setup
1 parent 6e0cfa7 commit 419562b

File tree

5 files changed

+29
-5
lines changed

5 files changed

+29
-5
lines changed

src/dotnet/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66

77
[assembly: AssemblyMetadataAttribute("Serviceable", "True")]
88
[assembly: InternalsVisibleTo("dotnet.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
9+
[assembly: InternalsVisibleTo("dotnet-help.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
910
[assembly: InternalsVisibleTo("dotnet-msbuild.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]

test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/StringAssertionsExtensions.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ public static AndConstraint<StringAssertions> BeVisuallyEquivalentTo(this String
2525
return new AndConstraint<StringAssertions>(assertions);
2626
}
2727

28+
public static AndConstraint<StringAssertions> BeVisuallyEquivalentToIfNotLocalized(this StringAssertions assertions, string expected, string because = "", params object[] becauseArgs)
29+
{
30+
if (!DotnetUnderTest.IsLocalized())
31+
{
32+
return BeVisuallyEquivalentTo(assertions, expected, because, becauseArgs);
33+
}
34+
35+
return new AndConstraint<StringAssertions>(assertions);
36+
}
37+
2838
public static AndConstraint<StringAssertions> ContainVisuallySameFragment(this StringAssertions assertions, string expected, string because = "", params object[] becauseArgs)
2939
{
3040
Execute.Assertion
@@ -34,5 +44,15 @@ public static AndConstraint<StringAssertions> ContainVisuallySameFragment(this S
3444

3545
return new AndConstraint<StringAssertions>(assertions);
3646
}
47+
48+
public static AndConstraint<StringAssertions> ContainVisuallySameFragmentIfNotLocalized(this StringAssertions assertions, string expected, string because = "", params object[] becauseArgs)
49+
{
50+
if (!DotnetUnderTest.IsLocalized())
51+
{
52+
return ContainVisuallySameFragment(assertions, expected, because, becauseArgs);
53+
}
54+
55+
return new AndConstraint<StringAssertions>(assertions);
56+
}
3757
}
3858
}

test/dotnet-help.Tests/GivenThatIWantToShowHelpForDotnetCommand.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void WhenHelpOptionIsPassedToDotnetItPrintsUsage(string helpArg)
6666
var cmd = new DotnetCommand()
6767
.ExecuteWithCapturedOutput($"{helpArg}");
6868
cmd.Should().Pass();
69-
cmd.StdOut.Should().ContainVisuallySameFragment(HelpText);
69+
cmd.StdOut.Should().ContainVisuallySameFragmentIfNotLocalized(HelpText);
7070
}
7171

7272
[Fact]
@@ -75,7 +75,7 @@ public void WhenHelpCommandIsPassedToDotnetItPrintsUsage()
7575
var cmd = new HelpCommand()
7676
.ExecuteWithCapturedOutput();
7777
cmd.Should().Pass();
78-
cmd.StdOut.Should().ContainVisuallySameFragment(HelpText);
78+
cmd.StdOut.Should().ContainVisuallySameFragmentIfNotLocalized(HelpText);
7979
}
8080

8181
[Fact]
@@ -85,8 +85,8 @@ public void WhenInvalidCommandIsPassedToDotnetHelpItPrintsError()
8585
.ExecuteWithCapturedOutput("help invalid");
8686

8787
cmd.Should().Fail();
88-
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.");
89-
cmd.StdOut.Should().ContainVisuallySameFragment(HelpText);
88+
cmd.StdErr.Should().Contain(string.Format(Tools.Help.LocalizableStrings.CommandDoesNotExist, "invalid"));
89+
cmd.StdOut.Should().ContainVisuallySameFragmentIfNotLocalized(HelpText);
9090
}
9191

9292
[WindowsOnlyFact]

test/dotnet-help.Tests/GivenThatIWantToShowHelpForDotnetHelpCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public void WhenHelpOptionIsPassedToDotnetHelpCommandItPrintsUsage(string helpAr
3131
var cmd = new HelpCommand()
3232
.ExecuteWithCapturedOutput($"{helpArg}");
3333
cmd.Should().Pass();
34-
cmd.StdOut.Should().ContainVisuallySameFragment(HelpText);
34+
cmd.StdOut.Should().ContainVisuallySameFragmentIfNotLocalized(HelpText);
3535
}
3636
}
3737
}

test/dotnet-help.Tests/dotnet-help.Tests.csproj

Lines changed: 3 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-help.Tests</AssemblyName>
9+
<AssemblyOriginatorKeyFile>../../tools/Key.snk</AssemblyOriginatorKeyFile>
10+
<SignAssembly>true</SignAssembly>
11+
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
912
<PackageTargetFallback>$(PackageTargetFallback);dnxcore50;portable-net45+win8</PackageTargetFallback>
1013
</PropertyGroup>
1114

0 commit comments

Comments
 (0)