forked from dotnet/command-line-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLocalizationTests.cs
More file actions
37 lines (31 loc) · 1.11 KB
/
LocalizationTests.cs
File metadata and controls
37 lines (31 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System.Globalization;
using System.Linq;
using Xunit;
namespace System.CommandLine.ApiCompatibility.Tests
{
public class LocalizationTests
{
private const string CommandName = "the-command";
[Theory]
[InlineData("es", $"Falta el argumento requerido para el comando: '{CommandName}'.")]
[InlineData("en-US", $"Required argument missing for command: '{CommandName}'.")]
public void ErrorMessages_AreLocalized(string cultureName, string expectedMessage)
{
CultureInfo uiCultureBefore = CultureInfo.CurrentUICulture;
try
{
CultureInfo.CurrentUICulture = new CultureInfo(cultureName);
Command command = new(CommandName)
{
new Argument<string>("arg")
};
ParseResult parseResult = command.Parse(CommandName);
Assert.Equal(expectedMessage, parseResult.Errors.Single().Message);
}
finally
{
CultureInfo.CurrentUICulture = uiCultureBefore;
}
}
}
}