test(spawners): exception-safe cleanup in RegionSpawner round-trip test
Move spawner?.Delete() into the finally block so a placed (MoveToWorld'd) spawner cannot leak into shared "Sequential UOContent Tests" map state if an assertion throws. Declare spawner/s before the try and null-init them. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
644488dde7
commit
d2a72f98f6
1 changed files with 6 additions and 5 deletions
|
|
@ -23,9 +23,11 @@ public class RegionSpawnerRoundTripTests
|
|||
);
|
||||
region.Register();
|
||||
|
||||
RegionSpawner spawner = null;
|
||||
RegionSpawner s = null;
|
||||
try
|
||||
{
|
||||
var spawner = new RegionSpawner("Fisherman") { SpawnRegion = region };
|
||||
spawner = new RegionSpawner("Fisherman") { SpawnRegion = region };
|
||||
spawner.MoveToWorld(new Point3D(1416, 1683, 0), Map.Felucca);
|
||||
|
||||
var json = JsonSerializer.Serialize<List<BaseSpawner>>(
|
||||
|
|
@ -34,14 +36,13 @@ public class RegionSpawnerRoundTripTests
|
|||
Assert.Contains(region.Name, json);
|
||||
|
||||
var rt = JsonSerializer.Deserialize<List<BaseSpawner>>(json, SpawnerJsonSerializer.Options);
|
||||
var s = Assert.IsType<RegionSpawner>(Assert.Single(rt));
|
||||
s = Assert.IsType<RegionSpawner>(Assert.Single(rt));
|
||||
Assert.Equal(region.Name, s.SpawnRegion?.Name);
|
||||
|
||||
s.Delete();
|
||||
spawner.Delete();
|
||||
}
|
||||
finally
|
||||
{
|
||||
s?.Delete();
|
||||
spawner?.Delete();
|
||||
region.Unregister();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue