Skip to content

Commit beb66ce

Browse files
committed
WIP
1 parent 28216ac commit beb66ce

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

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

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33

44
using System.Collections.Generic;
55
using System.Globalization;
6+
using System.IO;
67

78
namespace System.Data.OleDb.Tests
89
{
910
public static class Helpers
1011
{
1112
public const string IsDriverAvailable = nameof(Helpers) + "." + nameof(GetIsDriverAvailable);
12-
public const string IsAceDriverAvailable = nameof(Helpers) + "." + nameof(GetIsAceDriverAvailable);
1313
public static bool GetIsDriverAvailable() => Nested.IsAvailable;
14-
public static bool GetIsAceDriverAvailable() => GetIsDriverAvailable() && !PlatformDetection.Is32BitProcess;
1514
public static string ProviderName => Nested.ProviderName;
1615
public static string GetTableName(string memberName) => memberName + ".csv";
1716

@@ -21,25 +20,34 @@ private class Nested
2120
public static readonly string ProviderName;
2221
public static Nested Instance => s_instance;
2322
private static readonly Nested s_instance = new Nested();
24-
private const string ExpectedProviderName = @"Microsoft.ACE.OLEDB.12.0";
2523
private Nested() { }
2624
static Nested()
2725
{
2826
// Get the sources rowset for the SQLOLEDB enumerator
2927
DataTable table = (new OleDbEnumerator()).GetElements();
3028
DataColumn providersRegistered = table.Columns["SOURCES_NAME"];
31-
List<object> providerNames = new List<object>();
29+
List<string> providerNames = new List<string>();
3230
foreach (DataRow row in table.Rows)
3331
{
3432
providerNames.Add((string)row[providersRegistered]);
3533
}
34+
3635
// skip if x86 or if the expected driver not available
37-
IsAvailable = !PlatformDetection.Is32BitProcess && providerNames.Contains(ExpectedProviderName);
38-
if (!CultureInfo.CurrentCulture.Name.Equals("en-US", StringComparison.OrdinalIgnoreCase))
36+
//IsAvailable = !PlatformDetection.Is32BitProcess && providerNames.Contains(ExpectedProviderName);
37+
// For the following culture check: https://github.com/dotnet/runtime/issues/29969
38+
if (CultureInfo.CurrentCulture.Name.Equals("en-US", StringComparison.OrdinalIgnoreCase))
3939
{
40-
IsAvailable = false; // ActiveIssue: https://github.com/dotnet/runtime/issues/29969
40+
ProviderName = providerNames.Contains("MSOLEDBSQL19")
41+
? "MSOLEDBSQL19"
42+
: providerNames.Contains("MSOLEDBSQL")
43+
? "MSOLEDBSQL"
44+
: null;
45+
46+
if (ProviderName is not null)
47+
{
48+
IsAvailable = true;
49+
}
4150
}
42-
ProviderName = IsAvailable ? ExpectedProviderName : null;
4351
}
4452
}
4553
}

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)