๐ WAYPOINT LESSON
Checkpoint โ The Self-Verifying Suite
โญโญ intermediateโณ 25 min read๐ Lesson 137 of 265
Compose it: a fake double, a service behind an interface, and a test suite that actually catches broken implementations.
The gate (mini-build)
Three pieces, one file:
IInventoryโint GetStock(string sku),void Reserve(string sku, int qty).FakeInventory : IInventoryโ the fake:Dictionary<string,int> Stock(missing sku = 0),List<string> Reservations, plus two fault hooks:LyingStock(when true,GetStockreturns the real value + 1000) andBrokenReserve(when true,Reserverecords nothing).OrderService(IInventory)โPlaceOrder(sku, qty)โ "ok" | "outofstock"; reserves only on success.CheckAll(FakeInventory inv)โ a small suite (โฅ 3 tests) that verifies: the ok path reserves, the out-of-stock path does not reserve, and qty exactly equal to stock still succeeds. Returns the list of failure messages โ empty means every test passed. The suite must genuinely test the injected inventory: handed a lying or broken fake, it must report failures, not happy-face an empty list.