Test | Removing internal build of XunitExtensions and using the nuget (#2033)
This commit is contained in:
Родитель
97863e59ad
Коммит
57d287c1ca
|
@ -169,3 +169,7 @@ dotnet_code_quality.ca1802.api_surface = private, internal
|
|||
|
||||
[*.cs]
|
||||
dotnet_code_quality.CA2100.excluded_type_names_with_derived_types = Microsoft.Data.SqlClient.ManualTesting.Tests.*
|
||||
dotnet_diagnostic.xUnit1031.severity=none
|
||||
dotnet_diagnostic.xUnit1030.severity=none
|
||||
|
||||
|
||||
|
|
|
@ -53,7 +53,6 @@
|
|||
<FunctionalTests Include="**/tools/TDS/TDS/TDS.csproj" />
|
||||
<FunctionalTests Include="**/tools/TDS/TDS.EndPoint/TDS.EndPoint.csproj" />
|
||||
<FunctionalTests Include="**/tools/TDS/TDS.Servers/TDS.Servers.csproj" />
|
||||
<FunctionalTests Include="**/tools/Microsoft.DotNet.XUnitExtensions/Microsoft.DotNet.XUnitExtensions.csproj" />
|
||||
<FunctionalTests Include="**/tools/CoreFx.Private.TestUtilities/CoreFx.Private.TestUtilities.csproj" />
|
||||
<FunctionalTests Include="**/ManualTests/SQL/UdtTest/UDTs/Address/Address.csproj" />
|
||||
<FunctionalTests Include="**/FunctionalTests/Microsoft.Data.SqlClient.Tests.csproj" />
|
||||
|
@ -64,7 +63,6 @@
|
|||
<ManualTests Include="**/ManualTests/SQL/UdtTest/UDTs/Circle/Circle.csproj" />
|
||||
<ManualTests Include="**/ManualTests/SQL/UdtTest/UDTs/Shapes/Shapes.csproj" />
|
||||
<ManualTests Include="**/ManualTests/SQL/UdtTest/UDTs/Utf8String/Utf8String.csproj" />
|
||||
<ManualTests Include="**/tools/Microsoft.DotNet.XUnitExtensions/Microsoft.DotNet.XUnitExtensions.csproj" />
|
||||
<ManualTests Include="**/tools/Microsoft.Data.SqlClient.TestUtilities/Microsoft.Data.SqlClient.TestUtilities.csproj"/>
|
||||
<ManualTests Include="**/tools/CoreFx.Private.TestUtilities/CoreFx.Private.TestUtilities.csproj" />
|
||||
<ManualTests Include="**/CustomConfigurableRetryLogic/CustomRetryLogicProvider.csproj" />
|
||||
|
|
|
@ -72,8 +72,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Data.SqlClient.Al
|
|||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "add-ons", "add-ons", "{C9726AED-D6A3-4AAC-BA04-92DD1F079594}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.XUnitExtensions", "Microsoft.Data.SqlClient\tests\tools\Microsoft.DotNet.XUnitExtensions\Microsoft.DotNet.XUnitExtensions.csproj", "{FDA6971D-9F57-4DA4-B10A-261C91684CFC}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "doc", "doc", "{ED952CF7-84DF-437A-B066-F516E9BE1C2C}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "snippets", "snippets", "{71F356DC-DFA3-4163-8BFE-D268722CE189}"
|
||||
|
|
|
@ -303,7 +303,7 @@ namespace Microsoft.Data.SqlClient.Tests.AlwaysEncryptedTests
|
|||
break;
|
||||
|
||||
default:
|
||||
Assert.True(false, "unexpected data type.");
|
||||
Assert.Fail("unexpected data type.");
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using System.Transactions;
|
||||
using Xunit;
|
||||
|
@ -11,7 +12,7 @@ namespace Microsoft.Data.SqlClient.Tests
|
|||
{
|
||||
public class AmbientTransactionFailureTest
|
||||
{
|
||||
|
||||
private static readonly bool s_isNotArmProcess = TestUtility.IsNotArmProcess;
|
||||
private static readonly string s_servername = Guid.NewGuid().ToString();
|
||||
private static readonly string s_connectionStringWithEnlistAsDefault = $"Data Source={s_servername}; Integrated Security=true; Connect Timeout=1;";
|
||||
private static readonly string s_connectionStringWithEnlistOff = $"Data Source={s_servername}; Integrated Security=true; Connect Timeout=1;Enlist=False";
|
||||
|
@ -73,7 +74,7 @@ namespace Microsoft.Data.SqlClient.Tests
|
|||
new object[] { EnlistConnectionInTransaction, s_connectionStringWithEnlistOff }
|
||||
};
|
||||
|
||||
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotArmProcess))] // https://github.com/dotnet/corefx/issues/21598
|
||||
[ConditionalTheory(nameof(s_isNotArmProcess))] // https://github.com/dotnet/corefx/issues/21598
|
||||
[MemberData(nameof(ExceptionTestDataForSqlException))]
|
||||
public void TestSqlException(Action<string> connectAction, string connectionString)
|
||||
{
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Data.SqlClient.Tests;
|
||||
using Xunit;
|
||||
using Xunit.Sdk;
|
||||
|
||||
|
@ -12,7 +13,7 @@ namespace System
|
|||
{
|
||||
public static class AssertExtensions
|
||||
{
|
||||
private static bool IsFullFramework => RuntimeInformation.FrameworkDescription.StartsWith(".NET Framework", StringComparison.Ordinal);
|
||||
private static bool IsFullFramework => TestUtility.IsFullFramework;
|
||||
|
||||
public static void Throws<T>(Action action, string message)
|
||||
where T : Exception
|
||||
|
@ -35,7 +36,7 @@ namespace System
|
|||
IsFullFramework ?
|
||||
netFxParamName : netCoreParamName;
|
||||
|
||||
if (!RuntimeInformation.FrameworkDescription.StartsWith(".NET Native", StringComparison.Ordinal))
|
||||
if (!TestUtility.NetNative)
|
||||
Assert.Equal(expectedParamName, exception.ParamName);
|
||||
}
|
||||
|
||||
|
@ -54,7 +55,7 @@ namespace System
|
|||
IsFullFramework ?
|
||||
netFxParamName : netCoreParamName;
|
||||
|
||||
if (!RuntimeInformation.FrameworkDescription.StartsWith(".NET Native", StringComparison.Ordinal))
|
||||
if (!TestUtility.NetNative)
|
||||
Assert.Equal(expectedParamName, exception.ParamName);
|
||||
}
|
||||
|
||||
|
@ -63,7 +64,7 @@ namespace System
|
|||
{
|
||||
T exception = Assert.Throws<T>(action);
|
||||
|
||||
if (!RuntimeInformation.FrameworkDescription.StartsWith(".NET Native", StringComparison.Ordinal))
|
||||
if (!TestUtility.NetNative)
|
||||
Assert.Equal(paramName, exception.ParamName);
|
||||
|
||||
return exception;
|
||||
|
@ -82,7 +83,7 @@ namespace System
|
|||
{
|
||||
T exception = Assert.Throws<T>(testCode);
|
||||
|
||||
if (!RuntimeInformation.FrameworkDescription.StartsWith(".NET Native", StringComparison.Ordinal))
|
||||
if (!TestUtility.NetNative)
|
||||
Assert.Equal(paramName, exception.ParamName);
|
||||
|
||||
return exception;
|
||||
|
@ -93,7 +94,7 @@ namespace System
|
|||
{
|
||||
T exception = await Assert.ThrowsAsync<T>(testCode);
|
||||
|
||||
if (!RuntimeInformation.FrameworkDescription.StartsWith(".NET Native", StringComparison.Ordinal))
|
||||
if (!TestUtility.NetNative)
|
||||
Assert.Equal(paramName, exception.ParamName);
|
||||
|
||||
return exception;
|
||||
|
@ -298,24 +299,5 @@ namespace System
|
|||
throw new XunitException(AddOptionalUserMessage($"Expected: {actual} to be greater than or equal to {greaterThanOrEqualTo}", userMessage));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates that the actual byte array is equal to the expected byte array. XUnit only displays the first 5 values
|
||||
/// of each collection if the test fails. This doesn't display at what point or how the equality assertion failed.
|
||||
/// </summary>
|
||||
/// <param name="expected">The byte array that <paramref name="actual"/> should be equal to.</param>
|
||||
/// <param name="actual"></param>
|
||||
public static void Equal(byte[] expected, byte[] actual)
|
||||
{
|
||||
try
|
||||
{
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
catch (AssertActualExpectedException)
|
||||
{
|
||||
string expectedString = string.Join(", ", expected);
|
||||
string actualString = string.Join(", ", actual);
|
||||
throw new AssertActualExpectedException(expectedString, actualString, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Microsoft.Data.SqlClient.Tests
|
||||
{
|
||||
public static class TestUtility
|
||||
{
|
||||
public static readonly bool IsNotArmProcess = RuntimeInformation.ProcessArchitecture != Architecture.Arm;
|
||||
public static bool IsFullFramework => RuntimeInformation.FrameworkDescription.StartsWith(".NET Framework");
|
||||
public static bool NetNative => RuntimeInformation.FrameworkDescription.StartsWith(".NET Native");
|
||||
}
|
||||
}
|
|
@ -25,8 +25,10 @@
|
|||
<Compile Include="AlwaysEncryptedTests\SqlConnectionShould.cs" />
|
||||
<Compile Include="AlwaysEncryptedTests\TestFixtures.cs" />
|
||||
<Compile Include="AlwaysEncryptedTests\Utility.cs" />
|
||||
<Compile Include="AssertExtensions.cs" />
|
||||
<Compile Include="DataCommon\AssemblyResourceManager.cs" />
|
||||
<Compile Include="DataCommon\SystemDataResourceManager.cs" />
|
||||
<Compile Include="DataCommon\TestUtility.cs" />
|
||||
<Compile Include="LocalizationTest.cs" />
|
||||
<Compile Include="MultipartIdentifierTests.cs" />
|
||||
<Compile Include="SqlClientLoggerTest.cs" />
|
||||
|
@ -66,6 +68,25 @@
|
|||
<Compile Include="SqlHelperTest.cs" />
|
||||
<Compile Include="..\..\src\Microsoft\Data\Common\MultipartIdentifier.cs" />
|
||||
</ItemGroup>
|
||||
<!-- XUnit and XUnit extensions -->
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="$(MicrosoftNETFrameworkReferenceAssembliesVersion)" Condition="$(TargetGroup) == 'netfx'">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Condition="$(TargetGroup) == 'netfx'" Include="System.Runtime.InteropServices.RuntimeInformation" Version="$(SystemRuntimeInteropServicesRuntimeInformationVersion)" />
|
||||
<PackageReference Include="xunit" Version="$(XunitVersion)" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitVersion)">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="xunit.runner.console" Version="$(XunitVersion)">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="xunit.runner.utility" Version="$(XunitVersion)" />
|
||||
<PackageReference Include="Microsoft.DotNet.XUnitExtensions" Version="$(MicrosoftDotNetXUnitExtensionsVersion)" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="$(MicrosoftExtensionsHosting)" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkVersion)" />
|
||||
|
@ -92,21 +113,21 @@
|
|||
<ProjectReference Include="$(TestsPath)tools\TDS\TDS\TDS.csproj">
|
||||
<Name>TDS</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="$(TestsPath)tools\Microsoft.DotNet.XUnitExtensions\Microsoft.DotNet.XUnitExtensions.csproj">
|
||||
<Name>Microsoft.DotNet.XUnitExtensions</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Condition="!$(ReferenceType.Contains('NetStandard'))" Include="$(AddOnsPath)AzureKeyVaultProvider\Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider.csproj" />
|
||||
<ProjectReference Condition="'$(TargetGroup)'=='netcoreapp' AND $(ReferenceType)=='Project'" Include="$(NetCoreSource)src\Microsoft.Data.SqlClient.csproj" />
|
||||
<ProjectReference Condition="'$(TargetGroup)'=='netfx' AND $(ReferenceType)=='Project'" Include="$(NetFxSource)src\Microsoft.Data.SqlClient.csproj" />
|
||||
<ProjectReference Condition="$(ReferenceType.Contains('NetStandard'))" Include="$(TestsPath)NSLibrary\Microsoft.Data.SqlClient.NSLibrary.csproj" />
|
||||
<ProjectReference Condition="!$(ReferenceType.Contains('Package'))" Include="$(SqlServerSource)Microsoft.SqlServer.Server.csproj" />
|
||||
<PackageReference Condition="$(ReferenceType.Contains('Package'))" Include="Microsoft.Data.SqlClient" Version="$(TestMicrosoftDataSqlClientVersion)" />
|
||||
<!-- .NET Core 3.1.2 known issue; It should be added manually! -->
|
||||
<!-- https://github.com/dotnet/core/blob/main/release-notes/3.1/3.1-known-issues.md#net-core-312-sdk-31102-sdk -->
|
||||
<PackageReference Condition="'$(TargetFramework)'=='net6.0' AND $(ReferenceType)=='Package'" Include="System.Security.Cryptography.Cng" Version="$(SystemSecurityCryptographyCngVersion)" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Condition="'$(TargetGroup)'=='netfx' AND $(ReferenceType)=='Project'" Include="$(BinFolder)$(Configuration).AnyCPU\Microsoft.Data.SqlClient\netfx\**\*SNI*.dll" CopyToOutputDirectory="PreserveNewest" />
|
||||
<PackageReference Condition="$(ReferenceType.Contains('Package'))" Include="Microsoft.Identity.Client" Version="$(MicrosoftIdentityClientVersion)" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ContentWithTargetPath Include="..\tools\Microsoft.Data.SqlClient.TestUtilities\xunit.runner.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<TargetPath>xunit.runner.json</TargetPath>
|
||||
</ContentWithTargetPath>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Diagnostics;
|
||||
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.Data.SqlClient.Tests
|
||||
|
@ -420,7 +419,7 @@ namespace Microsoft.Data.SqlClient.Tests
|
|||
Assert.Same(item3, list[2]);
|
||||
|
||||
list.Clear();
|
||||
Assert.Equal(0, list.Count);
|
||||
Assert.Empty(list);
|
||||
|
||||
list.Add(item1);
|
||||
list.Add(item3);
|
||||
|
@ -435,7 +434,7 @@ namespace Microsoft.Data.SqlClient.Tests
|
|||
Assert.Same(item3, list[2]);
|
||||
|
||||
list.Clear();
|
||||
Assert.Equal(0, list.Count);
|
||||
Assert.Empty(list);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -463,11 +462,11 @@ namespace Microsoft.Data.SqlClient.Tests
|
|||
IList list = CreateCollection(item1, item2);
|
||||
|
||||
list.Remove(item1);
|
||||
Assert.Equal(1, list.Count);
|
||||
Assert.Single(list);
|
||||
Assert.Same(item2, list[0]);
|
||||
|
||||
list.Remove(item2);
|
||||
Assert.Equal(0, list.Count);
|
||||
Assert.Empty(list);
|
||||
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => list.Remove(item2));
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => list.Remove(new SqlBulkCopyColumnMapping(2, 2)));
|
||||
|
@ -504,11 +503,11 @@ namespace Microsoft.Data.SqlClient.Tests
|
|||
Assert.Same(item3, list[1]);
|
||||
|
||||
list.RemoveAt(1);
|
||||
Assert.Equal(1, list.Count);
|
||||
Assert.Single(list);
|
||||
Assert.Same(item2, list[0]);
|
||||
|
||||
list.RemoveAt(0);
|
||||
Assert.Equal(0, list.Count);
|
||||
Assert.Empty(list);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
@ -395,7 +395,7 @@ namespace Microsoft.Data.SqlClient.Tests
|
|||
Assert.Same(item3, list[2]);
|
||||
|
||||
list.Clear();
|
||||
Assert.Equal(0, list.Count);
|
||||
Assert.Empty(list);
|
||||
|
||||
list.Add(item1);
|
||||
list.Add(item3);
|
||||
|
@ -410,7 +410,7 @@ namespace Microsoft.Data.SqlClient.Tests
|
|||
Assert.Same(item3, list[2]);
|
||||
|
||||
list.Clear();
|
||||
Assert.Equal(0, list.Count);
|
||||
Assert.Empty(list);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -434,11 +434,11 @@ namespace Microsoft.Data.SqlClient.Tests
|
|||
IList list = CreateCollection(item1, item2);
|
||||
|
||||
list.Remove(item1);
|
||||
Assert.Equal(1, list.Count);
|
||||
Assert.Single(list);
|
||||
Assert.Same(item2, list[0]);
|
||||
|
||||
list.Remove(item2);
|
||||
Assert.Equal(0, list.Count);
|
||||
Assert.Empty(list);
|
||||
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => list.Remove(item2));
|
||||
AssertExtensions.Throws<ArgumentException>(null, () => list.Remove(new SqlBulkCopyColumnOrderHint("column4", SortOrder.Ascending)));
|
||||
|
@ -473,11 +473,11 @@ namespace Microsoft.Data.SqlClient.Tests
|
|||
Assert.Same(item2, list[0]);
|
||||
Assert.Same(item3, list[1]);
|
||||
list.RemoveAt(1);
|
||||
Assert.Equal(1, list.Count);
|
||||
Assert.Single(list);
|
||||
Assert.Same(item2, list[0]);
|
||||
|
||||
list.RemoveAt(0);
|
||||
Assert.Equal(0, list.Count);
|
||||
Assert.Empty(list);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
@ -8,6 +8,7 @@ using System.Data.Common;
|
|||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -26,8 +27,7 @@ namespace Microsoft.Data.SqlClient.Tests
|
|||
connection.Open();
|
||||
}
|
||||
|
||||
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotArmProcess))]
|
||||
[ActiveIssue(4830, TestPlatforms.AnyUnix)]
|
||||
[ConditionalFact(typeof(TestUtility), nameof(TestUtility.IsNotArmProcess))]
|
||||
[PlatformSpecific(TestPlatforms.Windows)]
|
||||
public void IntegratedAuthConnectionTest()
|
||||
{
|
||||
|
@ -38,7 +38,7 @@ namespace Microsoft.Data.SqlClient.Tests
|
|||
connection.Open();
|
||||
}
|
||||
|
||||
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotArmProcess))]
|
||||
[ConditionalTheory(typeof(TestUtility), nameof(TestUtility.IsNotArmProcess))]
|
||||
[InlineData(40613)]
|
||||
[InlineData(42108)]
|
||||
[InlineData(42109)]
|
||||
|
@ -58,7 +58,7 @@ namespace Microsoft.Data.SqlClient.Tests
|
|||
Assert.Equal(ConnectionState.Open, connection.State);
|
||||
}
|
||||
|
||||
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotArmProcess))]
|
||||
[ConditionalTheory(typeof(TestUtility), nameof(TestUtility.IsNotArmProcess))]
|
||||
[InlineData(40613)]
|
||||
[InlineData(42108)]
|
||||
[InlineData(42109)]
|
||||
|
@ -81,11 +81,11 @@ namespace Microsoft.Data.SqlClient.Tests
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Assert.False(true, e.Message);
|
||||
Assert.Fail(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotArmProcess))]
|
||||
[ConditionalTheory(typeof(TestUtility), nameof(TestUtility.IsNotArmProcess))]
|
||||
[InlineData(40613)]
|
||||
[InlineData(42108)]
|
||||
[InlineData(42109)]
|
||||
|
@ -107,7 +107,7 @@ namespace Microsoft.Data.SqlClient.Tests
|
|||
Assert.Equal(ConnectionState.Closed, connection.State);
|
||||
}
|
||||
|
||||
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotArmProcess))]
|
||||
[ConditionalTheory(typeof(TestUtility), nameof(TestUtility.IsNotArmProcess))]
|
||||
[InlineData(40613)]
|
||||
[InlineData(42108)]
|
||||
[InlineData(42109)]
|
||||
|
@ -316,7 +316,7 @@ namespace Microsoft.Data.SqlClient.Tests
|
|||
try
|
||||
{
|
||||
//an asyn call with a timeout token to cancel the operation after the specific time
|
||||
using CancellationTokenSource cts = new CancellationTokenSource(timeout * 1000);
|
||||
using CancellationTokenSource cts = new CancellationTokenSource(timeout * 1000);
|
||||
timer.Start();
|
||||
await connection.OpenAsync(cts.Token).ConfigureAwait(false);
|
||||
}
|
||||
|
|
|
@ -181,13 +181,13 @@ namespace Microsoft.Data.SqlClient.Tests
|
|||
d.Clear();
|
||||
|
||||
Assert.Empty(d);
|
||||
Assert.Equal(0, d.Count);
|
||||
Assert.Empty(d);
|
||||
|
||||
Assert.Empty(d.Keys);
|
||||
Assert.Equal(0, d.Keys.Count);
|
||||
Assert.Empty(d.Keys);
|
||||
|
||||
Assert.Empty(d.Values);
|
||||
Assert.Equal(0, d.Values.Count);
|
||||
Assert.Empty(d.Values);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
@ -70,7 +70,7 @@ namespace Microsoft.Data.SqlClient.Tests
|
|||
|
||||
char[] expectedValue = new char[] { 'a', 'b', 'e', 'f', 'g' };
|
||||
Assert.Equal(expectedValue.Length, record.GetChars(3, 0, cb2, 0, 5));
|
||||
Assert.Equal<char>(expectedValue, new string(cb2, 0, (int)record.GetChars(3, 0, null, 0, 0)));
|
||||
Assert.Equal<char>(expectedValue, new string(cb2, 0, (int)record.GetChars(3, 0, null, 0, 0)).ToCharArray());
|
||||
|
||||
record.SetString(3, "");
|
||||
string xyz = "xyz";
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace Microsoft.Data.SqlClient.Tests
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Assert.False(true, $"Unexpected Exception occurred: {ex.Message}");
|
||||
Assert.Fail($"Unexpected Exception occurred: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace Microsoft.Data.SqlClient.Tests
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Assert.False(true, $"Unexpected Exception occurred: {ex.Message}");
|
||||
Assert.Fail($"Unexpected Exception occurred: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace Microsoft.Data.SqlClient.Tests
|
|||
if (unobservedExceptionHappend) //Save doing string interpolation in the happy case
|
||||
{
|
||||
var e = UnwrapException(unhandledException);
|
||||
Assert.False(true, $"Did not expect an unobserved exception, but found a {e?.GetType()} with message \"{e?.Message}\"");
|
||||
Assert.Fail($"Did not expect an unobserved exception, but found a {e?.GetType()} with message \"{e?.Message}\"");
|
||||
}
|
||||
}
|
||||
finally
|
||||
|
|
|
@ -59,7 +59,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests.AlwaysEncrypted
|
|||
}
|
||||
break;
|
||||
default:
|
||||
Assert.False(true, "Unexpected event occurred: " + item.Message);
|
||||
Assert.Fail("Unexpected event occurred: " + item.Message);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -2918,7 +2918,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests.AlwaysEncrypted
|
|||
catch (Exception e)
|
||||
{
|
||||
testAsyncCallBackStateObject.Completion.SetException(e);
|
||||
Assert.True(false, $"{e.Message}");
|
||||
Assert.Fail($"{e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -524,7 +524,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests.AlwaysEncrypted
|
|||
list.Add(new ValueErrorTuple(Single.Epsilon, false));
|
||||
break;
|
||||
default:
|
||||
Assert.True(false, "We should never get here");
|
||||
Assert.Fail("We should never get here");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -562,7 +562,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests.AlwaysEncrypted
|
|||
try
|
||||
{
|
||||
sqlCmd.ExecuteNonQuery();
|
||||
Assert.True(false, "We should have gotten an error but passed instead.");
|
||||
Assert.Fail("We should have gotten an error but passed instead.");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
|
@ -106,7 +106,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests.AlwaysEncrypted
|
|||
break;
|
||||
|
||||
default:
|
||||
Assert.True(false, "FAILED: No other data type is supported.");
|
||||
Assert.Fail("FAILED: No other data type is supported.");
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -157,7 +157,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests.AlwaysEncrypted
|
|||
break;
|
||||
|
||||
default:
|
||||
Assert.True(false, "FAILED: unexpected data type.");
|
||||
Assert.Fail("FAILED: unexpected data type.");
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ using Xunit;
|
|||
using System.Net.NetworkInformation;
|
||||
using System.Text;
|
||||
using System.Security.Principal;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
||||
{
|
||||
|
@ -77,6 +78,10 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
public const string AKVEventSourceName = "Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider.EventSource";
|
||||
private const string ManagedNetworkingAppContextSwitch = "Switch.Microsoft.Data.SqlClient.UseManagedNetworkingOnWindows";
|
||||
|
||||
// uap constant
|
||||
const long APPMODEL_ERROR_NO_PACKAGE = 15700L;
|
||||
public static readonly bool IsRunningAsUWPApp = RunningAsUWPApp();
|
||||
|
||||
private static Dictionary<string, bool> AvailableDatabases;
|
||||
private static BaseEventListener TraceListener;
|
||||
|
||||
|
@ -302,6 +307,8 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
return isTDS8Supported;
|
||||
}
|
||||
|
||||
public static bool IsNotX86Architecture => RuntimeInformation.ProcessArchitecture != Architecture.X86;
|
||||
|
||||
public static bool IsDatabasePresent(string name)
|
||||
{
|
||||
AvailableDatabases = AvailableDatabases ?? new Dictionary<string, bool>();
|
||||
|
@ -734,7 +741,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
try
|
||||
{
|
||||
actionThatFails();
|
||||
Assert.False(true, "ERROR: Did not get expected exception");
|
||||
Assert.Fail("ERROR: Did not get expected exception");
|
||||
return null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -755,7 +762,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
try
|
||||
{
|
||||
actionThatFails();
|
||||
Assert.False(true, "ERROR: Did not get expected exception");
|
||||
Assert.Fail("ERROR: Did not get expected exception");
|
||||
return null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -776,7 +783,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
try
|
||||
{
|
||||
actionThatFails();
|
||||
Assert.False(true, "ERROR: Did not get expected exception");
|
||||
Assert.Fail("ERROR: Did not get expected exception");
|
||||
return null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -1065,5 +1072,29 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
}
|
||||
return fqdn.ToString();
|
||||
}
|
||||
|
||||
private static bool RunningAsUWPApp()
|
||||
{
|
||||
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
|
||||
static extern int GetCurrentPackageFullName(ref int packageFullNameLength, StringBuilder packageFullName);
|
||||
|
||||
{
|
||||
int length = 0;
|
||||
StringBuilder sb = new(0);
|
||||
_ = GetCurrentPackageFullName(ref length, sb);
|
||||
|
||||
sb = new StringBuilder(length);
|
||||
int result = GetCurrentPackageFullName(ref length, sb);
|
||||
|
||||
return result != APPMODEL_ERROR_NO_PACKAGE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -292,19 +292,47 @@
|
|||
<ProjectReference Include="SQL\UdtTest\UDTs\Utf8String\Utf8String.csproj">
|
||||
<Name>Utf8String</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="$(TestsPath)tools\Microsoft.DotNet.XUnitExtensions\Microsoft.DotNet.XUnitExtensions.csproj">
|
||||
<Name>Microsoft.DotNet.XUnitExtensions</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="$(TestsPath)tools\TDS\TDS.EndPoint\TDS.EndPoint.csproj" />
|
||||
<ProjectReference Include="$(TestsPath)tools\TDS\TDS.Servers\TDS.Servers.csproj" />
|
||||
<ProjectReference Include="$(TestsPath)tools\TDS\TDS\TDS.csproj" />
|
||||
<ProjectReference Include="$(TestsPath)tools\Microsoft.Data.SqlClient.TestUtilities\Microsoft.Data.SqlClient.TestUtilities.csproj" />
|
||||
<ProjectReference Condition="'$(TargetGroup)'=='netcoreapp' AND $(ReferenceType)=='Project'" Include="$(NetCoreSource)src\Microsoft.Data.SqlClient.csproj" />
|
||||
<ProjectReference Condition="'$(TargetGroup)'=='netfx' AND $(ReferenceType)=='Project'" Include="$(NetFxSource)src\Microsoft.Data.SqlClient.csproj" />
|
||||
<ProjectReference Condition="$(ReferenceType.Contains('NetStandard'))" Include="$(TestsPath)NSLibrary\Microsoft.Data.SqlClient.NSLibrary.csproj" />
|
||||
<ProjectReference Condition="!$(ReferenceType.Contains('Package'))" Include="$(SqlServerSource)Microsoft.SqlServer.Server.csproj" />
|
||||
<PackageReference Condition="$(ReferenceType.Contains('Package'))" Include="Microsoft.Data.SqlClient" Version="$(TestMicrosoftDataSqlClientVersion)" />
|
||||
<ProjectReference Include="$(TestsPath)CustomConfigurableRetryLogic\CustomRetryLogicProvider.csproj" />
|
||||
<ProjectReference
|
||||
Include="$(TestsPath)tools\Microsoft.Data.SqlClient.TestUtilities\Microsoft.Data.SqlClient.TestUtilities.csproj" />
|
||||
<ProjectReference Condition="'$(TargetGroup)'=='netcoreapp' AND $(ReferenceType)=='Project'"
|
||||
Include="$(NetCoreSource)src\Microsoft.Data.SqlClient.csproj" />
|
||||
<ProjectReference Condition="'$(TargetGroup)'=='netfx' AND $(ReferenceType)=='Project'"
|
||||
Include="$(NetFxSource)src\Microsoft.Data.SqlClient.csproj" />
|
||||
<ProjectReference Condition="$(ReferenceType.Contains('NetStandard'))"
|
||||
Include="$(TestsPath)NSLibrary\Microsoft.Data.SqlClient.NSLibrary.csproj" />
|
||||
<ProjectReference Condition="!$(ReferenceType.Contains('Package'))"
|
||||
Include="$(SqlServerSource)Microsoft.SqlServer.Server.csproj" />
|
||||
<PackageReference Condition="$(ReferenceType.Contains('Package'))"
|
||||
Include="Microsoft.Data.SqlClient" Version="$(TestMicrosoftDataSqlClientVersion)" />
|
||||
<ProjectReference
|
||||
Include="$(TestsPath)CustomConfigurableRetryLogic\CustomRetryLogicProvider.csproj" />
|
||||
</ItemGroup>
|
||||
<!-- XUnit and XUnit extensions -->
|
||||
<ItemGroup>
|
||||
<PackageReference Condition="$(TargetGroup) == 'netfx'"
|
||||
Include="System.Runtime.InteropServices.RuntimeInformation"
|
||||
Version="$(SystemRuntimeInteropServicesRuntimeInformationVersion)" />
|
||||
<PackageReference Include="xunit" Version="$(XunitVersion)" />
|
||||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies"
|
||||
Version="$(MicrosoftNETFrameworkReferenceAssembliesVersion)"
|
||||
Condition="'$(TargetGroup)' == 'netfx'">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitVersion)">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="xunit.runner.console" Version="$(XunitVersion)">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="xunit.runner.utility" Version="$(XunitVersion)" />
|
||||
<PackageReference Include="Microsoft.DotNet.XUnitExtensions"
|
||||
Version="$(MicrosoftDotNetXUnitExtensionsVersion)" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" />
|
||||
|
@ -331,5 +359,9 @@
|
|||
<None Update="SQL\ConnectionTestWithSSLCert\GenerateSelfSignedCertificate.ps1">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<ContentWithTargetPath Include="..\tools\Microsoft.Data.SqlClient.TestUtilities\xunit.runner.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<TargetPath>xunit.runner.json</TargetPath>
|
||||
</ContentWithTargetPath>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
{
|
||||
public static class AsyncTest
|
||||
{
|
||||
[ActiveIssue(5533)] // Async Operations slower than Sync operations
|
||||
[ActiveIssue("5533")] // Async Operations slower than Sync operations
|
||||
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))]
|
||||
public static void TestReadAsyncTimeConsumed()
|
||||
{
|
||||
|
|
|
@ -174,7 +174,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Assert.False(true, "Exception occurred: " + ex.Message);
|
||||
Assert.Fail("Exception occurred: " + ex.Message);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -89,7 +89,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Assert.False(true, "Exception occurred: " + ex.Message);
|
||||
Assert.Fail("Exception occurred: " + ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
}
|
||||
}
|
||||
|
||||
[ActiveIssue(26934)]
|
||||
[ActiveIssue("26934")]
|
||||
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.UseManagedSNIOnWindows), nameof(DataTestUtility.IsNotAzureServer))]
|
||||
[PlatformSpecific(TestPlatforms.Windows)]
|
||||
public void RemoteCertificateNameMismatchErrorTest()
|
||||
|
|
|
@ -647,7 +647,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
|
||||
// Test passes locally everytime, but in pieplines fails randomly with uncertainity.
|
||||
// e.g. Second AAD connection too slow (802ms)! (More than 30% of the first (576ms).)
|
||||
[ActiveIssue(16058)]
|
||||
[ActiveIssue("16058")]
|
||||
[ConditionalFact(nameof(IsAADConnStringsSetup))]
|
||||
public static void ConnectionSpeed()
|
||||
{
|
||||
|
|
|
@ -83,7 +83,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
// Confirm Server Process Id stays the same after query execution
|
||||
Assert.Equal(sessionSpid, sqlConnection.ServerProcessId);
|
||||
}
|
||||
Assert.True(false, "No non-empty hostname found for the application");
|
||||
Assert.Fail("No non-empty hostname found for the application");
|
||||
}
|
||||
|
||||
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))]
|
||||
|
|
|
@ -161,7 +161,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
}
|
||||
catch (SqlException e)
|
||||
{
|
||||
Assert.True(false, $"Unexpected Exception occurred: {e.Message}");
|
||||
Assert.Fail($"Unexpected Exception occurred: {e.Message}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
}
|
||||
}
|
||||
|
||||
[ActiveIssue(5540)]
|
||||
[ActiveIssue("5540")]
|
||||
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))]
|
||||
public static void RunAllTestsForSingleServer_TCP()
|
||||
{
|
||||
|
@ -106,17 +106,17 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
int sharedLength = Math.Min(inputData.Length, outputData.Length);
|
||||
if (sharedLength < outputData.Length)
|
||||
{
|
||||
Assert.False(true, $"output is longer than input, input={inputData.Length} bytes, output={outputData.Length} bytes");
|
||||
Assert.Fail($"output is longer than input, input={inputData.Length} bytes, output={outputData.Length} bytes");
|
||||
}
|
||||
if (sharedLength < inputData.Length)
|
||||
{
|
||||
Assert.False(true, $"input is longer than output, input={inputData.Length} bytes, output={outputData.Length} bytes");
|
||||
Assert.Fail($"input is longer than output, input={inputData.Length} bytes, output={outputData.Length} bytes");
|
||||
}
|
||||
for (int index = 0; index < sharedLength; index++)
|
||||
{
|
||||
if (inputData[index] != outputData[index]) // avoid formatting the output string unless there is a difference
|
||||
{
|
||||
Assert.True(false, $"input and output differ at index {index}, input={inputData[index]}, output={outputData[index]}");
|
||||
Assert.Fail($"input and output differ at index {index}, input={inputData[index]}, output={outputData[index]}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -176,8 +176,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
OpenBadConnection(builder.ConnectionString, invalidConnStringError);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[SkipOnTargetFramework(~TargetFrameworkMonikers.Uap)]
|
||||
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.IsRunningAsUWPApp))]
|
||||
public static void LocalDBNotSupportedOnUapTest()
|
||||
{
|
||||
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(@$"server=(localdb)\{DataTestUtility.LocalDbAppName}")
|
||||
|
@ -195,6 +194,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
private void GenerateConnectionException(string connectionString)
|
||||
{
|
||||
using (SqlConnection sqlConnection = new SqlConnection(connectionString))
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
TryOpenConnectionWithIntegratedAuthentication(builder.ConnectionString);
|
||||
}
|
||||
|
||||
[ActiveIssue(21707)]
|
||||
[ActiveIssue("21707")]
|
||||
[ConditionalFact(nameof(IsIntegratedSecurityEnvironmentSet), nameof(AreConnectionStringsSetup))]
|
||||
public static void IntegratedAuthenticationTest_InvalidServerSPN()
|
||||
{
|
||||
|
|
|
@ -26,15 +26,15 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
private static readonly string s_startLocalDbCommand = @$"/c SqlLocalDb start {DataTestUtility.LocalDbAppName}";
|
||||
private static readonly string s_localDbNamedPipeConnectionString = @$"server={GetLocalDbNamedPipe()}";
|
||||
|
||||
|
||||
#region LocalDbTests
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.Uap)] // No Registry support on UAP
|
||||
|
||||
[ConditionalFact(nameof(IsLocalDBEnvironmentSet))]
|
||||
public static void SqlLocalDbConnectionTest()
|
||||
{
|
||||
ConnectionTest(s_localDbConnectionString);
|
||||
}
|
||||
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.Uap)] // No Registry support on UAP
|
||||
[ConditionalFact(nameof(IsLocalDBEnvironmentSet))]
|
||||
public static void LocalDBEncryptionNotSupportedTest()
|
||||
{
|
||||
|
@ -43,7 +43,6 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
ConnectionWithEncryptionTest(s_localDbConnectionString);
|
||||
}
|
||||
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.Uap)] // No Registry support on UAP
|
||||
[ConditionalFact(nameof(IsLocalDBEnvironmentSet))]
|
||||
public static void LocalDBMarsTest()
|
||||
{
|
||||
|
@ -51,17 +50,15 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
ConnectionWithMarsTest(s_localDbConnectionString);
|
||||
}
|
||||
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.Uap)] // No Registry support on UAP
|
||||
[ConditionalFact(nameof(IsLocalDBEnvironmentSet))]
|
||||
public static void InvalidLocalDBTest()
|
||||
{
|
||||
using var connection = new SqlConnection(s_badConnectionString);
|
||||
DataTestUtility.AssertThrowsWrapper<SqlException>(() => connection.Open());
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region SharedLocalDb tests
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.Uap)] // No Registry support on UAP
|
||||
[ConditionalFact(nameof(IsLocalDbSharedInstanceSet))]
|
||||
public static void SharedLocalDbEncryptionTest()
|
||||
{
|
||||
|
@ -73,7 +70,6 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
}
|
||||
}
|
||||
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.Uap)] // No Registry support on UAP
|
||||
[ConditionalFact(nameof(IsLocalDbSharedInstanceSet))]
|
||||
public static void SharedLocalDbMarsTest()
|
||||
{
|
||||
|
@ -83,7 +79,6 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
}
|
||||
}
|
||||
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.Uap)] // No Registry support on UAP
|
||||
[ConditionalFact(nameof(IsLocalDbSharedInstanceSet))]
|
||||
public static void SqlLocalDbSharedInstanceConnectionTest()
|
||||
{
|
||||
|
@ -94,19 +89,18 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region NamedPipeTests
|
||||
|
||||
[Fact]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.Uap)] // No Registry support on UAP
|
||||
[ActiveIssue(20245)] //pending pipeline configuration
|
||||
[ActiveIssue("20245")] //pending pipeline configuration
|
||||
public static void SqlLocalDbNamedPipeConnectionTest()
|
||||
{
|
||||
ConnectionTest(s_localDbNamedPipeConnectionString);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.Uap)] // No Registry support on UAP
|
||||
[ActiveIssue(20245)] //pending pipeline configuration
|
||||
[ActiveIssue("20245")] //pending pipeline configuration
|
||||
public static void LocalDBNamedPipeEncryptionNotSupportedTest()
|
||||
{
|
||||
// Encryption is not supported by SQL Local DB.
|
||||
|
@ -115,8 +109,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
}
|
||||
|
||||
[Fact]
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.Uap)] // No Registry support on UAP
|
||||
[ActiveIssue(20245)] //pending pipeline configuration
|
||||
[ActiveIssue("20245")] //pending pipeline configuration
|
||||
public static void LocalDBNamepipeMarsTest()
|
||||
{
|
||||
ConnectionWithMarsTest(s_localDbNamedPipeConnectionString);
|
||||
|
@ -126,7 +119,6 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
|
||||
#region Failures
|
||||
// ToDo: After adding shared memory support on managed SNI, the IsNativeSNI could be taken out
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.Uap)] // No Registry support on UAP
|
||||
[ConditionalTheory(nameof(IsLocalDBEnvironmentSet), nameof(IsNativeSNI))]
|
||||
[InlineData("lpc:")]
|
||||
public static void SharedMemoryAndSqlLocalDbConnectionTest(string prefix)
|
||||
|
@ -137,7 +129,6 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
Assert.Contains("A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 41 - Cannot open a Shared Memory connection to a remote SQL server)", ex.Message);
|
||||
}
|
||||
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.Uap)] // No Registry support on UAP
|
||||
[InlineData("tcp:")]
|
||||
[InlineData("np:")]
|
||||
[InlineData("undefinded:")]
|
||||
|
@ -150,7 +141,6 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
Assert.Contains("A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)", ex.Message);
|
||||
}
|
||||
|
||||
[SkipOnTargetFramework(TargetFrameworkMonikers.Uap)] // No Registry support on UAP
|
||||
[ConditionalFact(nameof(IsLocalDBEnvironmentSet)/*, nameof(IsNativeSNI)*/)]
|
||||
public static void InvalidSqlLocalDbConnectionTest()
|
||||
{
|
||||
|
|
|
@ -67,7 +67,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
}
|
||||
|
||||
// Synapse: Catalog view 'dm_exec_connections' is not supported in this version.
|
||||
[ActiveIssue(11167)]
|
||||
[ActiveIssue("11167")]
|
||||
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))]
|
||||
public static void MarsExecuteReader_Text_WithGC()
|
||||
{
|
||||
|
@ -76,7 +76,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
}
|
||||
|
||||
// Synapse: Stored procedure sp_who does not exist or is not supported.
|
||||
[ActiveIssue(8959)]
|
||||
[ActiveIssue("8959")]
|
||||
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))]
|
||||
public static void MarsExecuteReader_StoredProcedure_WithGC()
|
||||
{
|
||||
|
|
|
@ -688,7 +688,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Assert.False(true, "CRITIAL: Test should not fail randomly. Exception occurred: " + e.Message);
|
||||
Assert.Fail("CRITIAL: Test should not fail randomly. Exception occurred: " + e.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
@ -761,7 +761,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Assert.False(true, $"Unexpected exception occurred: {e.Message}");
|
||||
Assert.Fail($"Unexpected exception occurred: {e.Message}");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -804,7 +804,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
return;
|
||||
else if ((Guid)cm.Parameters["@id2"].Value != expectedGuid)
|
||||
{
|
||||
Assert.False(true, "CRITICAL : Unexpected data found in SqlCommand parameters, this is a MAJOR issue.");
|
||||
Assert.Fail("CRITICAL : Unexpected data found in SqlCommand parameters, this is a MAJOR issue.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
}
|
||||
|
||||
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureServer))]
|
||||
[ActiveIssue(5531)]
|
||||
[ActiveIssue("5531")]
|
||||
public void TestPacketNumberWraparound()
|
||||
{
|
||||
// this test uses a specifically crafted sql record enumerator and data to put the TdsParserStateObject.WritePacket(byte,bool)
|
||||
|
@ -120,7 +120,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
cmd.CommandTimeout = 100;
|
||||
AddCommandParameters(cmd, parameters);
|
||||
new SqlDataAdapter(cmd).Fill(new("BadFunc"));
|
||||
Assert.False(true, "Expected exception did not occur");
|
||||
Assert.Fail("Expected exception did not occur");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -140,7 +140,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Assert.False(true, $"Unexpected error occurred: {e.Message}");
|
||||
Assert.Fail($"Unexpected error occurred: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
default:
|
||||
break;
|
||||
}
|
||||
Assert.False(true, "Exception did not occur.");
|
||||
Assert.Fail("Exception did not occur.");
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -103,7 +103,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
default:
|
||||
break;
|
||||
}
|
||||
Assert.False(true, "Exception did not occur.");
|
||||
Assert.Fail("Exception did not occur.");
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
|
@ -107,7 +107,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
}
|
||||
}
|
||||
|
||||
[ActiveIssue(14588)]
|
||||
[ActiveIssue("14588")]
|
||||
[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.IsNotAzureSynapse), nameof(DataTestUtility.AreConnStringsSetup))]
|
||||
[MemberData(nameof(RetryLogicTestHelper.GetConnectionAndRetryStrategyInvalidCommand), parameters: new object[] { 5 }, MemberType = typeof(RetryLogicTestHelper), DisableDiscoveryEnumeration = true)]
|
||||
public void RetryExecuteWithTransScope(string cnnString, SqlRetryLogicBaseProvider provider)
|
||||
|
@ -233,7 +233,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
}
|
||||
}
|
||||
|
||||
[ActiveIssue(14325)]
|
||||
[ActiveIssue("14325")]
|
||||
// avoid creating a new database in Azure
|
||||
[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.IsNotAzureServer), nameof(DataTestUtility.IsNotAzureSynapse), nameof(DataTestUtility.AreConnStringsSetup))]
|
||||
[MemberData(nameof(RetryLogicTestHelper.GetConnectionAndRetryStrategyDropDB), parameters: new object[] { 5 }, MemberType = typeof(RetryLogicTestHelper), DisableDiscoveryEnumeration = true)]
|
||||
|
|
|
@ -49,7 +49,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
}
|
||||
}
|
||||
|
||||
[ActiveIssue(14590, TestPlatforms.Windows)]
|
||||
[ActiveIssue("14590", TestPlatforms.Windows)]
|
||||
// avoid creating a new database in Azure
|
||||
[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.IsNotAzureServer), nameof(DataTestUtility.IsNotAzureSynapse), nameof(DataTestUtility.AreConnStringsSetup))]
|
||||
[MemberData(nameof(RetryLogicTestHelper.GetConnectionAndRetryStrategyLongRunner), parameters: new object[] { 10 }, MemberType = typeof(RetryLogicTestHelper), DisableDiscoveryEnumeration = true)]
|
||||
|
@ -98,7 +98,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
Assert.True(currentRetries > 0);
|
||||
}
|
||||
|
||||
[ActiveIssue(25147)]
|
||||
[ActiveIssue("25147")]
|
||||
[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))]
|
||||
[MemberData(nameof(RetryLogicTestHelper.GetConnectionAndRetryStrategyInvalidCatalog), parameters: new object[] { 2 }, MemberType = typeof(RetryLogicTestHelper), DisableDiscoveryEnumeration = true)]
|
||||
public void ConcurrentExecution(string cnnString, SqlRetryLogicBaseProvider provider)
|
||||
|
|
|
@ -11,7 +11,7 @@ using Xunit;
|
|||
|
||||
namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
||||
{
|
||||
[ActiveIssue(5538)] // Only testable on localhost
|
||||
[ActiveIssue("5538")] // Only testable on localhost
|
||||
public class SplitPacketTest
|
||||
{
|
||||
private int Port = -1;
|
||||
|
|
|
@ -297,7 +297,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
}
|
||||
|
||||
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))]
|
||||
[ActiveIssue(12219)]
|
||||
[ActiveIssue("12219")]
|
||||
public void OrderHintIdentityColumnTest()
|
||||
{
|
||||
OrderHintIdentityColumn.Test(_connStr, AddGuid("SqlBulkCopyTest_OrderHintIdentityColumn"));
|
||||
|
|
|
@ -157,7 +157,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
TimeoutCancel(tcp_connStr);
|
||||
}
|
||||
|
||||
[ActiveIssue(12167)]
|
||||
[ActiveIssue("12167")]
|
||||
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureServer))]
|
||||
[PlatformSpecific(TestPlatforms.Windows)]
|
||||
public static void TimeoutCancelNP()
|
||||
|
@ -178,14 +178,14 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
CancelAndDisposePreparedCommand(np_connStr);
|
||||
}
|
||||
|
||||
[ActiveIssue(5541)]
|
||||
[ActiveIssue("5541")]
|
||||
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))]
|
||||
public static void TimeOutDuringRead()
|
||||
{
|
||||
TimeOutDuringRead(tcp_connStr);
|
||||
}
|
||||
|
||||
[ActiveIssue(5541)]
|
||||
[ActiveIssue("5541")]
|
||||
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureServer))]
|
||||
[PlatformSpecific(TestPlatforms.Windows)]
|
||||
public static void TimeOutDuringReadNP()
|
||||
|
@ -306,7 +306,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
{
|
||||
if (retryAttempt >= 3 || e.Message.Contains("The transaction operation cannot be performed"))
|
||||
{
|
||||
Assert.False(true, $"Retry Attempt: {retryAttempt} | Unexpected Exception occurred: {e.Message}");
|
||||
Assert.Fail($"Retry Attempt: {retryAttempt} | Unexpected Exception occurred: {e.Message}");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -122,7 +122,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Assert.True(false, e.Message);
|
||||
Assert.Fail(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -152,7 +152,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Assert.True(false, e.Message);
|
||||
Assert.Fail(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -226,7 +226,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
/// <summary>
|
||||
/// SqlDependecy premature timeout
|
||||
/// </summary>
|
||||
[ActiveIssue(5539)]
|
||||
[ActiveIssue("5539")]
|
||||
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))]
|
||||
public void Test_SingleDependency_Timeout()
|
||||
{
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using System.Transactions;
|
||||
using Xunit;
|
||||
|
@ -14,7 +15,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
[PlatformSpecific(TestPlatforms.Windows)]
|
||||
public class DistributedTransactionTest
|
||||
{
|
||||
private static bool s_DelegatedTransactionCondition => DataTestUtility.AreConnStringsSetup() && DataTestUtility.IsNotAzureServer() && PlatformDetection.IsNotX86Process;
|
||||
private static bool s_DelegatedTransactionCondition => DataTestUtility.AreConnStringsSetup() && DataTestUtility.IsNotAzureServer() && DataTestUtility.IsNotX86Architecture;
|
||||
|
||||
[ConditionalFact(nameof(s_DelegatedTransactionCondition), Timeout = 10000)]
|
||||
public async Task Delegated_transaction_deadlock_in_SinglePhaseCommit()
|
||||
|
|
|
@ -252,7 +252,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
}
|
||||
|
||||
// Synapse: Parse error at line: 1, column: 41: Incorrect syntax near 'hierarchyid'.
|
||||
[ActiveIssue(25421, TargetFrameworkMonikers.NetFramework)]
|
||||
[ActiveIssue("25421", TargetFrameworkMonikers.NetFramework)]
|
||||
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))]
|
||||
public static void TestUdtSchemaMetadata()
|
||||
{
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
{
|
||||
private string _connStr;
|
||||
|
||||
[ActiveIssue(5535)]
|
||||
[ActiveIssue("5535")]
|
||||
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.IsUdtTestDatabasePresent), nameof(DataTestUtility.AreConnStringsSetup))]
|
||||
public void RunCopyTest()
|
||||
{
|
||||
|
|
|
@ -11,7 +11,7 @@ using Microsoft.SqlServer.Server;
|
|||
|
||||
namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
||||
{
|
||||
[ActiveIssue(5536)]
|
||||
[ActiveIssue("5536")]
|
||||
// TODO Synapse: Remove dependency from UDTTest Database
|
||||
public class UdtTest2
|
||||
{
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
|
|||
private const int CONCURRENT_COMMANDS = 5;
|
||||
|
||||
// TODO Synapse: Remove dependency on Northwind database
|
||||
[ActiveIssue(6643, TestPlatforms.AnyUnix)]
|
||||
[ActiveIssue("6643", TestPlatforms.AnyUnix)]
|
||||
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))]
|
||||
public static void TestReaderMars()
|
||||
{
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
|
||||
"diagnosticMessages": true,
|
||||
"parallelizeAssembly": true,
|
||||
"shadowCopy": false
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using Xunit.Sdk;
|
||||
|
||||
namespace Xunit
|
||||
{
|
||||
/// <summary>
|
||||
/// Apply this attribute to your test method to specify an active issue.
|
||||
/// </summary>
|
||||
[TraitDiscoverer("Microsoft.DotNet.XUnitExtensions.ActiveIssueDiscoverer", "Microsoft.DotNet.XUnitExtensions")]
|
||||
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true)]
|
||||
public class ActiveIssueAttribute : Attribute, ITraitAttribute
|
||||
{
|
||||
public ActiveIssueAttribute(int issueNumber, TestPlatforms platforms) { }
|
||||
public ActiveIssueAttribute(string issue, TestPlatforms platforms) { }
|
||||
public ActiveIssueAttribute(int issueNumber, TargetFrameworkMonikers framework) { }
|
||||
public ActiveIssueAttribute(string issue, TargetFrameworkMonikers framework) { }
|
||||
public ActiveIssueAttribute(int issueNumber, TestPlatforms platforms = TestPlatforms.Any, TargetFrameworkMonikers framework = (TargetFrameworkMonikers)0) { }
|
||||
public ActiveIssueAttribute(string issue, TestPlatforms platforms = TestPlatforms.Any, TargetFrameworkMonikers framework = (TargetFrameworkMonikers)0) { }
|
||||
}
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using Xunit.Sdk;
|
||||
|
||||
namespace Xunit
|
||||
{
|
||||
[TraitDiscoverer("Microsoft.DotNet.XUnitExtensions.ConditionalClassDiscoverer", "Microsoft.DotNet.XUnitExtensions")]
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
|
||||
public sealed class ConditionalClassAttribute : Attribute, ITraitAttribute
|
||||
{
|
||||
public Type CalleeType { get; private set; }
|
||||
public string[] ConditionMemberNames { get; private set; }
|
||||
|
||||
public ConditionalClassAttribute(Type calleeType, params string[] conditionMemberNames)
|
||||
{
|
||||
CalleeType = calleeType;
|
||||
ConditionMemberNames = conditionMemberNames;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using Xunit.Sdk;
|
||||
|
||||
namespace Xunit
|
||||
{
|
||||
[XunitTestCaseDiscoverer("Microsoft.DotNet.XUnitExtensions.ConditionalFactDiscoverer", "Microsoft.DotNet.XUnitExtensions")]
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
|
||||
public sealed class ConditionalFactAttribute : FactAttribute
|
||||
{
|
||||
public Type CalleeType { get; private set; }
|
||||
public string[] ConditionMemberNames { get; private set; }
|
||||
|
||||
public ConditionalFactAttribute(Type calleeType, params string[] conditionMemberNames)
|
||||
{
|
||||
CalleeType = calleeType;
|
||||
ConditionMemberNames = conditionMemberNames;
|
||||
}
|
||||
|
||||
public ConditionalFactAttribute(params string[] conditionMemberNames)
|
||||
{
|
||||
ConditionMemberNames = conditionMemberNames;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using Xunit.Sdk;
|
||||
|
||||
namespace Xunit
|
||||
{
|
||||
[XunitTestCaseDiscoverer("Microsoft.DotNet.XUnitExtensions.ConditionalTheoryDiscoverer", "Microsoft.DotNet.XUnitExtensions")]
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
|
||||
public sealed class ConditionalTheoryAttribute : TheoryAttribute
|
||||
{
|
||||
public Type CalleeType { get; private set; }
|
||||
public string[] ConditionMemberNames { get; private set; }
|
||||
|
||||
public ConditionalTheoryAttribute(Type calleeType, params string[] conditionMemberNames)
|
||||
{
|
||||
CalleeType = calleeType;
|
||||
ConditionMemberNames = conditionMemberNames;
|
||||
}
|
||||
|
||||
public ConditionalTheoryAttribute(params string[] conditionMemberNames)
|
||||
{
|
||||
ConditionMemberNames = conditionMemberNames;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using Xunit.Sdk;
|
||||
|
||||
namespace Xunit
|
||||
{
|
||||
/// <summary>
|
||||
/// Apply this attribute to your test method to specify a outer-loop category.
|
||||
/// </summary>
|
||||
[TraitDiscoverer("Microsoft.DotNet.XUnitExtensions.OuterLoopTestsDiscoverer", "Microsoft.DotNet.XUnitExtensions")]
|
||||
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true)]
|
||||
public class OuterLoopAttribute : Attribute, ITraitAttribute
|
||||
{
|
||||
public OuterLoopAttribute() { }
|
||||
public OuterLoopAttribute(string reason) { }
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using Xunit.Sdk;
|
||||
|
||||
namespace Xunit
|
||||
{
|
||||
/// <summary>
|
||||
/// Apply this attribute to your test method to specify this is a platform specific test.
|
||||
/// </summary>
|
||||
[TraitDiscoverer("Microsoft.DotNet.XUnitExtensions.PlatformSpecificDiscoverer", "Microsoft.DotNet.XUnitExtensions")]
|
||||
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = false)]
|
||||
public class PlatformSpecificAttribute : Attribute, ITraitAttribute
|
||||
{
|
||||
public PlatformSpecificAttribute(TestPlatforms platforms) { }
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using Xunit.Sdk;
|
||||
|
||||
namespace Xunit
|
||||
{
|
||||
[TraitDiscoverer("Microsoft.DotNet.XUnitExtensions.SkipOnCoreClrDiscoverer", "Microsoft.DotNet.XUnitExtensions")]
|
||||
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
|
||||
public class SkipOnCoreClrAttribute : Attribute, ITraitAttribute
|
||||
{
|
||||
internal SkipOnCoreClrAttribute() { }
|
||||
|
||||
public SkipOnCoreClrAttribute(string reason, TestPlatforms testPlatforms) { }
|
||||
public SkipOnCoreClrAttribute(string reason, RuntimeStressTestModes testMode) { }
|
||||
public SkipOnCoreClrAttribute(string reason, TestPlatforms testPlatforms, RuntimeStressTestModes testMode) { }
|
||||
public SkipOnCoreClrAttribute(string reason) { }
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using Xunit;
|
||||
using Xunit.Sdk;
|
||||
|
||||
namespace Microsoft.DotNet.XUnitExtensions.Attributes
|
||||
{
|
||||
[TraitDiscoverer("Microsoft.DotNet.XUnitExtensions.SkipOnMonoDiscoverer", "Microsoft.DotNet.XUnitExtensions")]
|
||||
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
|
||||
public class SkipOnMonoAttribute : Attribute, ITraitAttribute
|
||||
{
|
||||
internal SkipOnMonoAttribute() { }
|
||||
public SkipOnMonoAttribute(string reason, TestPlatforms testPlatforms = TestPlatforms.Any) { }
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using Xunit.Sdk;
|
||||
|
||||
namespace Xunit
|
||||
{
|
||||
/// <summary>
|
||||
/// Apply this attribute to your test method to specify this is a platform specific test.
|
||||
/// </summary>
|
||||
[TraitDiscoverer("Microsoft.DotNet.XUnitExtensions.SkipOnTargetFrameworkDiscoverer", "Microsoft.DotNet.XUnitExtensions")]
|
||||
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true)]
|
||||
public class SkipOnTargetFrameworkAttribute : Attribute, ITraitAttribute
|
||||
{
|
||||
public SkipOnTargetFrameworkAttribute(TargetFrameworkMonikers platform, string reason = null) { }
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using Xunit.Sdk;
|
||||
|
||||
namespace Xunit
|
||||
{
|
||||
/// <summary>
|
||||
/// Apply this attribute to your test method to specify the test category.
|
||||
/// </summary>
|
||||
[TraitDiscoverer("Microsoft.DotNet.XUnitExtensions.TestCategoryDiscoverer", "Microsoft.DotNet.XUnitExtensions")]
|
||||
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true)]
|
||||
public class TestCategoryAttribute : Attribute, ITraitAttribute
|
||||
{
|
||||
public TestCategoryAttribute(string category) { }
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.DotNet.XUnitExtensions
|
||||
{
|
||||
internal class ConditionalDiscovererException : Exception
|
||||
{
|
||||
public ConditionalDiscovererException(string message) : base(message) { }
|
||||
}
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Microsoft.DotNet.XUnitExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Trace Listener for corefx Desktop test execution to avoid showing assert pop-ups and making the test fail when an Assert fails.
|
||||
/// </summary>
|
||||
public class DesktopTestTraceListener : DefaultTraceListener
|
||||
{
|
||||
/// <summary>
|
||||
/// Override of <see cref="DefaultTraceListener.Fail" /> to handle Assert failures with custom behavior.
|
||||
/// When an Assert failure happens during test execution we will rather throw a DebugAssertException so that the test fails and we have a full StackTrace.
|
||||
/// </summary>
|
||||
public override void Fail(string message, string detailMessage)
|
||||
{
|
||||
throw new DebugAssertException(message, detailMessage);
|
||||
}
|
||||
|
||||
private sealed class DebugAssertException : Exception
|
||||
{
|
||||
internal DebugAssertException(string message, string detailMessage) :
|
||||
base(message + Environment.NewLine + detailMessage)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.DotNet.XUnitExtensions
|
||||
{
|
||||
internal static class DiscovererHelpers
|
||||
{
|
||||
internal static bool TestPlatformApplies(TestPlatforms platforms) =>
|
||||
#if NETCOREAPP
|
||||
(platforms.HasFlag(TestPlatforms.FreeBSD) && RuntimeInformation.IsOSPlatform(OSPlatform.Create("FREEBSD"))) ||
|
||||
(platforms.HasFlag(TestPlatforms.Linux) && RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) ||
|
||||
(platforms.HasFlag(TestPlatforms.NetBSD) && RuntimeInformation.IsOSPlatform(OSPlatform.Create("NETBSD"))) ||
|
||||
(platforms.HasFlag(TestPlatforms.OSX) && RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) ||
|
||||
(platforms.HasFlag(TestPlatforms.Windows) && RuntimeInformation.IsOSPlatform(OSPlatform.Windows));
|
||||
# else
|
||||
(platforms.HasFlag(TestPlatforms.Windows) && (int)Environment.OSVersion.Platform == 2) ||
|
||||
(platforms.HasFlag(TestPlatforms.Linux) && (int)Environment.OSVersion.Platform == 4) ||
|
||||
(platforms.HasFlag(TestPlatforms.OSX) && (int)Environment.OSVersion.Platform == 6);
|
||||
#endif
|
||||
}
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
using Xunit.Sdk;
|
||||
|
||||
namespace Microsoft.DotNet.XUnitExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// This class discovers all of the tests and test classes that have
|
||||
/// applied the ActiveIssue attribute
|
||||
/// </summary>
|
||||
public class ActiveIssueDiscoverer : ITraitDiscoverer
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the trait values from the Category attribute.
|
||||
/// </summary>
|
||||
/// <param name="traitAttribute">The trait attribute containing the trait values.</param>
|
||||
/// <returns>The trait values.</returns>
|
||||
public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitAttribute)
|
||||
{
|
||||
IEnumerable<object> ctorArgs = traitAttribute.GetConstructorArguments();
|
||||
Debug.Assert(ctorArgs.Count() >= 2);
|
||||
|
||||
string issue = ctorArgs.First().ToString();
|
||||
TestPlatforms platforms = TestPlatforms.Any;
|
||||
TargetFrameworkMonikers frameworks = (TargetFrameworkMonikers)0;
|
||||
|
||||
foreach (object arg in ctorArgs.Skip(1)) // First argument is the issue number.
|
||||
{
|
||||
if (arg is TestPlatforms)
|
||||
{
|
||||
platforms = (TestPlatforms)arg;
|
||||
}
|
||||
else if (arg is TargetFrameworkMonikers)
|
||||
{
|
||||
frameworks = (TargetFrameworkMonikers)arg;
|
||||
}
|
||||
}
|
||||
|
||||
if (DiscovererHelpers.TestPlatformApplies(platforms))
|
||||
{
|
||||
if (frameworks.HasFlag(TargetFrameworkMonikers.Netcoreapp))
|
||||
yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNetcoreappTest);
|
||||
if (frameworks.HasFlag(TargetFrameworkMonikers.NetFramework))
|
||||
yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNetfxTest);
|
||||
if (frameworks.HasFlag(TargetFrameworkMonikers.Uap))
|
||||
yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonUapTest);
|
||||
if (frameworks.HasFlag(TargetFrameworkMonikers.Mono))
|
||||
yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonMonoTest);
|
||||
if (frameworks == (TargetFrameworkMonikers)0)
|
||||
yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.Failing);
|
||||
|
||||
yield return new KeyValuePair<string, string>(XunitConstants.ActiveIssue, issue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Xunit.Abstractions;
|
||||
using Xunit.Sdk;
|
||||
|
||||
namespace Microsoft.DotNet.XUnitExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// This class discovers all of the tests and test classes that have
|
||||
/// applied the ConditionalClass attribute
|
||||
/// </summary>
|
||||
public class ConditionalClassDiscoverer : ITraitDiscoverer
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the trait values from the Category attribute.
|
||||
/// </summary>
|
||||
/// <param name="traitAttribute">The trait attribute containing the trait values.</param>
|
||||
/// <returns>The trait values.</returns>
|
||||
public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitAttribute)
|
||||
{
|
||||
// If evaluated to false, skip the test class entirely.
|
||||
if (!EvaluateParameterHelper(traitAttribute))
|
||||
{
|
||||
yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.Failing);
|
||||
}
|
||||
}
|
||||
|
||||
internal static bool EvaluateParameterHelper(IAttributeInfo traitAttribute)
|
||||
{
|
||||
// Parse the traitAttribute. We make sure it contains two parts:
|
||||
// 1. Type 2. nameof(conditionMemberName)
|
||||
object[] conditionArguments = traitAttribute.GetConstructorArguments().ToArray();
|
||||
Debug.Assert(conditionArguments.Count() == 2);
|
||||
|
||||
Type calleeType = null;
|
||||
string[] conditionMemberNames = null;
|
||||
|
||||
if (ConditionalTestDiscoverer.CheckInputToSkipExecution(conditionArguments, ref calleeType, ref conditionMemberNames))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
foreach (string entry in conditionMemberNames)
|
||||
{
|
||||
// Null condition member names are silently tolerated.
|
||||
if (string.IsNullOrWhiteSpace(entry))
|
||||
continue;
|
||||
|
||||
MethodInfo conditionMethodInfo = ConditionalTestDiscoverer.LookupConditionalMethod(calleeType, entry);
|
||||
if (conditionMethodInfo == null)
|
||||
{
|
||||
throw new InvalidOperationException($"Unable to get MethodInfo, please check input for {entry}.");
|
||||
}
|
||||
|
||||
// If one of the conditions is false, then return the category failing trait.
|
||||
if (!(bool)conditionMethodInfo.Invoke(null, null))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Linq;
|
||||
using Xunit.Abstractions;
|
||||
using Xunit.Sdk;
|
||||
|
||||
namespace Microsoft.DotNet.XUnitExtensions
|
||||
{
|
||||
public class ConditionalFactDiscoverer : FactDiscoverer
|
||||
{
|
||||
public ConditionalFactDiscoverer(IMessageSink diagnosticMessageSink) : base(diagnosticMessageSink) { }
|
||||
|
||||
protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
|
||||
{
|
||||
if (ConditionalTestDiscoverer.TryEvaluateSkipConditions(discoveryOptions, DiagnosticMessageSink, testMethod, factAttribute.GetConstructorArguments().ToArray(), out string skipReason, out ExecutionErrorTestCase errorTestCase))
|
||||
{
|
||||
return skipReason != null
|
||||
? (IXunitTestCase)new SkippedTestCase(skipReason, DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod)
|
||||
: new SkippedFactTestCase(DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod); // Test case skippable at runtime.
|
||||
}
|
||||
|
||||
return errorTestCase;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,180 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Xunit.Abstractions;
|
||||
using Xunit.Sdk;
|
||||
|
||||
namespace Microsoft.DotNet.XUnitExtensions
|
||||
{
|
||||
// Internal helper class for code common to conditional test discovery through
|
||||
// [ConditionalFact] and [ConditionalTheory]
|
||||
internal static class ConditionalTestDiscoverer
|
||||
{
|
||||
// This helper method evaluates the given condition member names for a given set of test cases.
|
||||
// If any condition member evaluates to 'false', the test cases are marked to be skipped.
|
||||
// The skip reason is the collection of all the condition members that evaluated to 'false'.
|
||||
internal static string EvaluateSkipConditions(ITestMethod testMethod, object[] conditionArguments)
|
||||
{
|
||||
Type calleeType = null;
|
||||
string[] conditionMemberNames = null;
|
||||
|
||||
if (CheckInputToSkipExecution(conditionArguments, ref calleeType, ref conditionMemberNames, testMethod))
|
||||
return null;
|
||||
|
||||
MethodInfo testMethodInfo = testMethod.Method.ToRuntimeMethod();
|
||||
Type testMethodDeclaringType = testMethodInfo.DeclaringType;
|
||||
List<string> falseConditions = new List<string>(conditionMemberNames.Count());
|
||||
|
||||
foreach (string entry in conditionMemberNames)
|
||||
{
|
||||
string conditionMemberName = entry;
|
||||
|
||||
// Null condition member names are silently tolerated
|
||||
if (string.IsNullOrWhiteSpace(conditionMemberName))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Type declaringType;
|
||||
|
||||
if (calleeType != null)
|
||||
{
|
||||
declaringType = calleeType;
|
||||
}
|
||||
else
|
||||
{
|
||||
declaringType = testMethodDeclaringType;
|
||||
|
||||
string[] symbols = conditionMemberName.Split('.');
|
||||
if (symbols.Length == 2)
|
||||
{
|
||||
conditionMemberName = symbols[1];
|
||||
ITypeInfo type = testMethod.TestClass.Class.Assembly.GetTypes(false).Where(t => t.Name.Contains(symbols[0])).FirstOrDefault();
|
||||
if (type != null)
|
||||
{
|
||||
declaringType = type.ToRuntimeType();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MethodInfo conditionMethodInfo;
|
||||
if ((conditionMethodInfo = LookupConditionalMethod(declaringType, conditionMemberName)) == null)
|
||||
{
|
||||
throw new ConditionalDiscovererException(GetFailedLookupString(conditionMemberName, declaringType));
|
||||
}
|
||||
|
||||
// In the case of multiple conditions, collect the results of all
|
||||
// of them to produce a summary skip reason.
|
||||
try
|
||||
{
|
||||
if (!(bool)conditionMethodInfo.Invoke(null, null))
|
||||
{
|
||||
falseConditions.Add(conditionMemberName);
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
falseConditions.Add($"{conditionMemberName} ({exc.GetType().Name})");
|
||||
}
|
||||
}
|
||||
|
||||
// Compose a summary of all conditions that returned false.
|
||||
if (falseConditions.Count > 0)
|
||||
{
|
||||
return string.Format("Condition(s) not met: \"{0}\"", string.Join("\", \"", falseConditions));
|
||||
}
|
||||
|
||||
// No conditions returned false (including the absence of any conditions).
|
||||
return null;
|
||||
}
|
||||
|
||||
internal static bool TryEvaluateSkipConditions(ITestFrameworkDiscoveryOptions discoveryOptions, IMessageSink diagnosticMessageSink, ITestMethod testMethod, object[] conditionArguments, out string skipReason, out ExecutionErrorTestCase errorTestCase)
|
||||
{
|
||||
skipReason = null;
|
||||
errorTestCase = null;
|
||||
try
|
||||
{
|
||||
skipReason = EvaluateSkipConditions(testMethod, conditionArguments);
|
||||
return true;
|
||||
}
|
||||
catch (ConditionalDiscovererException e)
|
||||
{
|
||||
errorTestCase = new ExecutionErrorTestCase(
|
||||
diagnosticMessageSink,
|
||||
discoveryOptions.MethodDisplayOrDefault(),
|
||||
discoveryOptions.MethodDisplayOptionsOrDefault(),
|
||||
testMethod,
|
||||
e.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
internal static string GetFailedLookupString(string name, Type type)
|
||||
{
|
||||
return
|
||||
$"An appropriate member '{name}' could not be found. " +
|
||||
$"The conditional method needs to be a static method or property on the type {type} or any ancestor, " +
|
||||
"of any visibility, accepting zero arguments, and having a return type of Boolean.";
|
||||
}
|
||||
|
||||
internal static MethodInfo LookupConditionalMethod(Type t, string name)
|
||||
{
|
||||
if (t == null || name == null)
|
||||
return null;
|
||||
|
||||
TypeInfo ti = t.GetTypeInfo();
|
||||
|
||||
MethodInfo mi = ti.GetDeclaredMethod(name);
|
||||
if (mi != null && mi.IsStatic && mi.GetParameters().Length == 0 && mi.ReturnType == typeof(bool))
|
||||
return mi;
|
||||
|
||||
PropertyInfo pi = ti.GetDeclaredProperty(name);
|
||||
if (pi != null && pi.PropertyType == typeof(bool) && pi.GetMethod != null && pi.GetMethod.IsStatic && pi.GetMethod.GetParameters().Length == 0)
|
||||
return pi.GetMethod;
|
||||
|
||||
return LookupConditionalMethod(ti.BaseType, name);
|
||||
}
|
||||
|
||||
internal static bool CheckInputToSkipExecution(object[] conditionArguments, ref Type calleeType, ref string[] conditionMemberNames, ITestMethod testMethod = null)
|
||||
{
|
||||
// A null or empty list of conditionArguments is treated as "no conditions".
|
||||
// and the test cases will be executed.
|
||||
// Example: [ConditionalClass()]
|
||||
if (conditionArguments == null || conditionArguments.Length == 0)
|
||||
return true;
|
||||
|
||||
calleeType = conditionArguments[0] as Type;
|
||||
if (calleeType != null)
|
||||
{
|
||||
if (conditionArguments.Length < 2)
|
||||
{
|
||||
// [ConditionalFact(typeof(x))] no provided methods.
|
||||
return true;
|
||||
}
|
||||
|
||||
// [ConditionalFact(typeof(x), "MethodName")]
|
||||
conditionMemberNames = conditionArguments[1] as string[];
|
||||
}
|
||||
else
|
||||
{
|
||||
// For [ConditionalClass], unable to get the Type info. All test cases will be executed.
|
||||
if (testMethod == null)
|
||||
return true;
|
||||
|
||||
// [ConditionalFact("MethodName")]
|
||||
conditionMemberNames = conditionArguments[0] as string[];
|
||||
}
|
||||
|
||||
// [ConditionalFact((string[]) null)]
|
||||
if (conditionMemberNames == null || conditionMemberNames.Count() == 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Xunit.Abstractions;
|
||||
using Xunit.Sdk;
|
||||
|
||||
namespace Microsoft.DotNet.XUnitExtensions
|
||||
{
|
||||
public class ConditionalTheoryDiscoverer : TheoryDiscoverer
|
||||
{
|
||||
private readonly Dictionary<IMethodInfo, string> _conditionCache;
|
||||
|
||||
public ConditionalTheoryDiscoverer(IMessageSink diagnosticMessageSink) : base(diagnosticMessageSink)
|
||||
{
|
||||
_conditionCache = new Dictionary<IMethodInfo, string>();
|
||||
}
|
||||
|
||||
protected override IEnumerable<IXunitTestCase> CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute)
|
||||
{
|
||||
if (ConditionalTestDiscoverer.TryEvaluateSkipConditions(discoveryOptions, DiagnosticMessageSink, testMethod, theoryAttribute.GetConstructorArguments().ToArray(), out string skipReason, out ExecutionErrorTestCase errorTestCase))
|
||||
{
|
||||
return skipReason != null
|
||||
? new[] { new SkippedTestCase(skipReason, DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod) }
|
||||
: new IXunitTestCase[] { new SkippedTheoryTestCase(DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod) }; // Theory skippable at runtime.
|
||||
}
|
||||
|
||||
return new IXunitTestCase[] { errorTestCase };
|
||||
}
|
||||
|
||||
protected override IEnumerable<IXunitTestCase> CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute, object[] dataRow)
|
||||
{
|
||||
IMethodInfo methodInfo = testMethod.Method;
|
||||
List<IXunitTestCase> skippedTestCase = new List<IXunitTestCase>();
|
||||
|
||||
if (!_conditionCache.TryGetValue(methodInfo, out string skipReason))
|
||||
{
|
||||
if (!ConditionalTestDiscoverer.TryEvaluateSkipConditions(discoveryOptions, DiagnosticMessageSink, testMethod, theoryAttribute.GetConstructorArguments().ToArray(), out skipReason, out ExecutionErrorTestCase errorTestCase))
|
||||
{
|
||||
return new IXunitTestCase[] { errorTestCase };
|
||||
}
|
||||
|
||||
_conditionCache.Add(methodInfo, skipReason);
|
||||
|
||||
if (skipReason != null)
|
||||
{
|
||||
// If this is the first time we evalute the condition we return a SkippedTestCase to avoid printing a skip for every inline-data.
|
||||
skippedTestCase.Add(new SkippedTestCase(skipReason, DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod));
|
||||
}
|
||||
}
|
||||
|
||||
return skipReason != null ?
|
||||
(IEnumerable<IXunitTestCase>)skippedTestCase
|
||||
: new[] { new SkippedFactTestCase(DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, dataRow) }; // Test case skippable at runtime.
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Xunit.Abstractions;
|
||||
using Xunit.Sdk;
|
||||
|
||||
namespace Microsoft.DotNet.XUnitExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// This class discovers all of the tests and test classes that have
|
||||
/// applied the OuterLoop attribute
|
||||
/// </summary>
|
||||
public class OuterLoopTestsDiscoverer : ITraitDiscoverer
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the trait values from the Category attribute.
|
||||
/// </summary>
|
||||
/// <param name="traitAttribute">The trait attribute containing the trait values.</param>
|
||||
/// <returns>The trait values.</returns>
|
||||
public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitAttribute)
|
||||
{
|
||||
yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.OuterLoop);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
using Xunit.Sdk;
|
||||
|
||||
namespace Microsoft.DotNet.XUnitExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// This class discovers all of the tests and test classes that have
|
||||
/// applied the PlatformSpecific attribute
|
||||
/// </summary>
|
||||
public class PlatformSpecificDiscoverer : ITraitDiscoverer
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the trait values from the Category attribute.
|
||||
/// </summary>
|
||||
/// <param name="traitAttribute">The trait attribute containing the trait values.</param>
|
||||
/// <returns>The trait values.</returns>
|
||||
public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitAttribute)
|
||||
{
|
||||
TestPlatforms platforms = (TestPlatforms)traitAttribute.GetConstructorArguments().First();
|
||||
if (!platforms.HasFlag(TestPlatforms.Windows))
|
||||
yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonWindowsTest);
|
||||
if (!platforms.HasFlag(TestPlatforms.Linux))
|
||||
yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonLinuxTest);
|
||||
if (!platforms.HasFlag(TestPlatforms.OSX))
|
||||
yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonOSXTest);
|
||||
if (!platforms.HasFlag(TestPlatforms.FreeBSD))
|
||||
yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonFreeBSDTest);
|
||||
if (!platforms.HasFlag(TestPlatforms.NetBSD))
|
||||
yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNetBSDTest);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,103 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
using Xunit.Sdk;
|
||||
|
||||
namespace Microsoft.DotNet.XUnitExtensions
|
||||
{
|
||||
public class SkipOnCoreClrDiscoverer : ITraitDiscoverer
|
||||
{
|
||||
public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitAttribute)
|
||||
{
|
||||
if (!SkipOnMonoDiscoverer.IsMonoRuntime)
|
||||
{
|
||||
TestPlatforms testPlatforms = TestPlatforms.Any;
|
||||
RuntimeStressTestModes stressMode = RuntimeStressTestModes.Any;
|
||||
foreach (object arg in traitAttribute.GetConstructorArguments().Skip(1)) // We skip the first one as it is the reason
|
||||
{
|
||||
if (arg is TestPlatforms tp)
|
||||
{
|
||||
testPlatforms = tp;
|
||||
}
|
||||
else if (arg is RuntimeStressTestModes rstm)
|
||||
{
|
||||
stressMode = rstm;
|
||||
}
|
||||
}
|
||||
|
||||
if (DiscovererHelpers.TestPlatformApplies(testPlatforms) && StressModeApplies(stressMode))
|
||||
{
|
||||
if (IsCheckedRuntime() || (IsRuntimeStressTesting && !stressMode.HasFlag(RuntimeStressTestModes.CheckedRuntime)))
|
||||
{
|
||||
return new[] { new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.Failing) };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Array.Empty<KeyValuePair<string, string>>();
|
||||
}
|
||||
|
||||
// Order here matters as some env variables may appear in multiple modes
|
||||
private static bool StressModeApplies(RuntimeStressTestModes stressMode) =>
|
||||
stressMode == RuntimeStressTestModes.Any ||
|
||||
(stressMode.HasFlag(RuntimeStressTestModes.GCStress3) && IsGCStress3) ||
|
||||
(stressMode.HasFlag(RuntimeStressTestModes.GCStressC) && IsGCStressC) ||
|
||||
(stressMode.HasFlag(RuntimeStressTestModes.ZapDisable) && IsZapDisable) ||
|
||||
(stressMode.HasFlag(RuntimeStressTestModes.TailcallStress) && IsTailCallStress) ||
|
||||
(stressMode.HasFlag(RuntimeStressTestModes.JitStressRegs) && IsJitStressRegs) ||
|
||||
(stressMode.HasFlag(RuntimeStressTestModes.JitStress) && IsJitStress) ||
|
||||
(stressMode.HasFlag(RuntimeStressTestModes.JitMinOpts) && IsJitMinOpts) ||
|
||||
stressMode == RuntimeStressTestModes.CheckedRuntime; // if checked runtime is the only flag, all stress modes apply.
|
||||
|
||||
// Order here matters as some env variables may appear in multiple modes
|
||||
private static bool IsRuntimeStressTesting =>
|
||||
IsGCStress3 ||
|
||||
IsGCStressC ||
|
||||
IsZapDisable ||
|
||||
IsTailCallStress ||
|
||||
IsJitStressRegs ||
|
||||
IsJitStress ||
|
||||
IsJitMinOpts;
|
||||
|
||||
private static string GetEnvironmentVariableValue(string name) => Environment.GetEnvironmentVariable(name) ?? "0";
|
||||
|
||||
private static bool IsJitStress => !string.Equals(GetEnvironmentVariableValue("COMPlus_JitStress"), "0", StringComparison.InvariantCulture);
|
||||
|
||||
private static bool IsJitStressRegs => !string.Equals(GetEnvironmentVariableValue("COMPlus_JitStressRegs"), "0", StringComparison.InvariantCulture);
|
||||
|
||||
private static bool IsJitMinOpts => string.Equals(GetEnvironmentVariableValue("COMPlus_JITMinOpts"), "1", StringComparison.InvariantCulture);
|
||||
|
||||
private static bool IsTailCallStress => string.Equals(GetEnvironmentVariableValue("COMPlus_TailcallStress"), "1", StringComparison.InvariantCulture);
|
||||
|
||||
private static bool IsZapDisable => string.Equals(GetEnvironmentVariableValue("COMPlus_ZapDisable"), "1", StringComparison.InvariantCulture);
|
||||
|
||||
private static bool IsGCStress3 => CompareGCStressModeAsLower(GetEnvironmentVariableValue("COMPlus_GCStress"), "0x3", "3");
|
||||
|
||||
private static bool IsGCStressC => CompareGCStressModeAsLower(GetEnvironmentVariableValue("COMPlus_GCStress"), "0xC", "C");
|
||||
|
||||
private static bool IsCheckedRuntime()
|
||||
{
|
||||
Assembly assembly = typeof(string).Assembly;
|
||||
AssemblyConfigurationAttribute assemblyConfigurationAttribute = assembly.GetCustomAttribute<AssemblyConfigurationAttribute>();
|
||||
|
||||
return assemblyConfigurationAttribute != null &&
|
||||
string.Equals(assemblyConfigurationAttribute.Configuration, "Checked", StringComparison.InvariantCulture);
|
||||
}
|
||||
|
||||
private static bool CompareGCStressModeAsLower(string value, string first, string second)
|
||||
{
|
||||
value = value.ToLowerInvariant();
|
||||
return string.Equals(value, first.ToLowerInvariant(), StringComparison.InvariantCulture) ||
|
||||
string.Equals(value, second.ToLowerInvariant(), StringComparison.InvariantCulture) ||
|
||||
string.Equals(value, "0xf", StringComparison.InvariantCulture) ||
|
||||
string.Equals(value, "f", StringComparison.InvariantCulture);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
using Xunit.Sdk;
|
||||
|
||||
namespace Microsoft.DotNet.XUnitExtensions
|
||||
{
|
||||
public class SkipOnMonoDiscoverer : ITraitDiscoverer
|
||||
{
|
||||
public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitAttribute)
|
||||
{
|
||||
if (IsMonoRuntime)
|
||||
{
|
||||
TestPlatforms testPlatforms = TestPlatforms.Any;
|
||||
|
||||
// Last argument is either the TestPlatform or the test platform to skip the test on.
|
||||
if (traitAttribute.GetConstructorArguments().LastOrDefault() is TestPlatforms tp)
|
||||
{
|
||||
testPlatforms = tp;
|
||||
}
|
||||
|
||||
if (DiscovererHelpers.TestPlatformApplies(testPlatforms))
|
||||
{
|
||||
return new[] { new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.Failing) };
|
||||
}
|
||||
}
|
||||
|
||||
return Array.Empty<KeyValuePair<string, string>>();
|
||||
}
|
||||
|
||||
public static bool IsMonoRuntime => Type.GetType("Mono.RuntimeStructs") != null;
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
using Xunit.Sdk;
|
||||
|
||||
namespace Microsoft.DotNet.XUnitExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// This class discovers all of the tests and test classes that have
|
||||
/// applied the TestOnTargetFrameworkDiscoverer attribute
|
||||
/// </summary>
|
||||
public class SkipOnTargetFrameworkDiscoverer : ITraitDiscoverer
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the trait values from the Category attribute.
|
||||
/// </summary>
|
||||
/// <param name="traitAttribute">The trait attribute containing the trait values.</param>
|
||||
/// <returns>The trait values.</returns>
|
||||
public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitAttribute)
|
||||
{
|
||||
TargetFrameworkMonikers frameworks = (TargetFrameworkMonikers)traitAttribute.GetConstructorArguments().First();
|
||||
if (frameworks.HasFlag(TargetFrameworkMonikers.Netcoreapp))
|
||||
yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNetcoreappTest);
|
||||
if (frameworks.HasFlag(TargetFrameworkMonikers.NetFramework))
|
||||
yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonNetfxTest);
|
||||
if (frameworks.HasFlag(TargetFrameworkMonikers.Uap))
|
||||
yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonUapTest);
|
||||
if (frameworks.HasFlag(TargetFrameworkMonikers.Mono))
|
||||
yield return new KeyValuePair<string, string>(XunitConstants.Category, XunitConstants.NonMonoTest);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Xunit.Abstractions;
|
||||
using Xunit.Sdk;
|
||||
|
||||
/// <summary>
|
||||
/// This is a replacement for the MSTest [TestCategoryAttribute] on xunit
|
||||
/// xunit does not have the concept of Category for tests and instead, the have [TraitAttribute(string key, string value)]
|
||||
/// If we replace the MSTest [TestCategoryAttribute] for the [TestCategory("BVT")], we will surely fall at some time in cases
|
||||
/// where people will typo on the "Category" key part of the Trait.
|
||||
/// On order to achieve the same behaviour as on MSTest, a custom [TestCategory] was created
|
||||
/// to mimic the MSTest one and avoid replace it on every existent test.
|
||||
/// The tests can be filtered by xunit runners by usage of "-trait" on the command line with the expression like
|
||||
/// <code>-trait "Category=BVT"</code> for example that will only run the tests with [TestCategory("BVT")] on it.
|
||||
/// </summary>
|
||||
|
||||
namespace Microsoft.DotNet.XUnitExtensions
|
||||
{
|
||||
public class TestCategoryDiscoverer : ITraitDiscoverer
|
||||
{
|
||||
public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitAttribute)
|
||||
{
|
||||
var ctorArgs = traitAttribute.GetConstructorArguments().ToList();
|
||||
yield return new KeyValuePair<string, string>("Category", ctorArgs[0].ToString());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace System
|
||||
{
|
||||
public static partial class PlatformDetection
|
||||
{
|
||||
public static bool IsArmProcess => RuntimeInformation.ProcessArchitecture == Architecture.Arm;
|
||||
public static bool IsNotArmProcess => !IsArmProcess;
|
||||
public static bool IsX86Process => RuntimeInformation.ProcessArchitecture == Architecture.X86;
|
||||
public static bool IsNotX86Process => !IsX86Process;
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.DotNet.XUnitExtensions
|
||||
{
|
||||
public static class TheoryExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts an IEnumerable<typeparamref name="T"/> into an Xunit theory compatible enumerable.
|
||||
/// </summary>
|
||||
public static TheoryData ToTheoryData<T>(this IEnumerable<T> data)
|
||||
{
|
||||
// Returning TheoryData rather than IEnumerable<object> directly should
|
||||
// encourage discover and usage of TheoryData<T1, ..> classes for more
|
||||
// complicated theories. Slightly easier to type as well.
|
||||
return new TheoryDataAdapter(data.Select(d => new object[] { d }));
|
||||
}
|
||||
|
||||
private class TheoryDataAdapter : TheoryData, IEnumerable<object[]>
|
||||
{
|
||||
private IEnumerable<object[]> _data;
|
||||
|
||||
public TheoryDataAdapter(IEnumerable<object[]> data)
|
||||
{
|
||||
_data = data;
|
||||
}
|
||||
|
||||
public new IEnumerator<object[]> GetEnumerator() => _data.GetEnumerator();
|
||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<AssemblyName>Microsoft.DotNet.XUnitExtensions</AssemblyName>
|
||||
<TargetGroup Condition="$(TargetFramework.StartsWith('netcoreapp'))">netcoreapp</TargetGroup>
|
||||
<TargetGroup Condition="$(TargetFramework.StartsWith('net4'))">netfx</TargetGroup>
|
||||
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
||||
<IntermediateOutputPath>$(ObjFolder)$(Configuration).$(Platform)\$(AssemblyName)</IntermediateOutputPath>
|
||||
<OutputPath>$(BinFolder)$(Configuration).$(Platform)\$(AssemblyName)</OutputPath>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Attributes\ActiveIssueAttribute.cs" />
|
||||
<Compile Include="Discoverers\ActiveIssueDiscoverer.cs" />
|
||||
<Compile Include="Attributes\ConditionalClassAttribute.cs" />
|
||||
<Compile Include="Discoverers\ConditionalClassDiscoverer.cs" />
|
||||
<Compile Include="ConditionalDiscovererException.cs" />
|
||||
<Compile Include="Attributes\ConditionalFactAttribute.cs" />
|
||||
<Compile Include="Discoverers\ConditionalFactDiscoverer.cs" />
|
||||
<Compile Include="Discoverers\ConditionalTestDiscoverer.cs" />
|
||||
<Compile Include="Attributes\ConditionalTheoryAttribute.cs" />
|
||||
<Compile Include="Discoverers\ConditionalTheoryDiscoverer.cs" />
|
||||
<Compile Include="DesktopTraceListener.cs" />
|
||||
<Compile Include="DiscovererHelpers.cs" />
|
||||
<Compile Include="Attributes\OuterLoopAttribute.cs" />
|
||||
<Compile Include="Discoverers\OuterLoopTestsDiscoverer.cs" />
|
||||
<Compile Include="Attributes\PlatformSpecificAttribute.cs" />
|
||||
<Compile Include="Discoverers\PlatformSpecificDiscoverer.cs" />
|
||||
<Compile Include="Extensions\AssertExtensions.cs" />
|
||||
<Compile Include="Extensions\PlatformDetection.cs" />
|
||||
<Compile Include="RuntimeStressTestModes.cs" />
|
||||
<Compile Include="Attributes\SkipOnCoreClrAttribute.cs" />
|
||||
<Compile Include="Discoverers\SkipOnCoreClrDiscoverer.cs" />
|
||||
<Compile Include="Attributes\SkipOnMonoAttribute.cs" />
|
||||
<Compile Include="Discoverers\SkipOnMonoDiscoverer.cs" />
|
||||
<Compile Include="Attributes\SkipOnTargetFrameworkAttribute.cs" />
|
||||
<Compile Include="Discoverers\SkipOnTargetFrameworkDiscoverer.cs" />
|
||||
<Compile Include="SkippedFactTestCase.cs" />
|
||||
<Compile Include="SkippedTestCase.cs" />
|
||||
<Compile Include="SkippedTestMessageBus.cs" />
|
||||
<Compile Include="SkippedTheoryTestCase.cs" />
|
||||
<Compile Include="TargetFrameworkMonikers.cs" />
|
||||
<Compile Include="Attributes\TestCategoryAttribute.cs" />
|
||||
<Compile Include="Discoverers\TestCategoryDiscoverer.cs" />
|
||||
<Compile Include="TestPlatforms.cs" />
|
||||
<Compile Include="Extensions\TheoryExtensions.cs" />
|
||||
<Compile Include="XunitConstants.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkVersion)" />
|
||||
<PackageReference Condition="$(TargetGroup) == 'netfx'" Include="System.Runtime.InteropServices.RuntimeInformation" Version="$(SystemRuntimeInteropServicesRuntimeInformationVersion)" />
|
||||
<PackageReference Include="xunit" Version="$(XunitVersion)" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="$(xunitrunnervisualstudioVersion)" />
|
||||
<PackageReference Include="xunit.runner.console" Version="$(XunitVersion)" />
|
||||
<PackageReference Include="xunit.runner.utility" Version="$(XunitVersion)" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -1,39 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Xunit
|
||||
{
|
||||
[Flags]
|
||||
public enum RuntimeStressTestModes
|
||||
{
|
||||
// Disable on any stress test mode or on checked runtime.
|
||||
// Can't be ~0 as that would include CheckedRuntime flag, which would break the case
|
||||
// where you want to disable in all (including release stress test).
|
||||
Any = 0,
|
||||
|
||||
// JitStress, JitStressRegs, JitMinOpts and TailcallStress enable
|
||||
// various modes in the JIT that cause us to exercise more code paths,
|
||||
// and generate different kinds of code
|
||||
JitStress = 1, // COMPlus_JitStress is set.
|
||||
JitStressRegs = 1 << 1, // COMPlus_JitStressRegs is set.
|
||||
JitMinOpts = 1 << 2, // COMPlus_JITMinOpts is set.
|
||||
TailcallStress = 1 << 3, // COMPlus_TailcallStress is set.
|
||||
|
||||
// ZapDisable says to not use NGEN or ReadyToRun images.
|
||||
// This means we JIT everything.
|
||||
ZapDisable = 1 << 4, // COMPlus_ZapDisable is set.
|
||||
|
||||
// GCStress3 forces a GC at various locations, typically transitions
|
||||
// to/from the VM from managed code.
|
||||
GCStress3 = 1 << 5, // COMPlus_GCStress includes mode 0x3.
|
||||
|
||||
// GCStressC forces a GC at every JIT-generated code instruction,
|
||||
// including in NGEN/ReadyToRun code.
|
||||
GCStressC = 1 << 6, // COMPlus_GCStress includes mode 0xC.
|
||||
CheckedRuntime = 1 << 7, // Disable only when running on checked runtime.
|
||||
AnyGCStress = GCStress3 | GCStressC // Disable when any GCStress is exercised.
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit.Abstractions;
|
||||
using Xunit.Sdk;
|
||||
|
||||
namespace Microsoft.DotNet.XUnitExtensions
|
||||
{
|
||||
/// <summary>Wraps RunAsync for ConditionalFact.</summary>
|
||||
public class SkippedFactTestCase : XunitTestCase
|
||||
{
|
||||
[Obsolete("Called by the de-serializer; should only be called by deriving classes for de-serialization purposes", error: true)]
|
||||
public SkippedFactTestCase() { }
|
||||
|
||||
public SkippedFactTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod, object[] testMethodArguments = null)
|
||||
: base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, testMethodArguments) { }
|
||||
|
||||
public override async Task<RunSummary> RunAsync(IMessageSink diagnosticMessageSink,
|
||||
IMessageBus messageBus,
|
||||
object[] constructorArguments,
|
||||
ExceptionAggregator aggregator,
|
||||
CancellationTokenSource cancellationTokenSource)
|
||||
{
|
||||
SkippedTestMessageBus skipMessageBus = new SkippedTestMessageBus(messageBus);
|
||||
var result = await base.RunAsync(diagnosticMessageSink, skipMessageBus, constructorArguments, aggregator, cancellationTokenSource);
|
||||
if (skipMessageBus.SkippedTestCount > 0)
|
||||
{
|
||||
result.Failed -= skipMessageBus.SkippedTestCount;
|
||||
result.Skipped += skipMessageBus.SkippedTestCount;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using Xunit.Abstractions;
|
||||
using Xunit.Sdk;
|
||||
|
||||
namespace Microsoft.DotNet.XUnitExtensions
|
||||
{
|
||||
/// <summary>Wraps another test case that should be skipped.</summary>
|
||||
internal sealed class SkippedTestCase : XunitTestCase
|
||||
{
|
||||
private string _skipReason;
|
||||
|
||||
[Obsolete("Called by the de-serializer; should only be called by deriving classes for de-serialization purposes")]
|
||||
public SkippedTestCase() : base()
|
||||
{
|
||||
}
|
||||
|
||||
public SkippedTestCase(
|
||||
string skipReason,
|
||||
IMessageSink diagnosticMessageSink,
|
||||
TestMethodDisplay defaultMethodDisplay,
|
||||
TestMethodDisplayOptions defaultMethodDisplayOptions,
|
||||
ITestMethod testMethod,
|
||||
object[] testMethodArguments = null)
|
||||
: base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, testMethodArguments)
|
||||
{
|
||||
_skipReason = skipReason;
|
||||
}
|
||||
|
||||
protected override string GetSkipReason(IAttributeInfo factAttribute)
|
||||
=> _skipReason ?? base.GetSkipReason(factAttribute);
|
||||
|
||||
public override void Deserialize(IXunitSerializationInfo data)
|
||||
{
|
||||
base.Deserialize(data);
|
||||
_skipReason = data.GetValue<string>(nameof(_skipReason));
|
||||
}
|
||||
|
||||
public override void Serialize(IXunitSerializationInfo data)
|
||||
{
|
||||
base.Serialize(data);
|
||||
data.AddValue(nameof(_skipReason), _skipReason);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Xunit.Abstractions;
|
||||
using Xunit.Sdk;
|
||||
|
||||
namespace Microsoft.DotNet.XUnitExtensions
|
||||
{
|
||||
public class SkipTestException : Exception
|
||||
{
|
||||
public SkipTestException(string reason)
|
||||
: base(reason) { }
|
||||
}
|
||||
|
||||
/// <summary>Implements message bus to communicate tests skipped via SkipTestException.</summary>
|
||||
public class SkippedTestMessageBus : IMessageBus
|
||||
{
|
||||
readonly IMessageBus innerBus;
|
||||
|
||||
public SkippedTestMessageBus(IMessageBus innerBus)
|
||||
{
|
||||
this.innerBus = innerBus;
|
||||
}
|
||||
|
||||
public int SkippedTestCount { get; private set; }
|
||||
|
||||
public void Dispose() { }
|
||||
|
||||
public bool QueueMessage(IMessageSinkMessage message)
|
||||
{
|
||||
var testFailed = message as ITestFailed;
|
||||
|
||||
if (testFailed != null)
|
||||
{
|
||||
var exceptionType = testFailed.ExceptionTypes.FirstOrDefault();
|
||||
if (exceptionType == typeof(SkipTestException).FullName)
|
||||
{
|
||||
SkippedTestCount++;
|
||||
return innerBus.QueueMessage(new TestSkipped(testFailed.Test, testFailed.Messages.FirstOrDefault()));
|
||||
}
|
||||
}
|
||||
|
||||
// Nothing we care about, send it on its way
|
||||
return innerBus.QueueMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit.Abstractions;
|
||||
using Xunit.Sdk;
|
||||
|
||||
namespace Microsoft.DotNet.XUnitExtensions
|
||||
{
|
||||
/// <summary>Wraps RunAsync for ConditionalTheory.</summary>
|
||||
public class SkippedTheoryTestCase : XunitTheoryTestCase
|
||||
{
|
||||
[Obsolete("Called by the de-serializer; should only be called by deriving classes for de-serialization purposes", error: true)]
|
||||
public SkippedTheoryTestCase() { }
|
||||
|
||||
public SkippedTheoryTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod)
|
||||
: base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod) { }
|
||||
|
||||
public override async Task<RunSummary> RunAsync(IMessageSink diagnosticMessageSink,
|
||||
IMessageBus messageBus,
|
||||
object[] constructorArguments,
|
||||
ExceptionAggregator aggregator,
|
||||
CancellationTokenSource cancellationTokenSource)
|
||||
{
|
||||
SkippedTestMessageBus skipMessageBus = new SkippedTestMessageBus(messageBus);
|
||||
var result = await base.RunAsync(diagnosticMessageSink, skipMessageBus, constructorArguments, aggregator, cancellationTokenSource);
|
||||
if (skipMessageBus.SkippedTestCount > 0)
|
||||
{
|
||||
result.Failed -= skipMessageBus.SkippedTestCount;
|
||||
result.Skipped += skipMessageBus.SkippedTestCount;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Xunit
|
||||
{
|
||||
[Flags]
|
||||
public enum TargetFrameworkMonikers
|
||||
{
|
||||
Netcoreapp = 0x1,
|
||||
NetFramework = 0x2,
|
||||
Uap = 0x4,
|
||||
Mono = 0x8
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Xunit
|
||||
{
|
||||
[Flags]
|
||||
public enum TestPlatforms
|
||||
{
|
||||
Windows = 1,
|
||||
Linux = 2,
|
||||
OSX = 4,
|
||||
FreeBSD = 8,
|
||||
NetBSD = 16,
|
||||
AnyUnix = FreeBSD | Linux | NetBSD | OSX,
|
||||
Any = ~0
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
namespace Microsoft.DotNet.XUnitExtensions
|
||||
{
|
||||
public struct XunitConstants
|
||||
{
|
||||
internal const string NonFreeBSDTest = "nonfreebsdtests";
|
||||
internal const string NonLinuxTest = "nonlinuxtests";
|
||||
internal const string NonNetBSDTest = "nonnetbsdtests";
|
||||
internal const string NonOSXTest = "nonosxtests";
|
||||
internal const string NonWindowsTest = "nonwindowstests";
|
||||
|
||||
internal static string NonNetcoreappTest = "nonnetcoreapptests";
|
||||
internal static string NonNetfxTest = "nonnetfxtests";
|
||||
internal static string NonUapTest = "nonuaptests";
|
||||
internal static string NonMonoTest = "nonmonotests";
|
||||
|
||||
internal const string Failing = "failing";
|
||||
internal const string ActiveIssue = "activeissue";
|
||||
internal const string OuterLoop = "outerloop";
|
||||
|
||||
public const string Category = "category";
|
||||
public const string IgnoreForCI = "ignoreforci";
|
||||
public const string RequiresElevation = "requireselevation";
|
||||
}
|
||||
}
|
|
@ -51,7 +51,7 @@
|
|||
<!-- NetStandard project dependencies -->
|
||||
<PropertyGroup>
|
||||
<SystemRuntimeLoaderVersion>4.3.0</SystemRuntimeLoaderVersion>
|
||||
<SystemDiagnosticsDiagnosticSourceVersion>6.0.1</SystemDiagnosticsDiagnosticSourceVersion>
|
||||
<SystemDiagnosticsDiagnosticSourceVersion>7.0.2</SystemDiagnosticsDiagnosticSourceVersion>
|
||||
</PropertyGroup>
|
||||
<!-- AKV Provider project dependencies -->
|
||||
<PropertyGroup>
|
||||
|
@ -61,15 +61,16 @@
|
|||
</PropertyGroup>
|
||||
<!-- Test Project Dependencies -->
|
||||
<PropertyGroup>
|
||||
<MicrosoftDotNetXUnitExtensionsVersion>9.0.0-beta.23506.2</MicrosoftDotNetXUnitExtensionsVersion>
|
||||
<MicrosoftDotNetPlatformAbstractionsVersion>3.1.6</MicrosoftDotNetPlatformAbstractionsVersion>
|
||||
<MicrosoftIdentityModelClientsActiveDirectoryVersion>5.2.9</MicrosoftIdentityModelClientsActiveDirectoryVersion>
|
||||
<MicrosoftNETTestSdkVersion>17.4.1</MicrosoftNETTestSdkVersion>
|
||||
<MicrosoftNETTestSdkVersion>17.7.2</MicrosoftNETTestSdkVersion>
|
||||
<NewtonsoftJsonVersion>13.0.1</NewtonsoftJsonVersion>
|
||||
<SystemRuntimeInteropServicesRuntimeInformationVersion>4.3.0</SystemRuntimeInteropServicesRuntimeInformationVersion>
|
||||
<SystemDataOdbcVersion>6.0.1</SystemDataOdbcVersion>
|
||||
<SystemIdentityModelTokensJwtVersion>6.24.0</SystemIdentityModelTokensJwtVersion>
|
||||
<XunitVersion>2.4.2</XunitVersion>
|
||||
<xunitrunnervisualstudioVersion>2.4.5</xunitrunnervisualstudioVersion>
|
||||
<XunitVersion>2.5.1</XunitVersion>
|
||||
<MicrosoftNETFrameworkReferenceAssembliesVersion>1.0.3</MicrosoftNETFrameworkReferenceAssembliesVersion>
|
||||
<MicrosoftDotNetRemoteExecutorVersion>7.0.0-beta.22316.1</MicrosoftDotNetRemoteExecutorVersion>
|
||||
<MicrosoftNETCoreRuntimeCoreCLRVersion>2.0.8</MicrosoftNETCoreRuntimeCoreCLRVersion>
|
||||
<MicrosoftSqlServerSqlManagementObjectsVersion>170.8.0</MicrosoftSqlServerSqlManagementObjectsVersion>
|
||||
|
@ -77,7 +78,7 @@
|
|||
<MicrosoftSqlServerTypesVersionNet>160.1000.6</MicrosoftSqlServerTypesVersionNet>
|
||||
<BenchmarkDotNetVersion>0.13.2</BenchmarkDotNetVersion>
|
||||
<SystemServiceProcessServiceControllerVersion>6.0.0</SystemServiceProcessServiceControllerVersion>
|
||||
<MicrosoftExtensionsHosting>6.0.0</MicrosoftExtensionsHosting>
|
||||
<MicrosoftExtensionsHosting>7.0.1</MicrosoftExtensionsHosting>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<TestAKVProviderVersion>$(NugetPackageVersion)</TestAKVProviderVersion>
|
||||
|
|
Загрузка…
Ссылка в новой задаче