mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-18 01:25:41 -05:00
Task: localization for the sqltoolsservice (#226)
* locale set through CLI and tests updated * adding cli locale support * adding tests and test constants * cleaning up new tests * fixing test which only fails remotely * adding support for MacOS/Linux * triggering new build due to appveyor timeout * updating usage printout
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using Microsoft.SqlTools.ServiceLayer.Utility;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Test.ServiceHost
|
||||
@@ -47,5 +48,44 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.ServiceHost
|
||||
var queryServiceQueryFailed = SR.QueryServiceQueryFailed("..");
|
||||
var workspaceServiceBufferPositionOutOfOrder = SR.WorkspaceServiceBufferPositionOutOfOrder(1, 2, 3, 4);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SrStringsTestWithEnLocalization()
|
||||
{
|
||||
string locale = "en";
|
||||
var args = new string[] { "--locale " + locale };
|
||||
CommandOptions options = new CommandOptions(args);
|
||||
Assert.Equal(SR.Culture.Name, options.Locale);
|
||||
Assert.Equal(options.Locale, locale);
|
||||
|
||||
var TestLocalizationConstant = SR.TestLocalizationConstant;
|
||||
Assert.Equal(TestLocalizationConstant, "EN_LOCALIZATION");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SrStringsTestWithEsLocalization()
|
||||
{
|
||||
string locale = "es";
|
||||
var args = new string[] { "--locale " + locale };
|
||||
CommandOptions options = new CommandOptions(args);
|
||||
Assert.Equal(SR.Culture.Name, options.Locale);
|
||||
Assert.Equal(options.Locale, locale);
|
||||
|
||||
var TestLocalizationConstant = SR.TestLocalizationConstant;
|
||||
Assert.Equal(TestLocalizationConstant, "ES_LOCALIZATION");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SrStringsTestWithNullLocalization()
|
||||
{
|
||||
SR.Culture = null;
|
||||
var args = new string[] { "" };
|
||||
CommandOptions options = new CommandOptions(args);
|
||||
Assert.Null(SR.Culture);
|
||||
Assert.Equal(options.Locale, "");
|
||||
|
||||
var TestLocalizationConstant = SR.TestLocalizationConstant;
|
||||
Assert.Equal(TestLocalizationConstant, "EN_LOCALIZATION");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace Microsoft.SqlTools.Test.Utility
|
||||
|
||||
Assert.True(options.EnableLogging);
|
||||
Assert.False(options.ShouldExit);
|
||||
Assert.Equal(options.Locale, string.Empty);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -33,6 +34,7 @@ namespace Microsoft.SqlTools.Test.Utility
|
||||
|
||||
Assert.False(options.EnableLogging);
|
||||
Assert.False(options.ShouldExit);
|
||||
Assert.Equal(options.Locale, string.Empty);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -43,6 +45,7 @@ namespace Microsoft.SqlTools.Test.Utility
|
||||
Assert.NotNull(options);
|
||||
|
||||
Assert.True(options.ShouldExit);
|
||||
Assert.Equal(options.Locale, string.Empty);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -53,6 +56,7 @@ namespace Microsoft.SqlTools.Test.Utility
|
||||
Assert.NotNull(options);
|
||||
|
||||
Assert.True(options.ShouldExit);
|
||||
Assert.Equal(options.Locale, string.Empty);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -61,9 +65,49 @@ namespace Microsoft.SqlTools.Test.Utility
|
||||
var args = new string[] {};
|
||||
CommandOptions options = new CommandOptions(args);
|
||||
Assert.NotNull(options);
|
||||
|
||||
|
||||
Assert.False(options.EnableLogging);
|
||||
Assert.False(options.ShouldExit);
|
||||
Assert.Equal(options.Locale, string.Empty);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("en")]
|
||||
[InlineData("es")]
|
||||
public void LocaleSetWhenProvided(string locale)
|
||||
{
|
||||
var args = new string[] {"--locale " + locale};
|
||||
CommandOptions options = new CommandOptions(args);
|
||||
|
||||
// Asserting all options were properly set
|
||||
Assert.NotNull(options);
|
||||
Assert.False(options.ShouldExit);
|
||||
Assert.Equal(options.Locale, locale);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ShouldExitSetWhenInvalidLocale()
|
||||
{
|
||||
string locale = "invalid";
|
||||
var args = new string[] { "--locale " + locale };
|
||||
CommandOptions options = new CommandOptions(args);
|
||||
|
||||
// Asserting all options were properly set
|
||||
Assert.NotNull(options);
|
||||
Assert.False(options.ShouldExit);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LocaleNotSetWhenNotProvided()
|
||||
{
|
||||
var args = new string[] {};
|
||||
CommandOptions options = new CommandOptions(args);
|
||||
|
||||
// Asserting all options were properly set
|
||||
Assert.NotNull(options);
|
||||
Assert.False(options.EnableLogging);
|
||||
Assert.False(options.ShouldExit);
|
||||
Assert.Equal(options.Locale, string.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user