Skip to content

Commit 3555922

Browse files
committed
WIP
1 parent b2c99a0 commit 3555922

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

src/libraries/System.Data.OleDb/tests/Helpers.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ namespace System.Data.OleDb.Tests
99
public static class Helpers
1010
{
1111
public const string IsDriverAvailable = nameof(Helpers) + "." + nameof(GetIsDriverAvailable);
12-
public const string IsAceDriverAvailable = nameof(Helpers) + "." + nameof(GetIsAceDriverAvailable);
1312
public static bool GetIsDriverAvailable() => Nested.IsAvailable;
14-
public static bool GetIsAceDriverAvailable() => GetIsDriverAvailable() && !PlatformDetection.Is32BitProcess;
1513
public static string ProviderName => Nested.ProviderName;
1614
public static string GetTableName(string memberName) => memberName + ".csv";
1715

@@ -21,25 +19,34 @@ private class Nested
2119
public static readonly string ProviderName;
2220
public static Nested Instance => s_instance;
2321
private static readonly Nested s_instance = new Nested();
24-
private const string ExpectedProviderName = @"Microsoft.ACE.OLEDB.12.0";
2522
private Nested() { }
2623
static Nested()
2724
{
2825
// Get the sources rowset for the SQLOLEDB enumerator
2926
DataTable table = (new OleDbEnumerator()).GetElements();
3027
DataColumn providersRegistered = table.Columns["SOURCES_NAME"];
31-
List<object> providerNames = new List<object>();
28+
List<string> providerNames = new List<object>();
3229
foreach (DataRow row in table.Rows)
3330
{
3431
providerNames.Add((string)row[providersRegistered]);
3532
}
33+
3634
// skip if x86 or if the expected driver not available
37-
IsAvailable = !PlatformDetection.Is32BitProcess && providerNames.Contains(ExpectedProviderName);
35+
//IsAvailable = !PlatformDetection.Is32BitProcess && providerNames.Contains(ExpectedProviderName);
36+
// ActiveIssue: https://github.com/dotnet/runtime/issues/29969
3837
if (!CultureInfo.CurrentCulture.Name.Equals("en-US", StringComparison.OrdinalIgnoreCase))
3938
{
40-
IsAvailable = false; // ActiveIssue: https://github.com/dotnet/runtime/issues/29969
39+
ProviderName = providerNames.Contains("MSOLEDBSQL19")
40+
? "MSOLEDBSQL19"
41+
: providerNames.Contains("MSOLEDBSQL")
42+
? "MSOLEDBSQL"
43+
: null;
44+
45+
if (ProviderName is not null)
46+
{
47+
IsAvailable = true;
48+
}
4149
}
42-
ProviderName = IsAvailable ? ExpectedProviderName : null;
4350
}
4451
}
4552
}

src/libraries/System.Data.OleDb/tests/OleDbConnectionTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public void BeginTransaction_InvalidIsolationLevel_Throws()
9696
Assert.Throws<ArgumentOutOfRangeException>(() => connection.BeginTransaction((IsolationLevel)0));
9797
}
9898

99-
[ConditionalFact(Helpers.IsAceDriverAvailable)]
99+
[ConditionalFact(Helpers.IsDriverAvailable)]
100100
public void BeginTransaction_CallTwice_Throws()
101101
{
102102
// ctor in OleDbTestBase already called BeginTransaction once
@@ -199,7 +199,7 @@ public void GetOleDbSchemaTable_ReturnsTableInfo()
199199
command.ExecuteNonQuery();
200200
}
201201

202-
[ConditionalFact(Helpers.IsAceDriverAvailable)]
202+
[ConditionalFact(Helpers.IsDriverAvailable)]
203203
public void ChangeDatabase_EmptyDatabase_Throws()
204204
{
205205
Assert.Throws<ArgumentException>(() => connection.ChangeDatabase(null));

src/libraries/System.Data.OleDb/tests/OleDbTestBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,6 @@ protected override void Dispose(bool disposing)
6868
base.Dispose(disposing);
6969
}
7070

71-
protected string ConnectionString => @"Provider=" + Helpers.ProviderName + @";Data source=" + TestDirectory + @";Extended Properties=""Text;HDR=No;FMT=Delimited""";
71+
protected string ConnectionString => $"""Provider={Helpers.ProviderName}";Server=(localdb)\MSSQLLocalDB;Integrated Security=SSPI""";
7272
}
7373
}

0 commit comments

Comments
 (0)