chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net10.0;net472</TargetFrameworks>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
<IsPackable>false</IsPackable>
|
||||
<RootNamespace>InMemory.ConformanceTests</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="xunit" />
|
||||
<PackageReference Include="xunit.runner.visualstudio">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" />
|
||||
<PackageReference Include="System.Linq.AsyncEnumerable" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\src\VectorData\InMemory\InMemory.csproj" />
|
||||
<ProjectReference Include="..\VectorData.ConformanceTests\VectorData.ConformanceTests.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,12 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
using InMemory.ConformanceTests.Support;
|
||||
using VectorData.ConformanceTests;
|
||||
using Xunit;
|
||||
|
||||
namespace InMemory.ConformanceTests;
|
||||
|
||||
public class InMemoryCollectionManagementTests(InMemoryFixture fixture)
|
||||
: CollectionManagementTests<string>(fixture), IClassFixture<InMemoryFixture>
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
using InMemory.ConformanceTests.Support;
|
||||
using VectorData.ConformanceTests;
|
||||
using VectorData.ConformanceTests.Support;
|
||||
using Xunit;
|
||||
|
||||
namespace InMemory.ConformanceTests;
|
||||
|
||||
public class InMemoryDistanceFunctionTests(InMemoryDistanceFunctionTests.Fixture fixture)
|
||||
: DistanceFunctionTests<int>(fixture), IClassFixture<InMemoryDistanceFunctionTests.Fixture>
|
||||
{
|
||||
public override Task EuclideanSquaredDistance() => Assert.ThrowsAsync<NotSupportedException>(base.EuclideanSquaredDistance);
|
||||
public override Task NegativeDotProductSimilarity() => Assert.ThrowsAsync<NotSupportedException>(base.NegativeDotProductSimilarity);
|
||||
public override Task HammingDistance() => Assert.ThrowsAsync<NotSupportedException>(base.HammingDistance);
|
||||
public override Task ManhattanDistance() => Assert.ThrowsAsync<NotSupportedException>(base.ManhattanDistance);
|
||||
|
||||
public new class Fixture() : DistanceFunctionTests<int>.Fixture
|
||||
{
|
||||
public override TestStore TestStore => InMemoryTestStore.Instance;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
using InMemory.ConformanceTests.Support;
|
||||
using Microsoft.Extensions.AI;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.VectorData;
|
||||
using VectorData.ConformanceTests;
|
||||
using VectorData.ConformanceTests.Support;
|
||||
using Xunit;
|
||||
|
||||
namespace InMemory.ConformanceTests;
|
||||
|
||||
public class InMemoryEmbeddingGenerationTests(InMemoryEmbeddingGenerationTests.StringVectorFixture stringVectorFixture, InMemoryEmbeddingGenerationTests.RomOfFloatVectorFixture romOfFloatVectorFixture)
|
||||
: EmbeddingGenerationTests<int>(stringVectorFixture, romOfFloatVectorFixture), IClassFixture<InMemoryEmbeddingGenerationTests.StringVectorFixture>, IClassFixture<InMemoryEmbeddingGenerationTests.RomOfFloatVectorFixture>
|
||||
{
|
||||
// InMemory doesn't allowing accessing the same collection via different .NET types (it's unique in this).
|
||||
// The following dynamic tests attempt to access the fixture collection - which is created with Record - via
|
||||
// Dictionary<string, object?>.
|
||||
public override Task SearchAsync_with_property_generator_dynamic() => Task.CompletedTask;
|
||||
public override Task UpsertAsync_dynamic() => Task.CompletedTask;
|
||||
public override Task UpsertAsync_batch_dynamic() => Task.CompletedTask;
|
||||
|
||||
// The same applies to the custom type test:
|
||||
public override Task SearchAsync_with_custom_input_type() => Task.CompletedTask;
|
||||
|
||||
// The test relies on creating a new InMemoryVectorStore configured with a store-default generator, but with InMemory that store
|
||||
// doesn't share the seeded data with the fixture store (since each InMemoryVectorStore has its own private data).
|
||||
// Test coverage is already largely sufficient via the property and collection tests.
|
||||
public override Task SearchAsync_with_store_generator() => Task.CompletedTask;
|
||||
|
||||
public new class StringVectorFixture : EmbeddingGenerationTests<int>.StringVectorFixture
|
||||
{
|
||||
public override TestStore TestStore => InMemoryTestStore.Instance;
|
||||
|
||||
// Note that with InMemory specifically, we can't create a vector store with an embedding generator, since it wouldn't share the seeded data with the fixture store.
|
||||
public override VectorStore CreateVectorStore(IEmbeddingGenerator? embeddingGenerator)
|
||||
=> InMemoryTestStore.Instance.DefaultVectorStore;
|
||||
|
||||
public override Func<IServiceCollection, IServiceCollection>[] DependencyInjectionStoreRegistrationDelegates =>
|
||||
[
|
||||
// The InMemory DI methods register a new vector store instance, which doesn't share the collection seeded by the
|
||||
// fixture and the test fails.
|
||||
// services => services.AddInMemoryVectorStore()
|
||||
];
|
||||
|
||||
public override Func<IServiceCollection, IServiceCollection>[] DependencyInjectionCollectionRegistrationDelegates =>
|
||||
[
|
||||
// The InMemory DI methods register a new vector store instance, which doesn't share the collection seeded by the
|
||||
// fixture and the test fails.
|
||||
// services => services.AddInMemoryVectorStoreRecordCollection<int, RecordWithAttributes>(this.CollectionName)
|
||||
];
|
||||
}
|
||||
|
||||
public new class RomOfFloatVectorFixture : EmbeddingGenerationTests<int>.RomOfFloatVectorFixture
|
||||
{
|
||||
public override TestStore TestStore => InMemoryTestStore.Instance;
|
||||
|
||||
// Note that with InMemory specifically, we can't create a vector store with an embedding generator, since it wouldn't share the seeded data with the fixture store.
|
||||
public override VectorStore CreateVectorStore(IEmbeddingGenerator? embeddingGenerator)
|
||||
=> InMemoryTestStore.Instance.DefaultVectorStore;
|
||||
|
||||
public override Func<IServiceCollection, IServiceCollection>[] DependencyInjectionStoreRegistrationDelegates =>
|
||||
[
|
||||
// The InMemory DI methods register a new vector store instance, which doesn't share the collection seeded by the
|
||||
// fixture and the test fails.
|
||||
// services => services.AddInMemoryVectorStore()
|
||||
];
|
||||
|
||||
public override Func<IServiceCollection, IServiceCollection>[] DependencyInjectionCollectionRegistrationDelegates =>
|
||||
[
|
||||
// The InMemory DI methods register a new vector store instance, which doesn't share the collection seeded by the
|
||||
// fixture and the test fails.
|
||||
// services => services.AddInMemoryVectorStoreRecordCollection<int, RecordWithAttributes>(this.CollectionName)
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
using InMemory.ConformanceTests.Support;
|
||||
using VectorData.ConformanceTests;
|
||||
using VectorData.ConformanceTests.Support;
|
||||
using Xunit;
|
||||
|
||||
namespace InMemory.ConformanceTests;
|
||||
|
||||
public class InMemoryFilterTests(InMemoryFilterTests.Fixture fixture)
|
||||
: FilterTests<int>(fixture), IClassFixture<InMemoryFilterTests.Fixture>
|
||||
{
|
||||
public new class Fixture : FilterTests<int>.Fixture
|
||||
{
|
||||
public override TestStore TestStore => InMemoryTestStore.Instance;
|
||||
|
||||
// BaseFilterTests attempts to create two InMemoryVectorStoreRecordCollection with different .NET types:
|
||||
// 1. One for strongly-typed mapping (TRecord=FilterRecord)
|
||||
// 2. One for dynamic mapping (TRecord=Dictionary<string, object?>)
|
||||
// Unfortunately, InMemoryVectorStore does not allow mapping the same collection name to different types;
|
||||
// at the same time, it simply evaluates all filtering via .NET AsQueryable(), so actual test coverage
|
||||
// isn't very important here. So we disable the dynamic tests.
|
||||
public override bool TestDynamic => false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
using InMemory.ConformanceTests.Support;
|
||||
using VectorData.ConformanceTests;
|
||||
using VectorData.ConformanceTests.Support;
|
||||
using Xunit;
|
||||
|
||||
namespace InMemory.ConformanceTests;
|
||||
|
||||
public class InMemoryIndexKindTests(InMemoryIndexKindTests.Fixture fixture)
|
||||
: IndexKindTests<int>(fixture), IClassFixture<InMemoryIndexKindTests.Fixture>
|
||||
{
|
||||
public new class Fixture() : IndexKindTests<int>.Fixture
|
||||
{
|
||||
public override TestStore TestStore => InMemoryTestStore.Instance;
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
using VectorData.ConformanceTests;
|
||||
|
||||
namespace InMemory.ConformanceTests;
|
||||
|
||||
public class InMemoryTestSuiteImplementationTests : TestSuiteImplementationTests
|
||||
{
|
||||
protected override ICollection<Type> IgnoredTestBases { get; } =
|
||||
[
|
||||
typeof(DependencyInjectionTests<,,,>),
|
||||
typeof(DependencyInjectionTests<>),
|
||||
|
||||
// Hybrid search not supported
|
||||
typeof(HybridSearchTests<>)
|
||||
];
|
||||
}
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
using InMemory.ConformanceTests.Support;
|
||||
using VectorData.ConformanceTests.ModelTests;
|
||||
using VectorData.ConformanceTests.Support;
|
||||
using Xunit;
|
||||
|
||||
namespace InMemory.ConformanceTests.ModelTests;
|
||||
|
||||
public class InMemoryBasicModelTests(InMemoryBasicModelTests.Fixture fixture)
|
||||
: BasicModelTests<int>(fixture), IClassFixture<InMemoryBasicModelTests.Fixture>
|
||||
{
|
||||
public override async Task GetAsync_single_record(bool includeVectors)
|
||||
{
|
||||
if (includeVectors)
|
||||
{
|
||||
await base.GetAsync_single_record(includeVectors);
|
||||
return;
|
||||
}
|
||||
|
||||
// InMemory always returns the vectors (IncludeVectors = false isn't respected)
|
||||
var expectedRecord = fixture.TestData[0];
|
||||
var received = await fixture.Collection.GetAsync(expectedRecord.Key, new() { IncludeVectors = false });
|
||||
|
||||
expectedRecord.AssertEqual(received, includeVectors: true, fixture.TestStore.VectorsComparable);
|
||||
}
|
||||
|
||||
public override async Task GetAsync_multiple_records(bool includeVectors)
|
||||
{
|
||||
if (includeVectors)
|
||||
{
|
||||
await base.GetAsync_multiple_records(includeVectors);
|
||||
return;
|
||||
}
|
||||
|
||||
// InMemory always returns the vectors (IncludeVectors = false isn't respected)
|
||||
var expectedRecords = fixture.TestData.Take(2); // the last two records can get deleted by other tests
|
||||
var ids = expectedRecords.Select(record => record.Key);
|
||||
|
||||
var received = await fixture.Collection.GetAsync(ids, new() { IncludeVectors = false }).ToArrayAsync();
|
||||
|
||||
foreach (var record in expectedRecords)
|
||||
{
|
||||
record.AssertEqual(
|
||||
received.Single(r => r.Key.Equals(record.Key)),
|
||||
includeVectors: true,
|
||||
fixture.TestStore.VectorsComparable);
|
||||
}
|
||||
}
|
||||
|
||||
public override async Task GetAsync_with_filter(bool includeVectors)
|
||||
{
|
||||
if (includeVectors)
|
||||
{
|
||||
await base.GetAsync_with_filter(includeVectors);
|
||||
return;
|
||||
}
|
||||
|
||||
// InMemory always returns the vectors (IncludeVectors = false isn't respected)
|
||||
var expectedRecord = fixture.TestData[0];
|
||||
|
||||
var results = await this.Collection.GetAsync(
|
||||
r => r.Number == 1,
|
||||
top: 2,
|
||||
new() { IncludeVectors = includeVectors })
|
||||
.ToListAsync();
|
||||
|
||||
var receivedRecord = Assert.Single(results);
|
||||
expectedRecord.AssertEqual(receivedRecord, includeVectors: true, fixture.TestStore.VectorsComparable);
|
||||
}
|
||||
|
||||
public new class Fixture : BasicModelTests<int>.Fixture
|
||||
{
|
||||
public override TestStore TestStore => InMemoryTestStore.Instance;
|
||||
}
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
using InMemory.ConformanceTests.Support;
|
||||
using VectorData.ConformanceTests.ModelTests;
|
||||
using VectorData.ConformanceTests.Support;
|
||||
using Xunit;
|
||||
|
||||
namespace InMemory.ConformanceTests.ModelTests;
|
||||
|
||||
public class InMemoryDynamicModelTests(InMemoryDynamicModelTests.Fixture fixture)
|
||||
: DynamicModelTests<int>(fixture), IClassFixture<InMemoryDynamicModelTests.Fixture>
|
||||
{
|
||||
public override async Task GetAsync_single_record(bool includeVectors)
|
||||
{
|
||||
if (includeVectors)
|
||||
{
|
||||
await base.GetAsync_single_record(includeVectors);
|
||||
return;
|
||||
}
|
||||
|
||||
// InMemory always returns the vectors (IncludeVectors = false isn't respected)
|
||||
var expectedRecord = fixture.TestData[0];
|
||||
var received = await fixture.Collection.GetAsync(
|
||||
(int)expectedRecord[KeyPropertyName]!,
|
||||
new() { IncludeVectors = false });
|
||||
|
||||
AssertEquivalent(expectedRecord, received, includeVectors: true, fixture.TestStore.VectorsComparable);
|
||||
}
|
||||
|
||||
public override async Task GetAsync_multiple_records(bool includeVectors)
|
||||
{
|
||||
if (includeVectors)
|
||||
{
|
||||
await base.GetAsync_multiple_records(includeVectors);
|
||||
return;
|
||||
}
|
||||
|
||||
// InMemory always returns the vectors (IncludeVectors = false isn't respected)
|
||||
var expectedRecords = fixture.TestData.Take(2);
|
||||
var ids = expectedRecords.Select(record => record[KeyPropertyName]!);
|
||||
|
||||
var received = await fixture.Collection.GetAsync(ids, new() { IncludeVectors = false }).ToArrayAsync();
|
||||
|
||||
foreach (var record in expectedRecords)
|
||||
{
|
||||
AssertEquivalent(
|
||||
record,
|
||||
received.Single(r => r[KeyPropertyName]!.Equals(record[KeyPropertyName])),
|
||||
includeVectors: true,
|
||||
fixture.TestStore.VectorsComparable);
|
||||
}
|
||||
}
|
||||
|
||||
public override async Task GetAsync_with_filter(bool includeVectors)
|
||||
{
|
||||
if (includeVectors)
|
||||
{
|
||||
await base.GetAsync_with_filter(includeVectors);
|
||||
return;
|
||||
}
|
||||
|
||||
// InMemory always returns the vectors (IncludeVectors = false isn't respected)
|
||||
var expectedRecord = fixture.TestData[0];
|
||||
|
||||
var results = await fixture.Collection.GetAsync(
|
||||
r => (int)r[IntegerPropertyName]! == 1,
|
||||
top: 2,
|
||||
new() { IncludeVectors = includeVectors })
|
||||
.ToListAsync();
|
||||
|
||||
var receivedRecord = Assert.Single(results);
|
||||
AssertEquivalent(expectedRecord, receivedRecord, includeVectors: true, fixture.TestStore.VectorsComparable);
|
||||
}
|
||||
|
||||
public new class Fixture : DynamicModelTests<int>.Fixture
|
||||
{
|
||||
public override TestStore TestStore => InMemoryTestStore.Instance;
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
using InMemory.ConformanceTests.Support;
|
||||
using VectorData.ConformanceTests.ModelTests;
|
||||
using VectorData.ConformanceTests.Support;
|
||||
using Xunit;
|
||||
|
||||
namespace InMemory.ConformanceTests.ModelTests;
|
||||
|
||||
public class InMemoryMultiVectorModelTests(InMemoryMultiVectorModelTests.Fixture fixture)
|
||||
: MultiVectorModelTests<string>(fixture), IClassFixture<InMemoryMultiVectorModelTests.Fixture>
|
||||
{
|
||||
public new class Fixture : MultiVectorModelTests<string>.Fixture
|
||||
{
|
||||
public override TestStore TestStore => InMemoryTestStore.Instance;
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
using InMemory.ConformanceTests.Support;
|
||||
using VectorData.ConformanceTests.ModelTests;
|
||||
using VectorData.ConformanceTests.Support;
|
||||
using Xunit;
|
||||
|
||||
namespace InMemory.ConformanceTests.ModelTests;
|
||||
|
||||
public class InMemoryNoDataModelTests(InMemoryNoDataModelTests.Fixture fixture)
|
||||
: NoDataModelTests<string>(fixture), IClassFixture<InMemoryNoDataModelTests.Fixture>
|
||||
{
|
||||
public new class Fixture : NoDataModelTests<string>.Fixture
|
||||
{
|
||||
public override TestStore TestStore => InMemoryTestStore.Instance;
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
using InMemory.ConformanceTests.Support;
|
||||
using VectorData.ConformanceTests.ModelTests;
|
||||
using VectorData.ConformanceTests.Support;
|
||||
using Xunit;
|
||||
|
||||
namespace InMemory.ConformanceTests.ModelTests;
|
||||
|
||||
public class InMemoryNoVectorModelTests(InMemoryNoVectorModelTests.Fixture fixture)
|
||||
: NoVectorModelTests<string>(fixture), IClassFixture<InMemoryNoVectorModelTests.Fixture>
|
||||
{
|
||||
public new class Fixture : NoVectorModelTests<string>.Fixture
|
||||
{
|
||||
public override TestStore TestStore => InMemoryTestStore.Instance;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
using VectorData.ConformanceTests.Support;
|
||||
|
||||
namespace InMemory.ConformanceTests.Support;
|
||||
|
||||
public class InMemoryFixture : VectorStoreFixture
|
||||
{
|
||||
public override TestStore TestStore => InMemoryTestStore.Instance;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
using Microsoft.SemanticKernel.Connectors.InMemory;
|
||||
using VectorData.ConformanceTests.Support;
|
||||
|
||||
namespace InMemory.ConformanceTests.Support;
|
||||
|
||||
internal sealed class InMemoryTestStore : TestStore
|
||||
{
|
||||
public static InMemoryTestStore Instance { get; } = new();
|
||||
|
||||
public InMemoryVectorStore GetVectorStore(InMemoryVectorStoreOptions options)
|
||||
=> new(new() { EmbeddingGenerator = options.EmbeddingGenerator });
|
||||
|
||||
private InMemoryTestStore()
|
||||
{
|
||||
}
|
||||
|
||||
protected override Task StartAsync()
|
||||
{
|
||||
this.DefaultVectorStore = new InMemoryVectorStore();
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
using InMemory.ConformanceTests.Support;
|
||||
using VectorData.ConformanceTests.Support;
|
||||
using VectorData.ConformanceTests.TypeTests;
|
||||
using Xunit;
|
||||
|
||||
namespace InMemory.ConformanceTests.TypeTests;
|
||||
|
||||
public class InMemoryDataTypeTests(InMemoryDataTypeTests.Fixture fixture)
|
||||
: DataTypeTests<string, DataTypeTests<string>.DefaultRecord>(fixture), IClassFixture<InMemoryDataTypeTests.Fixture>
|
||||
{
|
||||
public new class Fixture : DataTypeTests<string, DataTypeTests<string>.DefaultRecord>.Fixture
|
||||
{
|
||||
public override TestStore TestStore => InMemoryTestStore.Instance;
|
||||
|
||||
public override Type[] UnsupportedDefaultTypes { get; } = [];
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
using InMemory.ConformanceTests.Support;
|
||||
using VectorData.ConformanceTests.Support;
|
||||
using VectorData.ConformanceTests.TypeTests;
|
||||
using Xunit;
|
||||
|
||||
#pragma warning disable CA2000 // Dispose objects before losing scope
|
||||
|
||||
namespace InMemory.ConformanceTests.TypeTests;
|
||||
|
||||
public class InMemoryEmbeddingTypeTests(InMemoryEmbeddingTypeTests.Fixture fixture)
|
||||
: EmbeddingTypeTests<Guid>(fixture), IClassFixture<InMemoryEmbeddingTypeTests.Fixture>
|
||||
{
|
||||
public new class Fixture : EmbeddingTypeTests<Guid>.Fixture
|
||||
{
|
||||
public override TestStore TestStore => InMemoryTestStore.Instance;
|
||||
|
||||
public override bool RecreateCollection => true;
|
||||
public override bool AssertNoVectorsLoadedWithEmbeddingGeneration => false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
using InMemory.ConformanceTests.Support;
|
||||
using VectorData.ConformanceTests.Support;
|
||||
using VectorData.ConformanceTests.TypeTests;
|
||||
using VectorData.ConformanceTests.Xunit;
|
||||
using Xunit;
|
||||
|
||||
namespace InMemory.ConformanceTests.TypeTests;
|
||||
|
||||
public class InMemoryKeyTypeTests(InMemoryKeyTypeTests.Fixture fixture)
|
||||
: KeyTypeTests(fixture), IClassFixture<InMemoryKeyTypeTests.Fixture>
|
||||
{
|
||||
// The InMemory provider supports all .NET types as keys; below are just a few basic tests.
|
||||
|
||||
[ConditionalFact]
|
||||
public virtual Task Int() => this.Test<int>(8, 9);
|
||||
|
||||
[ConditionalFact]
|
||||
public virtual Task Long() => this.Test<long>(8L, 9L);
|
||||
|
||||
[ConditionalFact]
|
||||
public virtual Task String() => this.Test<string>("foo", "bar");
|
||||
|
||||
protected override async Task Test<TKey>(TKey key1, TKey key2, bool supportsAutoGeneration = false)
|
||||
{
|
||||
await base.Test(key1, key2, supportsAutoGeneration);
|
||||
|
||||
// For InMemory, delete the collection, otherwise the next test that runs will fail because the collection
|
||||
// already exists but with the previous key type.
|
||||
using var collection = fixture.CreateCollection<TKey>(supportsAutoGeneration);
|
||||
await collection.EnsureCollectionDeletedAsync();
|
||||
}
|
||||
|
||||
public new class Fixture : KeyTypeTests.Fixture
|
||||
{
|
||||
public override TestStore TestStore => InMemoryTestStore.Instance;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user