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:
parent
15a7ce55ce
commit
ee4c174e34
1 changed files with 27 additions and 11 deletions
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue