From 51a2b03cadbcf0753d7be5b0e42f69828250280f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Jare=C5=A1?= Date: Mon, 20 Jan 2020 21:19:51 +0100 Subject: [PATCH] Make --verbosity case insensitive (#2300) Fixes #2179 --- .../Tasks/VSTestTask.cs | 4 ++-- .../VsTestTaskTests.cs | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.TestPlatform.Build/Tasks/VSTestTask.cs b/src/Microsoft.TestPlatform.Build/Tasks/VSTestTask.cs index 79194db9ca..2a07c3af5a 100644 --- a/src/Microsoft.TestPlatform.Build/Tasks/VSTestTask.cs +++ b/src/Microsoft.TestPlatform.Build/Tasks/VSTestTask.cs @@ -247,11 +247,11 @@ private List AddArgs() var quietTestLogging = new List() {"q", "quiet"}; string vsTestVerbosity = "minimal"; - if (normalTestLogging.Contains(this.VSTestVerbosity)) + if (normalTestLogging.Contains(this.VSTestVerbosity.ToLowerInvariant())) { vsTestVerbosity = "normal"; } - else if (quietTestLogging.Contains(this.VSTestVerbosity)) + else if (quietTestLogging.Contains(this.VSTestVerbosity.ToLowerInvariant())) { vsTestVerbosity = "quiet"; } diff --git a/test/Microsoft.TestPlatform.Build.UnitTests/VsTestTaskTests.cs b/test/Microsoft.TestPlatform.Build.UnitTests/VsTestTaskTests.cs index 24613edf9f..8bdc6d282d 100644 --- a/test/Microsoft.TestPlatform.Build.UnitTests/VsTestTaskTests.cs +++ b/test/Microsoft.TestPlatform.Build.UnitTests/VsTestTaskTests.cs @@ -188,6 +188,26 @@ public void CreateArgumentShouldSetConsoleLoggerVerbosityToMinimalIfConsoleLogge Assert.IsNotNull(allArguments.FirstOrDefault(arg => arg.Contains("--logger:Console;Verbosity=minimal"))); } + [TestMethod] + public void CreateArgumentShouldSetConsoleLoggerVerbosityToNormalIfConsoleLoggerIsNotGivenInArgsAndVerbosityIsNormalWithCapitalN() + { + this.vsTestTask.VSTestVerbosity = "Normal"; + + var allArguments = this.vsTestTask.CreateArgument().ToArray(); + + Assert.IsNotNull(allArguments.FirstOrDefault(arg => arg.Contains("--logger:Console;Verbosity=normal"))); + } + + [TestMethod] + public void CreateArgumentShouldSetConsoleLoggerVerbosityToQuietIfConsoleLoggerIsNotGivenInArgsAndVerbosityIsQuietWithCapitalQ() + { + this.vsTestTask.VSTestVerbosity = "Quiet"; + + var allArguments = this.vsTestTask.CreateArgument().ToArray(); + + Assert.IsNotNull(allArguments.FirstOrDefault(arg => arg.Contains("--logger:Console;Verbosity=quiet"))); + } + [TestMethod] public void CreateArgumentShouldPreserveWhiteSpaceInLogger() {