From 28c38168bc6ea7e2e387c87b0cc399fd1644b49b Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Tue, 22 Sep 2026 18:53:06 -0700 Subject: [PATCH] test: fix order-dependent enumerator test failures; bump MailKit and Test.Sdk (#2664) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary - `AnchoredItemSerializationTests.LastMovedAndDecayReset_RoundTripExactly` never deleted its deserialized copy. `Item.Deserialize` enters the item into its map's sectors, so the copy stayed live on Felucca at (121,100). `ItemEnumerator_FiltersByBoundsAndOrder`, `ItemByDistanceEnumerator_Bounds_FindsItemsInBounds` and `ItemByDistanceEnumerator_Bounds_MakeBoundsInclusive` scan that area and found an extra item whenever the serialization test ran before them, so they failed depending on test order. The copy is now deleted in a `finally`. - Bump MailKit 4.17.0 → 4.18.0 and Microsoft.NET.Test.Sdk 18.10.0 → 18.10.1. ## Test plan - [x] Probe test: a deserialized copy shows up in `GetItemsInBounds` (reproduced), and after the fix the area is empty - [x] Server.Tests: 907/907 pass - [x] UOContent.Tests: 1126 pass, 2 skipped - [x] Solution builds with 0 errors --- Projects/Server.Tests/Server.Tests.csproj | 2 +- .../AnchoredItemSerializationTests.cs | 35 ++++++++++++------- .../UOContent.Tests/UOContent.Tests.csproj | 2 +- Projects/UOContent/UOContent.csproj | 2 +- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/Projects/Server.Tests/Server.Tests.csproj b/Projects/Server.Tests/Server.Tests.csproj index b1462ba37..8ae939ce1 100644 --- a/Projects/Server.Tests/Server.Tests.csproj +++ b/Projects/Server.Tests/Server.Tests.csproj @@ -5,7 +5,7 @@ Server.Tests - + diff --git a/Projects/Server.Tests/Tests/Serialization/AnchoredItemSerializationTests.cs b/Projects/Server.Tests/Tests/Serialization/AnchoredItemSerializationTests.cs index 7889c57c8..41444ea56 100644 --- a/Projects/Server.Tests/Tests/Serialization/AnchoredItemSerializationTests.cs +++ b/Projects/Server.Tests/Tests/Serialization/AnchoredItemSerializationTests.cs @@ -53,24 +53,33 @@ public class AnchoredItemSerializationTests public void LastMovedAndDecayReset_RoundTripExactly() { var item = new Item(0x1F13); - item.MoveToWorld(new Point3D(121, 100, 0), Map.Felucca); + Item restored = null; - // Sub-minute precision that the old minutes encoding would have destroyed. - var moved = Core.Now - TimeSpan.FromSeconds(90.5) - TimeSpan.FromMilliseconds(123); - item.LastMoved = moved; + try + { + item.MoveToWorld(new Point3D(121, 100, 0), Map.Felucca); - item.RestartDecay(); - var decayReset = item.DecayResetTime; - Assert.NotEqual(default(DateTime), decayReset); + // Sub-minute precision that the old minutes encoding would have destroyed. + var moved = Core.Now - TimeSpan.FromSeconds(90.5) - TimeSpan.FromMilliseconds(123); + item.LastMoved = moved; - var bytes = SerializeItem(item); + item.RestartDecay(); + var decayReset = item.DecayResetTime; + Assert.NotEqual(default(DateTime), decayReset); - var restored = new Item((Serial)0x7ffff123u); - restored.Deserialize(new BufferReader(bytes)); + var bytes = SerializeItem(item); - Assert.Equal(moved, restored.LastMoved); - Assert.Equal(decayReset, restored.DecayResetTime); + // Deserialize enters the copy into the map's sectors, so it must be deleted too. + restored = new Item((Serial)0x7ffff123u); + restored.Deserialize(new BufferReader(bytes)); - item.Delete(); + Assert.Equal(moved, restored.LastMoved); + Assert.Equal(decayReset, restored.DecayResetTime); + } + finally + { + item.Delete(); + restored?.Delete(); + } } } diff --git a/Projects/UOContent.Tests/UOContent.Tests.csproj b/Projects/UOContent.Tests/UOContent.Tests.csproj index 1dc4440ae..b8c675127 100644 --- a/Projects/UOContent.Tests/UOContent.Tests.csproj +++ b/Projects/UOContent.Tests/UOContent.Tests.csproj @@ -4,7 +4,7 @@ Debug;Release;Analyze - + all diff --git a/Projects/UOContent/UOContent.csproj b/Projects/UOContent/UOContent.csproj index 996ec9514..7a2800f0b 100644 --- a/Projects/UOContent/UOContent.csproj +++ b/Projects/UOContent/UOContent.csproj @@ -42,7 +42,7 @@ - +