test: delete the corpse and sword CorpsePacketTests leave in the world (#2696)

`TestCorpseEquipPacket` and `TestCorpseContainerPacket` build a `Corpse` and a `VikingSword` and never delete them, so both stay in `World.Items` for every test that runs after them in the sequential collection.

They're now deleted in a `finally`, the same way the other tests that create world items clean up. The packet assertions are unchanged.
This commit is contained in:
Sergi Rosell 2026-10-08 07:26:00 +02:00 • committed by GitHub
parent 15a7ce55ce
commit ee4c174e34
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -21,13 +21,21 @@ public class CorpsePacketTests
var c = new Corpse(m, m.Items);
var expected = new CorpseEquip(m, c).Compile();
try
{
var expected = new CorpseEquip(m, c).Compile();
using var ns = PacketTestUtilities.CreateTestNetState();
ns.SendCorpseEquip(m, c);
using var ns = PacketTestUtilities.CreateTestNetState();
ns.SendCorpseEquip(m, c);
var result = ns.SendBuffer.GetReadSpan();
AssertThat.Equal(result, expected);
var result = ns.SendBuffer.GetReadSpan();
AssertThat.Equal(result, expected);
}
finally
{
c.Delete();
weapon.Delete();
}
}
[Theory]
@ -43,14 +51,22 @@ public class CorpsePacketTests
var c = new Corpse(m, m.Items);
using var ns = PacketTestUtilities.CreateTestNetState();
ns.ProtocolChanges = changes;
try
{
using var ns = PacketTestUtilities.CreateTestNetState();
ns.ProtocolChanges = changes;
var expected = (ns.ContainerGridLines ? (Packet)new CorpseContent6017(m, c) : new CorpseContent(m, c)).Compile();
var expected = (ns.ContainerGridLines ? (Packet)new CorpseContent6017(m, c) : new CorpseContent(m, c)).Compile();
ns.SendCorpseContent(m, c);
ns.SendCorpseContent(m, c);
var result = ns.SendBuffer.GetReadSpan();
AssertThat.Equal(result, expected);
var result = ns.SendBuffer.GetReadSpan();
AssertThat.Equal(result, expected);
}
finally
{
c.Delete();
weapon.Delete();
}
}
}