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

@@ -9,7 +9,7 @@ namespace ZB.MOM.WW.CBDD.Tests;
public class BsonDocumentAndBufferWriterTests
{
/// <summary>
/// Verifies BSON document creation and typed retrieval roundtrip.
/// Verifies BSON document creation and typed retrieval roundtrip.
/// </summary>
[Fact]
public void BsonDocument_Create_And_TryGet_RoundTrip()
@@ -32,10 +32,10 @@ public class BsonDocumentAndBufferWriterTests
var wrapped = new BsonDocument(doc.RawData.ToArray(), reverseMap);
wrapped.TryGetString("name", out var name).ShouldBeTrue();
wrapped.TryGetString("name", out string? name).ShouldBeTrue();
name.ShouldBe("Alice");
wrapped.TryGetInt32("age", out var age).ShouldBeTrue();
wrapped.TryGetInt32("age", out int age).ShouldBeTrue();
age.ShouldBe(32);
wrapped.TryGetObjectId("_id", out var id).ShouldBeTrue();
@@ -46,7 +46,7 @@ public class BsonDocumentAndBufferWriterTests
}
/// <summary>
/// Verifies typed getters return false for missing fields and type mismatches.
/// Verifies typed getters return false for missing fields and type mismatches.
/// </summary>
[Fact]
public void BsonDocument_TryGet_Should_Return_False_For_Missing_Or_Wrong_Type()
@@ -71,7 +71,7 @@ public class BsonDocumentAndBufferWriterTests
}
/// <summary>
/// Verifies the BSON document builder grows its internal buffer for large documents.
/// Verifies the BSON document builder grows its internal buffer for large documents.
/// </summary>
[Fact]
public void BsonDocumentBuilder_Should_Grow_Buffer_When_Document_Is_Large()
@@ -86,21 +86,18 @@ public class BsonDocumentAndBufferWriterTests
}
var builder = new BsonDocumentBuilder(keyMap);
for (int i = 1; i <= 180; i++)
{
builder.AddInt32($"k{i}", i);
}
for (var i = 1; i <= 180; i++) builder.AddInt32($"k{i}", i);
var doc = builder.Build();
doc.Size.ShouldBeGreaterThan(1024);
var wrapped = new BsonDocument(doc.RawData.ToArray(), reverseMap);
wrapped.TryGetInt32("k180", out var value).ShouldBeTrue();
wrapped.TryGetInt32("k180", out int value).ShouldBeTrue();
value.ShouldBe(180);
}
/// <summary>
/// Verifies BSON buffer writer emits expected nested document and array layout.
/// Verifies BSON buffer writer emits expected nested document and array layout.
/// </summary>
[Fact]
public void BsonBufferWriter_Should_Write_Nested_Document_And_Array()
@@ -125,7 +122,7 @@ public class BsonDocumentAndBufferWriterTests
writer.EndDocument(rootSizePos);
int rootEnd = writer.Position;
var bytes = output.WrittenSpan.ToArray();
byte[] bytes = output.WrittenSpan.ToArray();
PatchDocumentSize(bytes, childSizePos, childEnd);
PatchDocumentSize(bytes, arraySizePos, arrayEnd);
PatchDocumentSize(bytes, rootSizePos, rootEnd);
@@ -164,7 +161,7 @@ public class BsonDocumentAndBufferWriterTests
}
/// <summary>
/// Verifies single-byte and C-string span reads operate correctly.
/// Verifies single-byte and C-string span reads operate correctly.
/// </summary>
[Fact]
public void BsonSpanReader_ReadByte_And_ReadCStringSpan_Should_Work()
@@ -172,10 +169,10 @@ public class BsonDocumentAndBufferWriterTests
var singleByteReader = new BsonSpanReader(new byte[] { 0x2A }, new ConcurrentDictionary<ushort, string>());
singleByteReader.ReadByte().ShouldBe((byte)0x2A);
var cstring = Encoding.UTF8.GetBytes("hello\0");
byte[] cstring = Encoding.UTF8.GetBytes("hello\0");
var cstringReader = new BsonSpanReader(cstring, new ConcurrentDictionary<ushort, string>());
var destination = new char[16];
var written = cstringReader.ReadCString(destination);
int written = cstringReader.ReadCString(destination);
new string(destination, 0, written).ShouldBe("hello");
}
@@ -194,4 +191,4 @@ public class BsonDocumentAndBufferWriterTests
{
BinaryPrimitives.WriteInt32LittleEndian(output.AsSpan(sizePosition, 4), endPosition - sizePosition);
}
}
}