From ee4c174e34519a9194fbffea49d746f3bdb934d1 Mon Sep 17 00:00:00 2001 From: Sergi Rosell <50594106+srosellj@users.noreply.github.com> Date: Thu, 8 Oct 2026 07:26:00 +0200 Subject: [PATCH] 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. --- .../Items/Misc/Corpses/CorpsePacketTests.cs | 38 +++++++++++++------ 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/Projects/UOContent.Tests/Tests/Items/Misc/Corpses/CorpsePacketTests.cs b/Projects/UOContent.Tests/Tests/Items/Misc/Corpses/CorpsePacketTests.cs index 40ad7c6d7..b5cec8aa6 100644 --- a/Projects/UOContent.Tests/Tests/Items/Misc/Corpses/CorpsePacketTests.cs +++ b/Projects/UOContent.Tests/Tests/Items/Misc/Corpses/CorpsePacketTests.cs @@ -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(); + } } }