Skip to content

.Net: Add MEVD TestSuiteImplementationTests #12574

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

Merged
merged 1 commit into from
Jul 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
@@ -0,0 +1,15 @@
// Copyright (c) Microsoft. All rights reserved.

using VectorData.ConformanceTests;
using VectorData.ConformanceTests.VectorSearch;

namespace AzureAISearch.ConformanceTests;

public class AzureAISearchTestSuiteImplementationTests : TestSuiteImplementationTests
{
protected override ICollection<Type> IgnoredTestBases { get; } =
[
typeof(VectorSearchDistanceFunctionComplianceTests<>),
typeof(VectorSearchWithFilterConformanceTests<>),
];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) Microsoft. All rights reserved.

using VectorData.ConformanceTests;
using VectorData.ConformanceTests.CRUD;
using VectorData.ConformanceTests.HybridSearch;
using VectorData.ConformanceTests.VectorSearch;

namespace CosmosMongoDB.ConformanceTests;

public class CosmosMongoTestSuiteImplementationTests : TestSuiteImplementationTests
{
protected override ICollection<Type> IgnoredTestBases { get; } =
[
typeof(VectorSearchDistanceFunctionComplianceTests<>),
typeof(VectorSearchWithFilterConformanceTests<>),
typeof(DynamicDataModelConformanceTests<>),

// Hybrid search not supported
typeof(KeywordVectorizedHybridSearchComplianceTests<>),
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

namespace CosmosNoSql.ConformanceTests;

public class CosmosNoSQLEmbeddingGenerationTests(CosmosNoSQLEmbeddingGenerationTests.StringVectorFixture stringVectorFixture, CosmosNoSQLEmbeddingGenerationTests.RomOfFloatVectorFixture romOfFloatVectorFixture)
: EmbeddingGenerationTests<string>(stringVectorFixture, romOfFloatVectorFixture), IClassFixture<CosmosNoSQLEmbeddingGenerationTests.StringVectorFixture>, IClassFixture<CosmosNoSQLEmbeddingGenerationTests.RomOfFloatVectorFixture>
public class CosmosNoSqlEmbeddingGenerationTests(CosmosNoSqlEmbeddingGenerationTests.StringVectorFixture stringVectorFixture, CosmosNoSqlEmbeddingGenerationTests.RomOfFloatVectorFixture romOfFloatVectorFixture)
: EmbeddingGenerationTests<string>(stringVectorFixture, romOfFloatVectorFixture), IClassFixture<CosmosNoSqlEmbeddingGenerationTests.StringVectorFixture>, IClassFixture<CosmosNoSqlEmbeddingGenerationTests.RomOfFloatVectorFixture>
{
public new class StringVectorFixture : EmbeddingGenerationTests<string>.StringVectorFixture
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) Microsoft. All rights reserved.

using VectorData.ConformanceTests;
using VectorData.ConformanceTests.CRUD;
using VectorData.ConformanceTests.VectorSearch;

namespace CosmosNoSql.ConformanceTests;

public class CosmosNoSqlTestSuiteImplementationTests : TestSuiteImplementationTests
{
protected override ICollection<Type> IgnoredTestBases { get; } =
[
typeof(VectorSearchDistanceFunctionComplianceTests<>),
typeof(VectorSearchWithFilterConformanceTests<>),
typeof(DynamicDataModelConformanceTests<>),
typeof(BatchConformanceTests<>)
];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) Microsoft. All rights reserved.

using VectorData.ConformanceTests;
using VectorData.ConformanceTests.HybridSearch;
using VectorData.ConformanceTests.VectorSearch;

namespace InMemory.ConformanceTests;

public class InMemoryTestSuiteImplementationTests : TestSuiteImplementationTests
{
protected override ICollection<Type> IgnoredTestBases { get; } =
[
typeof(DependencyInjectionTests<,,,>),
typeof(VectorSearchDistanceFunctionComplianceTests<>),
typeof(VectorSearchWithFilterConformanceTests<>),

// Hybrid search not supported
typeof(KeywordVectorizedHybridSearchComplianceTests<>)
];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (c) Microsoft. All rights reserved.

using VectorData.ConformanceTests;
using VectorData.ConformanceTests.CRUD;
using VectorData.ConformanceTests.VectorSearch;

namespace MongoDB.ConformanceTests;

public class MongoTestSuiteImplementationTests : TestSuiteImplementationTests
{
protected override ICollection<Type> IgnoredTestBases { get; } =
[
typeof(VectorSearchDistanceFunctionComplianceTests<>),
typeof(VectorSearchWithFilterConformanceTests<>),
typeof(DynamicDataModelConformanceTests<>),
];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) Microsoft. All rights reserved.

using VectorData.ConformanceTests;
using VectorData.ConformanceTests.HybridSearch;
using VectorData.ConformanceTests.VectorSearch;

namespace PgVector.ConformanceTests;

public class PostgresTestSuiteImplementationTests : TestSuiteImplementationTests
{
protected override ICollection<Type> IgnoredTestBases { get; } =
[
typeof(VectorSearchWithFilterConformanceTests<>),

// Hybrid search not supported
typeof(KeywordVectorizedHybridSearchComplianceTests<>)
];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) Microsoft. All rights reserved.

using VectorData.ConformanceTests;
using VectorData.ConformanceTests.HybridSearch;
using VectorData.ConformanceTests.VectorSearch;

namespace Pinecone.ConformanceTests;

public class PineconeTestSuiteImplementationTests : TestSuiteImplementationTests
{
protected override ICollection<Type> IgnoredTestBases { get; } =
[
typeof(VectorSearchWithFilterConformanceTests<>),

// Hybrid search not supported
typeof(KeywordVectorizedHybridSearchComplianceTests<>)
];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (c) Microsoft. All rights reserved.

using VectorData.ConformanceTests;
using VectorData.ConformanceTests.VectorSearch;

namespace Qdrant.ConformanceTests;

public class QdrantTestSuiteImplementationTests : TestSuiteImplementationTests
{
protected override ICollection<Type> IgnoredTestBases { get; } =
[
typeof(VectorSearchDistanceFunctionComplianceTests<>),
typeof(VectorSearchWithFilterConformanceTests<>)
];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) Microsoft. All rights reserved.

using VectorData.ConformanceTests;
using VectorData.ConformanceTests.CRUD;
using VectorData.ConformanceTests.HybridSearch;
using VectorData.ConformanceTests.VectorSearch;

namespace Redis.ConformanceTests;

public class RedisTestSuiteImplementationTests : TestSuiteImplementationTests
{
protected override ICollection<Type> IgnoredTestBases { get; } =
[
typeof(VectorSearchDistanceFunctionComplianceTests<>),
typeof(VectorSearchWithFilterConformanceTests<>),
typeof(BatchConformanceTests<>),

// Hybrid search not supported
typeof(KeywordVectorizedHybridSearchComplianceTests<>)
];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) Microsoft. All rights reserved.

using VectorData.ConformanceTests;
using VectorData.ConformanceTests.HybridSearch;
using VectorData.ConformanceTests.VectorSearch;

namespace SqlServer.ConformanceTests;

public class SqlServerTestSuiteImplementationTests : TestSuiteImplementationTests
{
protected override ICollection<Type> IgnoredTestBases { get; } =
[
typeof(VectorSearchWithFilterConformanceTests<>),

// Hybrid search not supported
typeof(KeywordVectorizedHybridSearchComplianceTests<>)
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#pragma warning disable CA2000 // Dispose objects before losing scope

namespace SqliteIntegrationTests;
namespace SqliteVec.ConformanceTests;

public class SqliteEmbeddingTypeTests(SqliteEmbeddingTypeTests.Fixture fixture)
: EmbeddingTypeTests<string>(fixture), IClassFixture<SqliteEmbeddingTypeTests.Fixture>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) Microsoft. All rights reserved.

using VectorData.ConformanceTests;
using VectorData.ConformanceTests.CRUD;
using VectorData.ConformanceTests.HybridSearch;
using VectorData.ConformanceTests.VectorSearch;

namespace SqliteVec.ConformanceTests;

public class SqliteTestSuiteImplementationTests : TestSuiteImplementationTests
{
protected override ICollection<Type> IgnoredTestBases { get; } =
[
typeof(VectorSearchDistanceFunctionComplianceTests<>),
typeof(DynamicDataModelConformanceTests<>),

// Hybrid search not supported
typeof(KeywordVectorizedHybridSearchComplianceTests<>)
];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// Copyright (c) Microsoft. All rights reserved.

using System.Reflection;
using System.Text.RegularExpressions;
using Xunit;

namespace VectorData.ConformanceTests;

/// <summary>
/// A test that ensures that all base test suites are implemented (or explicitly ignored) in provider implementations.
/// Used to make sure that test coverage is complete.
/// </summary>
public abstract class TestSuiteImplementationTests
{
protected virtual ICollection<Type> IgnoredTestBases { get; } = [];

[Fact]
public virtual void All_test_bases_must_be_implemented()
{
var concreteTests
= this.GetType().Assembly.GetTypes()
.Where(c => c.BaseType != typeof(object) && !c.IsAbstract && (c.IsPublic || c.IsNestedPublic))
.ToList();

var nonImplementedBases
= this.GetBaseTestClasses()
.Where(t => !this.IgnoredTestBases.Contains(t) && !concreteTests.Any(c => Implements(c, t)))
.Select(t => t.FullName)
.ToList();

Assert.False(
nonImplementedBases.Count > 0,
"\r\n-- Missing derived classes for --\r\n" + string.Join(Environment.NewLine, nonImplementedBases));
}

// Filter for abstract base types which end with Tests and possibly generic arity (e.g. FooTests`2)
protected virtual IEnumerable<Type> GetBaseTestClasses()
=> typeof(TestSuiteImplementationTests).Assembly.ExportedTypes
.Where(t => Regex.IsMatch(t.Name, """Tests(`\d+)?$""") && t.IsAbstract && !t.IsSealed && !t.IsInterface);

private static bool Implements(Type type, Type interfaceOrBaseType)
=> (type.IsPublic || type.IsNestedPublic) && interfaceOrBaseType.IsGenericTypeDefinition
? GetGenericTypeImplementations(type, interfaceOrBaseType).Any()
: interfaceOrBaseType.IsAssignableFrom(type);

private static IEnumerable<Type> GetGenericTypeImplementations(Type type, Type interfaceOrBaseType)
{
var typeInfo = type.GetTypeInfo();

if (!typeInfo.IsGenericTypeDefinition)
{
var baseTypes = interfaceOrBaseType.IsInterface
? typeInfo.ImplementedInterfaces
: GetBaseTypes(type);
foreach (var baseType in baseTypes)
{
if (baseType.IsGenericType
&& baseType.GetGenericTypeDefinition() == interfaceOrBaseType)
{
yield return baseType;
}
}

if (type.IsGenericType
&& type.GetGenericTypeDefinition() == interfaceOrBaseType)
{
yield return type;
}
}
}

private static IEnumerable<Type> GetBaseTypes(Type type)
{
var t = type.BaseType;

while (t != null)
{
yield return t;

t = t.BaseType;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright (c) Microsoft. All rights reserved.

using VectorData.ConformanceTests;
using VectorData.ConformanceTests.VectorSearch;

namespace Weaviate.ConformanceTests;

public class WeaviateTestSuiteImplementationTests : TestSuiteImplementationTests
{
protected override ICollection<Type> IgnoredTestBases { get; } =
[
typeof(VectorSearchWithFilterConformanceTests<>)
];
}
Loading