Add command line option to specify the logging directory (#336)

Two changes in this PR:
* Add a --log-dir command line parameter and fix command line parsing
* Fix command line parsing where arguments with parameter were parsed incorrectly
This commit is contained in:
Brian O'Neill
2017-05-10 08:55:46 -07:00
committed by GitHub
parent 2e9843cec1
commit 7625c8d83d
6 changed files with 124 additions and 55 deletions

View File

@@ -4,6 +4,7 @@
//
using Microsoft.SqlTools.ServiceLayer.Utility;
using System.IO;
using Xunit;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Utility
@@ -68,6 +69,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Utility
Assert.False(options.EnableLogging);
Assert.False(options.ShouldExit);
Assert.True(string.IsNullOrWhiteSpace(options.LoggingDirectory));
Assert.Equal(options.Locale, string.Empty);
}
@@ -76,7 +78,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Utility
[InlineData("es")]
public void LocaleSetWhenProvided(string locale)
{
var args = new string[] {"--locale " + locale};
var args = new string[] {"--locale", locale};
CommandOptions options = new CommandOptions(args);
// Asserting all options were properly set
@@ -86,10 +88,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Utility
}
[Fact]
public void ShouldExitSetWhenInvalidLocale()
public void ShouldExitNotSetWhenInvalidLocale()
{
string locale = "invalid";
var args = new string[] { "--locale " + locale };
var args = new string[] { "--locale", locale };
CommandOptions options = new CommandOptions(args);
// Asserting all options were properly set
@@ -109,5 +111,18 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Utility
Assert.False(options.ShouldExit);
Assert.Equal(options.Locale, string.Empty);
}
[Fact]
public void LoggingDirectorySet()
{
string logDir = Directory.GetCurrentDirectory();
var args = new string[] { "--log-dir", logDir };
CommandOptions options = new CommandOptions(args);
// Asserting all options were properly set
Assert.NotNull(options);
Assert.False(options.ShouldExit);
Assert.Equal(options.LoggingDirectory, logDir);
}
}
}