Reformat / cleanup
All checks were successful
NuGet Publish / build-and-pack (push) Successful in 46s
NuGet Publish / publish-to-gitea (push) Successful in 56s

This commit is contained in:
Joseph Doherty
2026-02-21 08:10:36 -05:00
parent 4c6aaa5a3f
commit a70d8befae
176 changed files with 50555 additions and 49587 deletions

View File

@@ -5,20 +5,31 @@ namespace ZB.MOM.WW.CBDD.Tests;
public class DocumentCollectionIndexApiTests : IDisposable
{
private readonly TestDbContext _db;
private readonly string _dbPath;
private readonly Shared.TestDbContext _db;
/// <summary>
/// Initializes a new instance of the <see cref="DocumentCollectionIndexApiTests"/> class.
/// Initializes a new instance of the <see cref="DocumentCollectionIndexApiTests" /> class.
/// </summary>
public DocumentCollectionIndexApiTests()
{
_dbPath = Path.Combine(Path.GetTempPath(), $"collection_index_api_{Guid.NewGuid():N}.db");
_db = new Shared.TestDbContext(_dbPath);
_db = new TestDbContext(_dbPath);
}
/// <summary>
/// Verifies vector index creation and deletion behavior.
/// Disposes test resources and removes temporary files.
/// </summary>
public void Dispose()
{
_db.Dispose();
if (File.Exists(_dbPath)) File.Delete(_dbPath);
string wal = Path.ChangeExtension(_dbPath, ".wal");
if (File.Exists(wal)) File.Delete(wal);
}
/// <summary>
/// Verifies vector index creation and deletion behavior.
/// </summary>
[Fact]
public void CreateVectorIndex_And_DropIndex_Should_Work()
@@ -39,34 +50,23 @@ public class DocumentCollectionIndexApiTests : IDisposable
}
/// <summary>
/// Verifies ensure-index returns existing indexes when already present.
/// Verifies ensure-index returns existing indexes when already present.
/// </summary>
[Fact]
public void EnsureIndex_Should_Return_Existing_Index_When_Already_Present()
{
var first = _db.People.EnsureIndex(p => p.Age, name: "idx_people_age");
var second = _db.People.EnsureIndex(p => p.Age, name: "idx_people_age");
var first = _db.People.EnsureIndex(p => p.Age, "idx_people_age");
var second = _db.People.EnsureIndex(p => p.Age, "idx_people_age");
ReferenceEquals(first, second).ShouldBeTrue();
}
/// <summary>
/// Verifies dropping the primary index name is rejected.
/// Verifies dropping the primary index name is rejected.
/// </summary>
[Fact]
public void DropIndex_Should_Reject_Primary_Index_Name()
{
Should.Throw<InvalidOperationException>(() => _db.People.DropIndex("_id"));
}
/// <summary>
/// Disposes test resources and removes temporary files.
/// </summary>
public void Dispose()
{
_db.Dispose();
if (File.Exists(_dbPath)) File.Delete(_dbPath);
var wal = Path.ChangeExtension(_dbPath, ".wal");
if (File.Exists(wal)) File.Delete(wal);
}
}
}