clients/dotnet/Booblik.Tests
Generated page
Model gemma-mtp, commit ef58254ca7be, 2026-08-16, sources: 6. Edit the code or the hand-written documentation instead.
What this module is responsible for
(Documentation for the Booblik.Tests module, covering the testing infrastructure and validation logic for the Booblik client.)
Diagram
FakeBroker
The mock broker implementation used to simulate network responses, protocol framing, and broker-side errors. It implements a TcpListener to handle real network communication on a loopback address FakeBroker.cs:57-169. The broker's behavior can be configured via:
| Property | Type | Purpose |
|---|---|---|
Corrupt | bool | Flips a bit in stored checksums to simulate damaged segments FakeBroker.cs:36 |
RefuseWith | Code | Sets the error code for the next response FakeBroker.cs:60 |
The broker maintains state for _produced records FakeBroker.cs:26 and tracks the LastFetch metadata FakeBroker.cs:41-46.
More: FakeBroker
Connection
Validation of the low-level transport, including byte-for-byte payload integrity, protocol error handling, and metadata routing. Tests ensure that ARecordArrivesByteForByte preserves all byte values including nulls ConnectionTests.cs:17-31, and that ATruncatedResponseIsAProtocolError correctly identifies malformed frames ConnectionTests.cs:100-103. It also validates that MetadataAndKeyRouting correctly interacts with the partitioner ConnectionTests.cs:68-79.
More: Connection
Consumer
Testing of the consumer lifecycle, including record ordering, high watermark behavior, max bytes truncation, and checksum validation. The consumer is tested against "golden vectors" for CRC32C checksums ConsumerTests.cs:38-47. Key behaviors tested include:
RecordsComeBackInOrder: Verifies position and high watermark updatesConsumerTests.cs:60-75.TruncatedTailIsDroppedAndRefetched: EnsuresMaxBytescuts on byte boundaries do not corrupt dataConsumerTests.cs:100-113.RecordLargerThanMaxBytesIsReported: ValidatesRecordExceedsMaxBytesExceptionwhen a single record exceeds the bufferConsumerTests.cs:136-150.
Producer
Verification of batching logic, linger windows, partition accumulation, and asynchronous error propagation. The producer is tested to ensure NoRecordsAreLostAcrossLingerWindows by simulating timing-sensitive interleaving ProducerTests.cs:17-51. Other verified behaviors include:
PartitionsAccumulateSeparately: Ensures batches are partitioned by their targetProducerTests.cs:73-95.DisposeFlushesWhatIsQueued: Verifies thatDisposeAsynctriggers a final flush of pending recordsProducerTests.cs:97-117.ABrokerFailureReachesEveryWaitingCaller: Ensures all tasks in a batch receive theBrokerExceptionProducerTests.cs:141-157.
Partitioner
Validation of the FNV-1a hashing algorithm and partition assignment against golden vectors. The tests ensure MatchesTheGoldenVectors by comparing results against a known-good implementation PartitionerTests.cs:20-39. It specifically validates that HighBytesAreUnsigned to prevent errors common in signed-integer ports PartitionerTests.cs:47-51.
Key files
| File | Lines | What is there |
|---|---|---|
…/Booblik.Tests/Booblik.Tests.csproj | 13-17 | Test dependencies including xUnit and Coverlet |
…/Booblik.Tests/ConnectionTests.cs | 17-31 | Byte-for-byte payload integrity test |
…/Booblik.Tests/ConsumerTests.cs | 38-47 | CRC32C checksum validation against golden vectors |
…/Booblik.Tests/FakeBroker.cs | 175-227 | The Produce method implementation for the mock broker |
…/Booblik.Tests/PartitionerTests.cs | 20-39 | FNV-1a golden vector validation |
…/Booblik.Tests/ProducerTests.cs | 17-51 | Linger window and record loss regression test |
Behaviour that does not surprise
Producer.SendAsyncreturnsProducer.OffsetUnknownwhenAckPolicy.Noneis used, rather than waiting for a broker responseProducerTests.cs:132-134.Consumer.PollAsyncwill throw aRecordExceedsMaxBytesExceptionif a single record is larger than the configuredMaxBytes, preventing an infinite retry loopConsumerTests.cs:145-150.FakeBrokeruses alockon_gateto ensure thread-safe access to the_produceddictionary and_nextOffsetFakeBroker.cs:25-28.