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
38 lines (32 loc) · 1.18 KB
/
LocalizationTests.cs
File metadata and controls
38 lines (32 loc) · 1.18 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
38
using System.Globalization;
using System.Linq;
using Xunit;
namespace System.CommandLine.Tests
{
public class LocalizationTests
{
private const string CommandName = "the-command";
private const string ArgumentName = "arg";
[Theory]
[InlineData("es", $"Falta el argumento requerido '{ArgumentName}' para el comando: '{CommandName}'.")]
[InlineData("en-US", $"Required argument '{ArgumentName}' 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;
}
}
}
}