Allow multiple module testing callbacks

This commit is contained in:
DrSmugleaf
2020-10-29 17:50:25 +01:00
parent 60bee860cb
commit 0321a74bb6
3 changed files with 18 additions and 9 deletions

View File

@@ -80,9 +80,9 @@ namespace Content.Client
ClientContentIoC.Register();
if (TestingCallbacks != null)
foreach (var callback in TestingCallbacks)
{
var cast = (ClientModuleTestingCallbacks) TestingCallbacks;
var cast = (ClientModuleTestingCallbacks) callback;
cast.ClientBeforeIoC?.Invoke();
}

View File

@@ -57,6 +57,20 @@ namespace Content.IntegrationTests
options ??= new ServerIntegrationOptions();
options.ServerContentAssembly = typeof(Server.EntryPoint).Assembly;
options.SharedContentAssembly = typeof(Shared.EntryPoint).Assembly;
options.BeforeStart += () =>
{
IoCManager.Resolve<IModLoader>().SetModuleBaseCallbacks(new ServerModuleTestingCallbacks
{
ServerBeforeIoC = () =>
{
if (options is ServerContentIntegrationOption contentOptions)
{
contentOptions.ContentBeforeIoC?.Invoke();
}
}
});
};
return base.StartServer(options);
}
@@ -69,11 +83,6 @@ namespace Content.IntegrationTests
{
ServerBeforeIoC = () =>
{
if (options is ServerContentIntegrationOption contentOptions)
{
contentOptions.ContentBeforeIoC?.Invoke();
}
IoCManager.Register<IGameTicker, DummyGameTicker>(true);
}
});

View File

@@ -40,9 +40,9 @@ namespace Content.Server
ServerContentIoC.Register();
if (TestingCallbacks != null)
foreach (var callback in TestingCallbacks)
{
var cast = (ServerModuleTestingCallbacks) TestingCallbacks;
var cast = (ServerModuleTestingCallbacks) callback;
cast.ServerBeforeIoC?.Invoke();
}