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

@@ -8,20 +8,20 @@ namespace ZB.MOM.WW.CBDD.Tests;
public class CollectionIndexManagerAndDefinitionTests
{
/// <summary>
/// Tests find best index should prefer unique index.
/// Tests find best index should prefer unique index.
/// </summary>
[Fact]
public void FindBestIndex_Should_Prefer_Unique_Index()
{
var dbPath = NewDbPath();
string dbPath = NewDbPath();
try
{
using var storage = new StorageEngine(dbPath, PageFileConfig.Default);
var mapper = new ZB_MOM_WW_CBDD_Shared_PersonMapper();
using var manager = new CollectionIndexManager<int, Person>(storage, mapper, "people_idx_pref_unique");
manager.CreateIndex(p => p.Age, name: "idx_age", unique: false);
manager.CreateIndex(p => p.Age, name: "idx_age_unique", unique: true);
manager.CreateIndex(p => p.Age, "idx_age");
manager.CreateIndex(p => p.Age, "idx_age_unique", true);
var best = manager.FindBestIndex("Age");
@@ -36,12 +36,12 @@ public class CollectionIndexManagerAndDefinitionTests
}
/// <summary>
/// Tests find best compound index should choose longest prefix.
/// Tests find best compound index should choose longest prefix.
/// </summary>
[Fact]
public void FindBestCompoundIndex_Should_Choose_Longest_Prefix()
{
var dbPath = NewDbPath();
string dbPath = NewDbPath();
try
{
using var storage = new StorageEngine(dbPath, PageFileConfig.Default);
@@ -76,12 +76,12 @@ public class CollectionIndexManagerAndDefinitionTests
}
/// <summary>
/// Tests drop index should remove metadata and be idempotent.
/// Tests drop index should remove metadata and be idempotent.
/// </summary>
[Fact]
public void DropIndex_Should_Remove_Metadata_And_Be_Idempotent()
{
var dbPath = NewDbPath();
string dbPath = NewDbPath();
const string collectionName = "people_idx_drop";
try
@@ -91,7 +91,7 @@ public class CollectionIndexManagerAndDefinitionTests
using (var manager = new CollectionIndexManager<int, Person>(storage, mapper, collectionName))
{
manager.CreateIndex(p => p.Age, name: "idx_age", unique: false);
manager.CreateIndex(p => p.Age, "idx_age");
manager.DropIndex("idx_age").ShouldBeTrue();
manager.DropIndex("idx_age").ShouldBeFalse();
manager.GetIndexInfo().ShouldBeEmpty();
@@ -107,7 +107,7 @@ public class CollectionIndexManagerAndDefinitionTests
}
/// <summary>
/// Tests collection index definition should respect query support rules.
/// Tests collection index definition should respect query support rules.
/// </summary>
[Fact]
public void CollectionIndexDefinition_Should_Respect_Query_Support_Rules()
@@ -129,7 +129,7 @@ public class CollectionIndexManagerAndDefinitionTests
}
/// <summary>
/// Tests collection index info to string should include diagnostics.
/// Tests collection index info to string should include diagnostics.
/// </summary>
[Fact]
public void CollectionIndexInfo_ToString_Should_Include_Diagnostics()
@@ -150,16 +150,18 @@ public class CollectionIndexManagerAndDefinitionTests
}
private static string NewDbPath()
=> Path.Combine(Path.GetTempPath(), $"idx_mgr_{Guid.NewGuid():N}.db");
{
return Path.Combine(Path.GetTempPath(), $"idx_mgr_{Guid.NewGuid():N}.db");
}
private static void CleanupFiles(string dbPath)
{
if (File.Exists(dbPath)) File.Delete(dbPath);
var walPath = Path.ChangeExtension(dbPath, ".wal");
string walPath = Path.ChangeExtension(dbPath, ".wal");
if (File.Exists(walPath)) File.Delete(walPath);
var altWalPath = dbPath + "-wal";
string altWalPath = dbPath + "-wal";
if (File.Exists(altWalPath)) File.Delete(altWalPath);
}
}
}