Added option --enable-logging to enable diagnostic logging (#106)

* Added option --enable-logging to enable diagnostic logging

* Addressing feedback

* Addressing feedback, round 2
This commit is contained in:
Mitchell Sternke
2016-10-20 17:56:33 -07:00
committed by GitHub
parent 989ad065dd
commit f35b9fda27
3 changed files with 168 additions and 1 deletions

View File

@@ -0,0 +1,69 @@
//
// 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.Test.Utility
{
/// <summary>
/// Tests for the CommandOptions class
/// </summary>
public class CommandOptionsTests
{
[Fact]
public void LoggingEnabledWhenFlagProvided()
{
var args = new string[] {"--enable-logging"};
CommandOptions options = new CommandOptions(args);
Assert.NotNull(options);
Assert.True(options.EnableLogging);
Assert.False(options.ShouldExit);
}
[Fact]
public void LoggingDisabledWhenFlagNotProvided()
{
var args = new string[] {};
CommandOptions options = new CommandOptions(args);
Assert.NotNull(options);
Assert.False(options.EnableLogging);
Assert.False(options.ShouldExit);
}
[Fact]
public void UsageIsShownWhenHelpFlagProvided()
{
var args = new string[] {"--help"};
CommandOptions options = new CommandOptions(args);
Assert.NotNull(options);
Assert.True(options.ShouldExit);
}
[Fact]
public void UsageIsShownWhenBadArgumentsProvided()
{
var args = new string[] {"--unknown-argument", "/bad-argument"};
CommandOptions options = new CommandOptions(args);
Assert.NotNull(options);
Assert.True(options.ShouldExit);
}
[Fact]
public void DefaultValuesAreUsedWhenNoArgumentsAreProvided()
{
var args = new string[] {};
CommandOptions options = new CommandOptions(args);
Assert.NotNull(options);
Assert.False(options.EnableLogging);
Assert.False(options.ShouldExit);
}
}
}