refactor: MfGames.TestSetup: made service provider nullable internally

This commit is contained in:
D. Moonfire 2024-03-10 13:19:31 -05:00
parent ff974cb9bc
commit 5a225c82c8

View file

@ -14,6 +14,8 @@ public class TestContext : IDisposable
private ILogger? logger;
private AutofacServiceProvider? serviceProvider;
public IContainer Container
{
get =>
@ -31,7 +33,13 @@ public class TestContext : IDisposable
/// <summary>
/// Gets the service provider for resolving services.
/// </summary>
public AutofacServiceProvider ServiceProvider { get; private set; }
public AutofacServiceProvider ServiceProvider
{
get =>
this.serviceProvider
?? throw new NullReferenceException("ConfigureContainer has not been called.");
private set => this.serviceProvider = value;
}
public void ConfigureContainer()
{
@ -50,8 +58,8 @@ public class TestContext : IDisposable
this.ConfigureContainer(builder);
this.Container = builder.Build();
this.ServiceProvider = new AutofacServiceProvider(this.Container);
this.container = builder.Build();
this.serviceProvider = new AutofacServiceProvider(this.Container);
}
/// <inheritdoc />