Fix test-fixture reset routing, outbox restart overlap, and test-harness consumption/disposal bugs#338
Merged
Merged
Conversation
…lds, including lazy UseReal instances
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
when a test overrode CreateFactory() to run on a WithWebHostBuilder(...)-derived host. That silently
built a second, unused host and paused the wrong one's background services while Respawn wiped the
shared database. Reset now targets whichever factory the test actually ran on, and is skipped entirely
when a test never built a host.
OutboxBackgroundService.StartAsync could start a second relay loop before a slow-to-stop previous one
had actually finished. StartAsync now waits for an incomplete previous execute task before starting a
new one.
because RecordConsumed ran before the consumer's await instead of after (already correct for one-way
consumers).
per-test reset behavior; ITestHarness's singleton-lifetime capture leak across tests sharing one host
is now documented with a Clear()-from-Initialize() pattern.
iteration, a teardown-skipping initialization guard, lazy scope/client thread-safety, a Cosmos
readiness wait "falling through") against current code and found them already fixed - no change needed.
Verification
Vulthil.SharedKernel.Tests): all passing, net9.0 and net10.0.
net9.0 and net10.0 - confirms no regression to existing integration coverage.
Backport to v1.0: no - test-infrastructure behavior changes; ships with the next minor.
Amendment:
UseReal/UseRealFornow register the real instance as a lazy factory instead of constructing itimmediately - it is built the first time it's actually resolved (directly or as a dependency), so a dependency
registered afterward but before that resolution is now visible to it (previously it would have been auto-mocked).
BaseUnitTestCase.Dispose()now also disposes every disposable instance the auto-mocker holds (Use()instances,resolved
UseReal/UseRealForinstances, auto-generated dependency mocks) viaAutoMocker.AsDisposable(), inaddition to the existing
Targetdisposal -Targetis still disposed first. Only synchronousIDisposableiscovered; an
IAsyncDisposable-only registration still needs a manual override. These are the two behavior changesreviewers should look for: construction timing for
UseReal/UseRealFor, and new automatic disposal of anythingthe auto-mocker holds.