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,5 +1,6 @@
using System.IO.Compression;
using System.Security.Cryptography;
using System.Text;
using ZB.MOM.WW.CBDD.Bson;
using ZB.MOM.WW.CBDD.Core.Compression;
using ZB.MOM.WW.CBDD.Core.Storage;
@@ -10,12 +11,12 @@ namespace ZB.MOM.WW.CBDD.Tests;
public class CompressionCompatibilityTests
{
/// <summary>
/// Verifies opening legacy uncompressed files with compression enabled does not mutate database bytes.
/// Verifies opening legacy uncompressed files with compression enabled does not mutate database bytes.
/// </summary>
[Fact]
public void OpeningLegacyUncompressedFile_WithCompressionEnabled_ShouldNotMutateDbFile()
{
var dbPath = NewDbPath();
string dbPath = NewDbPath();
var idList = new List<ObjectId>();
try
@@ -28,8 +29,8 @@ public class CompressionCompatibilityTests
db.ForceCheckpoint();
}
var beforeSize = new FileInfo(dbPath).Length;
var beforeHash = ComputeFileHash(dbPath);
long beforeSize = new FileInfo(dbPath).Length;
string beforeHash = ComputeFileHash(dbPath);
var compressionOptions = new CompressionOptions
{
@@ -47,8 +48,8 @@ public class CompressionCompatibilityTests
reopened.Users.Count().ShouldBe(2);
}
var afterSize = new FileInfo(dbPath).Length;
var afterHash = ComputeFileHash(dbPath);
long afterSize = new FileInfo(dbPath).Length;
string afterHash = ComputeFileHash(dbPath);
afterSize.ShouldBe(beforeSize);
afterHash.ShouldBe(beforeHash);
@@ -60,12 +61,12 @@ public class CompressionCompatibilityTests
}
/// <summary>
/// Verifies mixed compressed and uncompressed documents remain readable after partial migration.
/// Verifies mixed compressed and uncompressed documents remain readable after partial migration.
/// </summary>
[Fact]
public void MixedFormatDocuments_ShouldRemainReadableAfterPartialMigration()
{
var dbPath = NewDbPath();
string dbPath = NewDbPath();
ObjectId legacyId;
ObjectId compressedId;
@@ -125,7 +126,7 @@ public class CompressionCompatibilityTests
for (ushort slotIndex = 0; slotIndex < header.SlotCount; slotIndex++)
{
var slotOffset = SlottedPageHeader.Size + (slotIndex * SlotEntry.Size);
int slotOffset = SlottedPageHeader.Size + slotIndex * SlotEntry.Size;
var slot = SlotEntry.ReadFrom(buffer.AsSpan(slotOffset, SlotEntry.Size));
if ((slot.Flags & SlotFlags.Deleted) != 0)
continue;
@@ -149,7 +150,7 @@ public class CompressionCompatibilityTests
private static string BuildPayload(int approxLength)
{
var builder = new System.Text.StringBuilder(approxLength + 256);
var builder = new StringBuilder(approxLength + 256);
var i = 0;
while (builder.Length < approxLength)
{
@@ -163,14 +164,16 @@ public class CompressionCompatibilityTests
}
private static string NewDbPath()
=> Path.Combine(Path.GetTempPath(), $"compression_compat_{Guid.NewGuid():N}.db");
{
return Path.Combine(Path.GetTempPath(), $"compression_compat_{Guid.NewGuid():N}.db");
}
private static void CleanupFiles(string dbPath)
{
var walPath = Path.ChangeExtension(dbPath, ".wal");
string walPath = Path.ChangeExtension(dbPath, ".wal");
var markerPath = $"{dbPath}.compact.state";
if (File.Exists(dbPath)) File.Delete(dbPath);
if (File.Exists(walPath)) File.Delete(walPath);
if (File.Exists(markerPath)) File.Delete(markerPath);
}
}
}