chore: import upstream snapshot with attribution
CodeQL / Analyze (csharp) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled

This commit is contained in:
wehub-resource-sync
2026-07-13 13:21:23 +08:00
commit b957a53def
5423 changed files with 863745 additions and 0 deletions
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}