Bug
The README's headline sample and the "Power in Simplicity" section both start with:
using var mock = new HttpMock();
HttpMock does not implement IDisposable (see Mockly.ApiVerificationTests/ApprovedApi/net8.0.verified.txt), so that snippet does not compile. Anyone copying the first sample off the README hits a compiler error immediately.
Proposal
Rather than just dropping using from the docs, make HttpMock disposable and give disposal a purpose:
using var mock = new HttpMock { Strict = true };
// ... test body ...
// on Dispose: throws if any configured mock was never invoked,
// or if unexpected calls were recorded
Strict would default to false, so nothing changes for existing users. With it on, you no longer have to remember HaveAllRequestsCalled() at the end of every test, and a test that forgets its assertions still fails.
Notes
- Dispose must not throw while an exception is already in flight, or it will mask the real failure. Needs care around
Marshal.GetExceptionPointers() / a "did the test already fail" heuristic, or a documented caveat.
- Also lets
HttpMock dispose the HttpClient instances it hands out.
- Either way, the README needs fixing — if
Strict is rejected, drop using from the samples.
Bug
The README's headline sample and the "Power in Simplicity" section both start with:
HttpMockdoes not implementIDisposable(seeMockly.ApiVerificationTests/ApprovedApi/net8.0.verified.txt), so that snippet does not compile. Anyone copying the first sample off the README hits a compiler error immediately.Proposal
Rather than just dropping
usingfrom the docs, makeHttpMockdisposable and give disposal a purpose:Strictwould default tofalse, so nothing changes for existing users. With it on, you no longer have to rememberHaveAllRequestsCalled()at the end of every test, and a test that forgets its assertions still fails.Notes
Marshal.GetExceptionPointers()/ a "did the test already fail" heuristic, or a documented caveat.HttpMockdispose theHttpClientinstances it hands out.Strictis rejected, dropusingfrom the samples.