Skip to content

Commit

Permalink
Update server init test to static hook
Browse files Browse the repository at this point in the history
  • Loading branch information
SignatureBeef committed Jan 11, 2025
1 parent 0c4c7db commit 7ffb431
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions TShockLauncher.Tests/ServerInitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,19 @@ public class ServerInitTests
public void EnsureBoots()
{
var are = new AutoResetEvent(false);
On.Terraria.Main.hook_DedServ cb = (On.Terraria.Main.orig_DedServ orig, Terraria.Main instance) =>
HookEvents.HookDelegate<Terraria.Main, HookEvents.Terraria.Main.DedServEventArgs> cb = (instance, args) =>
{
args.ContinueExecution = false;
are.Set();
Debug.WriteLine("Server init process successful");
};
On.Terraria.Main.DedServ += cb;
HookEvents.Terraria.Main.DedServ += cb;

new Thread(() => TerrariaApi.Server.Program.Main(new string[] { })).Start();
new Thread(() => TerrariaApi.Server.Program.Main([])).Start();

var hit = are.WaitOne(TimeSpan.FromSeconds(10));

On.Terraria.Main.DedServ -= cb;
HookEvents.Terraria.Main.DedServ -= cb;

Assert.That(hit, Is.True);
}
Expand Down

0 comments on commit 7ffb431

Please sign in to comment.