diff --git a/Tests/Server.Tests/IoCActivator.cs b/Tests/Server.Tests/IoCActivator.cs index e905efb1..d8e55e67 100644 --- a/Tests/Server.Tests/IoCActivator.cs +++ b/Tests/Server.Tests/IoCActivator.cs @@ -21,7 +21,8 @@ namespace Remotely.Server.Tests; [TestClass] public class IoCActivator { - public static IServiceProvider ServiceProvider { get; set; } = null!; + public static IServiceProvider ServiceProvider => _webApp?.Services ?? + throw new InvalidOperationException("The web application has not been initialized."); private static WebApplicationBuilder? _builder; private static WebApplication? _webApp; @@ -30,6 +31,12 @@ public class IoCActivator { _builder = WebApplication.CreateBuilder(); + var appSettings = new Dictionary + { + ["ApplicationOptions:DbProvider"] = "inmemory" + }; + _builder.Configuration.AddInMemoryCollection(appSettings); + _builder.Services.AddDbContext( contextLifetime: ServiceLifetime.Transient, optionsLifetime: ServiceLifetime.Transient); @@ -44,7 +51,6 @@ public class IoCActivator _builder.Services.AddTransient(); _webApp = _builder.Build(); - ServiceProvider = _webApp.Services; } }