Class IsolatedContainerUnitTests
Base class for unit tests that need to register services via Service and build the IoC container,
but do not require the full UnitTests setup (no AppStateReset, no AppCore.PreInit,
no assembly discovery, no fake bookkeeping).
[Category.Unit]
public abstract class IsolatedContainerUnitTests
- Inheritance
-
objectIsolatedContainerUnitTests
- Extension Methods
Remarks
The base class owns the container lifecycle: it resets the container before each fixture, calls RegisterTestServices() (overridable hook for test-specific registrations), then builds the container via InitializeContainer(). Tests just override RegisterTestServices() and rely on resolved services being available — they do not need to manage the container themselves. Performance is close to a test class with no base at all.
Constructors
IsolatedContainerUnitTests()
protected IsolatedContainerUnitTests()
Methods
IsolatedContainerUnitTestsOneTimeSetUp()
Disposes any leftover IoC container from a previously executed fixture, runs RegisterTestServices(), and builds the container so resolutions succeed in every test.
public void IsolatedContainerUnitTestsOneTimeSetUp()
IsolatedContainerUnitTestsOneTimeTearDown()
Disposes the IoC container once the fixture finishes so it does not leak service registrations into other fixtures.
public void IsolatedContainerUnitTestsOneTimeTearDown()
RegisterTestServices()
Override to register services (e.g. Use<TService, TImplementation>(string, bool)) needed by the fixture. Called between the container reset and InitializeContainer(), so registrations always succeed.
protected virtual void RegisterTestServices()