update version of SqlClient used by sql cache (dotnet/extensions#2006)

\n\nCommit migrated from b1ff0d9dc8
This commit is contained in:
Andrew Stanton-Nurse 2019-07-16 14:42:37 -07:00 committed by GitHub
parent d4ba273825
commit 4c0a9d9a6b
2 changed files with 29 additions and 22 deletions

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved. // Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
@ -52,9 +52,9 @@ namespace Microsoft.AspNetCore.Testing.xunit
} }
/// <summary> /// <summary>
/// Skips the test only if the value of the variable matches any of the supplied values. Default is <c>True</c>. /// Runs the test only if the value of the variable matches any of the supplied values. Default is <c>True</c>.
/// </summary> /// </summary>
public bool SkipOnMatch { get; set; } = true; public bool RunOnMatch { get; set; } = true;
public bool IsMet public bool IsMet
{ {
@ -63,7 +63,7 @@ namespace Microsoft.AspNetCore.Testing.xunit
_currentValue = _environmentVariable.Get(_variableName); _currentValue = _environmentVariable.Get(_variableName);
var hasMatched = _values.Any(value => string.Compare(value, _currentValue, ignoreCase: true) == 0); var hasMatched = _values.Any(value => string.Compare(value, _currentValue, ignoreCase: true) == 0);
if (SkipOnMatch) if (RunOnMatch)
{ {
return hasMatched; return hasMatched;
} }
@ -80,7 +80,7 @@ namespace Microsoft.AspNetCore.Testing.xunit
{ {
var value = _currentValue == null ? "(null)" : _currentValue; var value = _currentValue == null ? "(null)" : _currentValue;
return $"Test skipped on environment variable with name '{_variableName}' and value '{value}' " + return $"Test skipped on environment variable with name '{_variableName}' and value '{value}' " +
$"for the '{nameof(SkipOnMatch)}' value of '{SkipOnMatch}'."; $"for the '{nameof(RunOnMatch)}' value of '{RunOnMatch}'.";
} }
} }

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved. // Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Xunit; using Xunit;
@ -8,7 +8,7 @@ namespace Microsoft.AspNetCore.Testing.xunit
public class EnvironmentVariableSkipConditionTest public class EnvironmentVariableSkipConditionTest
{ {
private readonly string _skipReason = "Test skipped on environment variable with name '{0}' and value '{1}'" + private readonly string _skipReason = "Test skipped on environment variable with name '{0}' and value '{1}'" +
$" for the '{nameof(EnvironmentVariableSkipConditionAttribute.SkipOnMatch)}' value of '{{2}}'."; $" for the '{nameof(EnvironmentVariableSkipConditionAttribute.RunOnMatch)}' value of '{{2}}'.";
[Theory] [Theory]
[InlineData("false")] [InlineData("false")]
@ -18,7 +18,7 @@ namespace Microsoft.AspNetCore.Testing.xunit
{ {
// Arrange // Arrange
var attribute = new EnvironmentVariableSkipConditionAttribute( var attribute = new EnvironmentVariableSkipConditionAttribute(
new TestEnvironmentVariable(environmentVariableValue), new TestEnvironmentVariable("Run", environmentVariableValue),
"Run", "Run",
"true"); "true");
@ -37,7 +37,7 @@ namespace Microsoft.AspNetCore.Testing.xunit
{ {
// Arrange // Arrange
var attribute = new EnvironmentVariableSkipConditionAttribute( var attribute = new EnvironmentVariableSkipConditionAttribute(
new TestEnvironmentVariable(environmentVariableValue), new TestEnvironmentVariable("Run", environmentVariableValue),
"Run", "Run",
"true"); "true");
@ -47,7 +47,7 @@ namespace Microsoft.AspNetCore.Testing.xunit
// Assert // Assert
Assert.True(isMet); Assert.True(isMet);
Assert.Equal( Assert.Equal(
string.Format(_skipReason, "Run", environmentVariableValue, attribute.SkipOnMatch), string.Format(_skipReason, "Run", environmentVariableValue, attribute.RunOnMatch),
attribute.SkipReason); attribute.SkipReason);
} }
@ -56,7 +56,7 @@ namespace Microsoft.AspNetCore.Testing.xunit
{ {
// Arrange // Arrange
var attribute = new EnvironmentVariableSkipConditionAttribute( var attribute = new EnvironmentVariableSkipConditionAttribute(
new TestEnvironmentVariable(null), new TestEnvironmentVariable("Run", null),
"Run", "Run",
"true", null); // skip the test when the variable 'Run' is explicitly set to 'true' or is null (default) "true", null); // skip the test when the variable 'Run' is explicitly set to 'true' or is null (default)
@ -66,7 +66,7 @@ namespace Microsoft.AspNetCore.Testing.xunit
// Assert // Assert
Assert.True(isMet); Assert.True(isMet);
Assert.Equal( Assert.Equal(
string.Format(_skipReason, "Run", "(null)", attribute.SkipOnMatch), string.Format(_skipReason, "Run", "(null)", attribute.RunOnMatch),
attribute.SkipReason); attribute.SkipReason);
} }
@ -78,7 +78,7 @@ namespace Microsoft.AspNetCore.Testing.xunit
{ {
// Arrange // Arrange
var attribute = new EnvironmentVariableSkipConditionAttribute( var attribute = new EnvironmentVariableSkipConditionAttribute(
new TestEnvironmentVariable(environmentVariableValue), new TestEnvironmentVariable("Run", environmentVariableValue),
"Run", "Run",
"false", "", null); "false", "", null);
@ -94,7 +94,7 @@ namespace Microsoft.AspNetCore.Testing.xunit
{ {
// Arrange // Arrange
var attribute = new EnvironmentVariableSkipConditionAttribute( var attribute = new EnvironmentVariableSkipConditionAttribute(
new TestEnvironmentVariable("100"), new TestEnvironmentVariable("Build", "100"),
"Build", "Build",
"125", "126"); "125", "126");
@ -109,16 +109,16 @@ namespace Microsoft.AspNetCore.Testing.xunit
[InlineData("CentOS")] [InlineData("CentOS")]
[InlineData(null)] [InlineData(null)]
[InlineData("")] [InlineData("")]
public void IsMet_Matches_WhenSkipOnMatchIsFalse(string environmentVariableValue) public void IsMet_Matches_WhenRunOnMatchIsFalse(string environmentVariableValue)
{ {
// Arrange // Arrange
var attribute = new EnvironmentVariableSkipConditionAttribute( var attribute = new EnvironmentVariableSkipConditionAttribute(
new TestEnvironmentVariable(environmentVariableValue), new TestEnvironmentVariable("LinuxFlavor", environmentVariableValue),
"LinuxFlavor", "LinuxFlavor",
"Ubuntu14.04") "Ubuntu14.04")
{ {
// Example: Run this test on all OSes except on "Ubuntu14.04" // Example: Run this test on all OSes except on "Ubuntu14.04"
SkipOnMatch = false RunOnMatch = false
}; };
// Act // Act
@ -129,16 +129,16 @@ namespace Microsoft.AspNetCore.Testing.xunit
} }
[Fact] [Fact]
public void IsMet_DoesNotMatch_WhenSkipOnMatchIsFalse() public void IsMet_DoesNotMatch_WhenRunOnMatchIsFalse()
{ {
// Arrange // Arrange
var attribute = new EnvironmentVariableSkipConditionAttribute( var attribute = new EnvironmentVariableSkipConditionAttribute(
new TestEnvironmentVariable("Ubuntu14.04"), new TestEnvironmentVariable("LinuxFlavor", "Ubuntu14.04"),
"LinuxFlavor", "LinuxFlavor",
"Ubuntu14.04") "Ubuntu14.04")
{ {
// Example: Run this test on all OSes except on "Ubuntu14.04" // Example: Run this test on all OSes except on "Ubuntu14.04"
SkipOnMatch = false RunOnMatch = false
}; };
// Act // Act
@ -150,8 +150,11 @@ namespace Microsoft.AspNetCore.Testing.xunit
private struct TestEnvironmentVariable : IEnvironmentVariable private struct TestEnvironmentVariable : IEnvironmentVariable
{ {
public TestEnvironmentVariable(string value) private readonly string _varName;
public TestEnvironmentVariable(string varName, string value)
{ {
_varName = varName;
Value = value; Value = value;
} }
@ -159,7 +162,11 @@ namespace Microsoft.AspNetCore.Testing.xunit
public string Get(string name) public string Get(string name)
{ {
return Value; if(string.Equals(name, _varName, System.StringComparison.OrdinalIgnoreCase))
{
return Value;
}
return string.Empty;
} }
} }
} }