test: Make IntegrationFixture disposable

pull/124/head
Robert Dailey 2 years ago
parent 010c13e5e8
commit defb137a25

@ -9,14 +9,15 @@ using Serilog.Events;
namespace Recyclarr.TestLibrary; namespace Recyclarr.TestLibrary;
[FixtureLifeCycle(LifeCycle.InstancePerTestCase)] [FixtureLifeCycle(LifeCycle.InstancePerTestCase)]
public abstract class IntegrationFixture public abstract class IntegrationFixture : IDisposable
{ {
private readonly ILifetimeScope _container; private readonly ILifetimeScope _container;
private readonly FakeConsole _console = new();
protected IntegrationFixture() protected IntegrationFixture()
{ {
var compRoot = new CompositionRoot(); var compRoot = new CompositionRoot();
_container = compRoot.Setup(default, new FakeConsole(), LogEventLevel.Debug).Container _container = compRoot.Setup(default, _console, LogEventLevel.Debug).Container
.BeginLifetimeScope(builder => .BeginLifetimeScope(builder =>
{ {
builder.RegisterSource<AnyConcreteTypeNotAlreadyRegisteredSource>(); builder.RegisterSource<AnyConcreteTypeNotAlreadyRegisteredSource>();
@ -36,4 +37,21 @@ public abstract class IntegrationFixture
{ {
return _container.Resolve<T>(); return _container.Resolve<T>();
} }
protected virtual void Dispose(bool disposing)
{
if (!disposing)
{
return;
}
_container.Dispose();
_console.Dispose();
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
} }

Loading…
Cancel
Save