Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test | Removing internal build of XunitExtensions and using the nuget #2033

Merged
merged 30 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Microsoft.Data.SqlClient.Tests
{
public class AmbientTransactionFailureTest
{
private static readonly bool s_isNotArmProcess = TestUtility.s_isNotArmProcess;
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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace System
{
public static class AssertExtensions
{
private static bool IsFullFramework => TestUtility.s_isFullFramework;
private static bool IsFullFramework => TestUtility.IsFullFramework;

public static void Throws<T>(Action action, string message)
where T : Exception
Expand All @@ -36,7 +36,7 @@ public static void Throws<T>(string netCoreParamName, string netFxParamName, Act
IsFullFramework ?
netFxParamName : netCoreParamName;

if (!TestUtility.s_netNative)
if (!TestUtility.NetNative)
Assert.Equal(expectedParamName, exception.ParamName);
}

Expand All @@ -55,7 +55,7 @@ public static void Throws<T>(string netCoreParamName, string netFxParamName, Fun
IsFullFramework ?
netFxParamName : netCoreParamName;

if (!TestUtility.s_netNative)
if (!TestUtility.NetNative)
Assert.Equal(expectedParamName, exception.ParamName);
}

Expand All @@ -64,7 +64,7 @@ public static T Throws<T>(string paramName, Action action)
{
T exception = Assert.Throws<T>(action);

if (!TestUtility.s_netNative)
if (!TestUtility.NetNative)
Assert.Equal(paramName, exception.ParamName);

return exception;
Expand All @@ -83,7 +83,7 @@ public static T Throws<T>(string paramName, Func<object> testCode)
{
T exception = Assert.Throws<T>(testCode);

if (!TestUtility.s_netNative)
if (!TestUtility.NetNative)
Assert.Equal(paramName, exception.ParamName);

return exception;
Expand All @@ -94,7 +94,7 @@ public static async Task<T> ThrowsAsync<T>(string paramName, Func<Task> testCode
{
T exception = await Assert.ThrowsAsync<T>(testCode);

if (!TestUtility.s_netNative)
if (!TestUtility.NetNative)
Assert.Equal(paramName, exception.ParamName);

return exception;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void ConnectionTest()
connection.Open();
}

[ConditionalFact(typeof(TestUtility), nameof(TestUtility.s_isNotArmProcess))]
[ConditionalFact(typeof(TestUtility), nameof(TestUtility.IsNotArmProcess))]
[PlatformSpecific(TestPlatforms.Windows)]
public void IntegratedAuthConnectionTest()
{
Expand All @@ -38,7 +38,7 @@ public void IntegratedAuthConnectionTest()
connection.Open();
}

[ConditionalTheory(typeof(TestUtility), nameof(TestUtility.s_isNotArmProcess))]
[ConditionalTheory(typeof(TestUtility), nameof(TestUtility.IsNotArmProcess))]
[InlineData(40613)]
[InlineData(42108)]
[InlineData(42109)]
Expand All @@ -58,7 +58,7 @@ public async Task TransientFaultTestAsync(uint errorCode)
Assert.Equal(ConnectionState.Open, connection.State);
}

[ConditionalTheory(typeof(TestUtility), nameof(TestUtility.s_isNotArmProcess))]
[ConditionalTheory(typeof(TestUtility), nameof(TestUtility.IsNotArmProcess))]
[InlineData(40613)]
[InlineData(42108)]
[InlineData(42109)]
Expand All @@ -85,7 +85,7 @@ public void TransientFaultTest(uint errorCode)
}
}

[ConditionalTheory(typeof(TestUtility), nameof(TestUtility.s_isNotArmProcess))]
[ConditionalTheory(typeof(TestUtility), nameof(TestUtility.IsNotArmProcess))]
[InlineData(40613)]
[InlineData(42108)]
[InlineData(42109)]
Expand All @@ -107,7 +107,7 @@ public void TransientFaultDisabledTestAsync(uint errorCode)
Assert.Equal(ConnectionState.Closed, connection.State);
}

[ConditionalTheory(typeof(TestUtility), nameof(TestUtility.s_isNotArmProcess))]
[ConditionalTheory(typeof(TestUtility), nameof(TestUtility.IsNotArmProcess))]
[InlineData(40613)]
[InlineData(42108)]
[InlineData(42109)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ public static class DataTestUtility
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;

private static Dictionary<string, bool> AvailableDatabases;
private static BaseEventListener TraceListener;

Expand Down Expand Up @@ -1068,5 +1071,29 @@ public static string GetMachineFQDN(string hostname)
}
return fqdn.ToString();
}

public static bool IsRunningAsUWPApp()
JRahnama marked this conversation as resolved.
Show resolved Hide resolved
{
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;
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@ public void NamedPipeInvalidConnStringTest()
OpenBadConnection(builder.ConnectionString, invalidConnStringError);
}

#if WINDOWS_UAP
[ConditionalFact(typeof(DataTestUtility))]
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.IsRunningAsUWPApp))]
public static void LocalDBNotSupportedOnUapTest()
{
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(@$"server=(localdb)\{DataTestUtility.LocalDbAppName}")
Expand All @@ -194,7 +193,7 @@ public static void LocalDBNotSupportedOnUapTest()
}
});
}
#endif


private void GenerateConnectionException(string connectionString)
{
Expand Down