diff --git a/MEVD/test/SqlServer.ConformanceTests/SqlServer.ConformanceTests.csproj b/MEVD/test/SqlServer.ConformanceTests/SqlServer.ConformanceTests.csproj
index 09fc18c..c529ebf 100644
--- a/MEVD/test/SqlServer.ConformanceTests/SqlServer.ConformanceTests.csproj
+++ b/MEVD/test/SqlServer.ConformanceTests/SqlServer.ConformanceTests.csproj
@@ -11,11 +11,6 @@
b7762d10-e29b-4bb1-8b74-b6d69a667dd4
-
-
-
-
-
diff --git a/MEVD/test/SqlServer.ConformanceTests/SqlServerHybridSearchTests.cs b/MEVD/test/SqlServer.ConformanceTests/SqlServerHybridSearchTests.cs
index 913a163..757f3d4 100644
--- a/MEVD/test/SqlServer.ConformanceTests/SqlServerHybridSearchTests.cs
+++ b/MEVD/test/SqlServer.ConformanceTests/SqlServerHybridSearchTests.cs
@@ -8,20 +8,56 @@
namespace SqlServer.ConformanceTests;
+// The HybridSearch tests require running against Azure SQL.
+// The fixtures do not create their collections elsewhere, and each test is skipped.
public class SqlServerHybridSearchTests(
SqlServerHybridSearchTests.VectorAndStringFixture vectorAndStringFixture,
SqlServerHybridSearchTests.MultiTextFixture multiTextFixture)
: HybridSearchTests(vectorAndStringFixture, multiTextFixture),
IClassFixture,
- IClassFixture
+ IClassFixture,
+ IAsyncLifetime
{
+ async ValueTask IAsyncLifetime.InitializeAsync()
+ => await AzureSqlHelper.SkipUnlessAzureSqlAsync();
+
+ ValueTask IAsyncDisposable.DisposeAsync() => default;
+
public new class VectorAndStringFixture : HybridSearchTests.VectorAndStringFixture
{
+ private bool _initialized;
+
public override TestStore TestStore => SqlServerTestStore.Instance;
+
+ public override async ValueTask InitializeAsync()
+ {
+ if (await AzureSqlHelper.GetIsAzureSqlAsync())
+ {
+ await base.InitializeAsync();
+ this._initialized = true;
+ }
+ }
+
+ public override ValueTask DisposeAsync()
+ => this._initialized ? base.DisposeAsync() : default;
}
public new class MultiTextFixture : HybridSearchTests.MultiTextFixture
{
+ private bool _initialized;
+
public override TestStore TestStore => SqlServerTestStore.Instance;
+
+ public override async ValueTask InitializeAsync()
+ {
+ if (await AzureSqlHelper.GetIsAzureSqlAsync())
+ {
+ await base.InitializeAsync();
+ this._initialized = true;
+ }
+ }
+
+ public override ValueTask DisposeAsync()
+ => this._initialized ? base.DisposeAsync() : default;
}
}
diff --git a/MEVD/test/SqlServer.ConformanceTests/SqlServerIndexKindTests.cs b/MEVD/test/SqlServer.ConformanceTests/SqlServerIndexKindTests.cs
index f15111d..66e4ac7 100644
--- a/MEVD/test/SqlServer.ConformanceTests/SqlServerIndexKindTests.cs
+++ b/MEVD/test/SqlServer.ConformanceTests/SqlServerIndexKindTests.cs
@@ -19,11 +19,7 @@ public class SqlServerIndexKindTests(SqlServerIndexKindTests.Fixture fixture)
[Fact]
public virtual async Task DiskAnn()
{
- // This test should be conditional (https://github.com/dotnet/extensions/issues/7605)
- if (!await AzureSqlHelper.GetIsAzureSqlAsync())
- {
- return;
- }
+ await AzureSqlHelper.SkipUnlessAzureSqlAsync();
const string CollectionName = "IndexKindTests_DiskAnn";
diff --git a/MEVD/test/SqlServer.ConformanceTests/SqlServerTestSuiteImplementationTests.cs b/MEVD/test/SqlServer.ConformanceTests/SqlServerTestSuiteImplementationTests.cs
index ff30635..fb2820f 100644
--- a/MEVD/test/SqlServer.ConformanceTests/SqlServerTestSuiteImplementationTests.cs
+++ b/MEVD/test/SqlServer.ConformanceTests/SqlServerTestSuiteImplementationTests.cs
@@ -5,11 +5,4 @@
namespace SqlServer.ConformanceTests;
-public class SqlServerTestSuiteImplementationTests : TestSuiteImplementationTests
-{
- protected override ICollection IgnoredTestBases { get; } =
- [
- // Hybrid search not supported
- typeof(HybridSearchTests<>)
- ];
-}
+public class SqlServerTestSuiteImplementationTests : TestSuiteImplementationTests;
diff --git a/MEVD/test/SqlServer.ConformanceTests/Support/AzureSqlRequiredAttribute.cs b/MEVD/test/SqlServer.ConformanceTests/Support/AzureSqlRequiredAttribute.cs
index 7d7b4bc..ad05848 100644
--- a/MEVD/test/SqlServer.ConformanceTests/Support/AzureSqlRequiredAttribute.cs
+++ b/MEVD/test/SqlServer.ConformanceTests/Support/AzureSqlRequiredAttribute.cs
@@ -13,13 +13,23 @@ internal static class AzureSqlHelper
{
private static bool? s_isAzureSql;
+ public static async Task SkipUnlessAzureSqlAsync()
+ => Assert.SkipUnless(
+ await GetIsAzureSqlAsync(),
+ "This test requires Azure SQL Database or SQL database in Microsoft Fabric.");
+
public static async Task GetIsAzureSqlAsync()
{
if (s_isAzureSql is null)
{
- var connectionString = SqlServerTestStore.Instance.ConnectionString;
-
- using SqlConnection connection = new(connectionString);
+ // Without a connection string the tests run against the SQL Server testcontainer.
+ if (!SqlServerTestEnvironment.IsConnectionStringDefined)
+ {
+ s_isAzureSql = false;
+ return false;
+ }
+
+ using SqlConnection connection = new(SqlServerTestEnvironment.ConnectionString);
await connection.OpenAsync();
using var command = connection.CreateCommand();