Files
CBDD/tests/CBDD.Tests/VectorSearchTests.cs
Joseph Doherty 3ffd468c79
All checks were successful
NuGet Publish / build-and-pack (push) Successful in 45s
NuGet Publish / publish-to-gitea (push) Successful in 52s
Fix audit findings for coverage, architecture checks, and XML docs
2026-02-20 15:43:25 -05:00

35 lines
1.0 KiB
C#
Executable File

using ZB.MOM.WW.CBDD.Bson;
using ZB.MOM.WW.CBDD.Core;
using ZB.MOM.WW.CBDD.Core.Indexing;
using ZB.MOM.WW.CBDD.Shared;
using Xunit;
namespace ZB.MOM.WW.CBDD.Tests;
public class VectorSearchTests
{
/// <summary>
/// Verifies basic vector-search query behavior.
/// </summary>
[Fact]
public void Test_VectorSearch_Basic()
{
string dbPath = "vector_test.db";
if (File.Exists(dbPath)) File.Delete(dbPath);
using (var db = new Shared.TestDbContext(dbPath))
{
db.VectorItems.Insert(new VectorEntity { Title = "Near", Embedding = [1.0f, 1.0f, 1.0f] });
db.VectorItems.Insert(new VectorEntity { Title = "Far", Embedding = [10.0f, 10.0f, 10.0f] });
var query = new[] { 0.9f, 0.9f, 0.9f };
var results = db.VectorItems.AsQueryable().Where(x => x.Embedding.VectorSearch(query, 1)).ToList();
results.Count().ShouldBe(1);
results[0].Title.ShouldBe("Near");
}
File.Delete(dbPath);
}
}