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

@@ -1,7 +1,5 @@
using ZB.MOM.WW.CBDD.Core;
using ZB.MOM.WW.CBDD.Core.Storage;
using System.Text;
using Xunit;
using ZB.MOM.WW.CBDD.Core.Storage;
namespace ZB.MOM.WW.CBDD.Tests;
@@ -10,7 +8,7 @@ public class DictionaryPageTests
private const int PageSize = 16384;
/// <summary>
/// Verifies dictionary page initialization sets expected defaults.
/// Verifies dictionary page initialization sets expected defaults.
/// </summary>
[Fact]
public void Initialize_ShouldSetupEmptyPage()
@@ -30,7 +28,7 @@ public class DictionaryPageTests
}
/// <summary>
/// Verifies insert adds entries and keeps them ordered.
/// Verifies insert adds entries and keeps them ordered.
/// </summary>
[Fact]
public void Insert_ShouldAddEntryAndSort()
@@ -65,7 +63,7 @@ public class DictionaryPageTests
}
/// <summary>
/// Verifies key lookup returns the expected value.
/// Verifies key lookup returns the expected value.
/// </summary>
[Fact]
public void TryFind_ShouldReturnCorrectValue()
@@ -86,7 +84,7 @@ public class DictionaryPageTests
}
/// <summary>
/// Verifies inserts fail when the page is full.
/// Verifies inserts fail when the page is full.
/// </summary>
[Fact]
public void Overflow_ShouldReturnFalse_WhenFull()
@@ -94,18 +92,16 @@ public class DictionaryPageTests
var page = new byte[PageSize];
DictionaryPage.Initialize(page, 1);
string bigKey = new string('X', 250);
var bigKey = new string('X', 250);
int count = 0;
var count = 0;
while (true)
{
// Use unique keys
var key = bigKey + count;
string key = bigKey + count;
if (!DictionaryPage.Insert(page, key, (ushort)count))
{
// Should fail here
break;
}
count++;
if (count > 1000) throw new ShouldAssertException("Should have filled the page much earlier");
}
@@ -118,16 +114,16 @@ public class DictionaryPageTests
}
/// <summary>
/// Verifies global lookup finds keys across chained dictionary pages.
/// Verifies global lookup finds keys across chained dictionary pages.
/// </summary>
[Fact]
public void Chaining_ShouldFindKeysInLinkedPages()
{
var dbPath = Path.Combine(Path.GetTempPath(), $"test_dict_chain_{Guid.NewGuid()}.db");
string dbPath = Path.Combine(Path.GetTempPath(), $"test_dict_chain_{Guid.NewGuid()}.db");
using var storage = new StorageEngine(dbPath, PageFileConfig.Default);
// 1. Create First Page
var page1Id = storage.AllocatePage();
uint page1Id = storage.AllocatePage();
var pageBuffer = new byte[storage.PageSize];
DictionaryPage.Initialize(pageBuffer, page1Id);
@@ -136,7 +132,7 @@ public class DictionaryPageTests
DictionaryPage.Insert(pageBuffer, "KeyA", 200);
// 2. Create Second Page
var page2Id = storage.AllocatePage();
uint page2Id = storage.AllocatePage();
var page2Buffer = new byte[storage.PageSize];
DictionaryPage.Initialize(page2Buffer, page2Id);
@@ -174,18 +170,18 @@ public class DictionaryPageTests
}
/// <summary>
/// Verifies global enumeration returns keys across chained dictionary pages.
/// Verifies global enumeration returns keys across chained dictionary pages.
/// </summary>
[Fact]
public void FindAllGlobal_ShouldRetrieveAllKeys()
{
var dbPath = Path.Combine(Path.GetTempPath(), $"test_dict_findall_{Guid.NewGuid()}.db");
string dbPath = Path.Combine(Path.GetTempPath(), $"test_dict_findall_{Guid.NewGuid()}.db");
using var storage = new StorageEngine(dbPath, PageFileConfig.Default);
// 1. Create Chain of 3 Pages
var page1Id = storage.AllocatePage();
var page2Id = storage.AllocatePage();
var page3Id = storage.AllocatePage();
uint page1Id = storage.AllocatePage();
uint page2Id = storage.AllocatePage();
uint page3Id = storage.AllocatePage();
var buf = new byte[storage.PageSize];
@@ -226,4 +222,4 @@ public class DictionaryPageTests
if (File.Exists(dbPath)) File.Delete(dbPath);
if (File.Exists(Path.ChangeExtension(dbPath, ".wal"))) File.Delete(Path.ChangeExtension(dbPath, ".wal"));
}
}
}