From a497cc631eee542878086ccf69ad05cf40f522a8 Mon Sep 17 00:00:00 2001 From: Erik Date: Sat, 20 Jun 2026 15:18:35 +0200 Subject: [PATCH] =?UTF-8?q?test(core):=20D.5.3/B.2=20=E2=80=94=20move=20Sh?= =?UTF-8?q?ortcutStoreTests=20to=20Core.Net.Tests=20(Rule=206)=20+=20cosme?= =?UTF-8?q?tic=20cleanups?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Move ShortcutStoreTests from AcDream.Core.Tests to AcDream.Core.Net.Tests (Rule 6: tests live in the project matching the layer under test; ShortcutStore is Core.Net) - Replace fully-qualified System.Buffers.Binary.BinaryPrimitives. with BinaryPrimitives. in the two new BuildAddShortcut tests (file already has `using System.Buffers.Binary`) - Add `using System;` to ShortcutStore.cs; change System.Array.Clear → Array.Clear (matches sibling file style, no behavior change) Co-Authored-By: Claude Opus 4.8 (1M context) --- src/AcDream.Core.Net/Items/ShortcutStore.cs | 3 ++- .../Items/ShortcutStoreTests.cs | 2 +- .../Messages/InventoryActionsTests.cs | 14 +++++++------- 3 files changed, 10 insertions(+), 9 deletions(-) rename tests/{AcDream.Core.Tests => AcDream.Core.Net.Tests}/Items/ShortcutStoreTests.cs (97%) diff --git a/src/AcDream.Core.Net/Items/ShortcutStore.cs b/src/AcDream.Core.Net/Items/ShortcutStore.cs index bff0b098..a927451d 100644 --- a/src/AcDream.Core.Net/Items/ShortcutStore.cs +++ b/src/AcDream.Core.Net/Items/ShortcutStore.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using AcDream.Core.Net.Messages; @@ -19,7 +20,7 @@ public sealed class ShortcutStore /// Replace all slots from the login PlayerDescription shortcut list (item entries only). public void Load(IReadOnlyList entries) { - System.Array.Clear(_objIds); + Array.Clear(_objIds); foreach (var e in entries) if (e.Index < SlotCount && e.ObjectGuid != 0) _objIds[(int)e.Index] = e.ObjectGuid; } diff --git a/tests/AcDream.Core.Tests/Items/ShortcutStoreTests.cs b/tests/AcDream.Core.Net.Tests/Items/ShortcutStoreTests.cs similarity index 97% rename from tests/AcDream.Core.Tests/Items/ShortcutStoreTests.cs rename to tests/AcDream.Core.Net.Tests/Items/ShortcutStoreTests.cs index 2804f64e..97a2b68e 100644 --- a/tests/AcDream.Core.Tests/Items/ShortcutStoreTests.cs +++ b/tests/AcDream.Core.Net.Tests/Items/ShortcutStoreTests.cs @@ -3,7 +3,7 @@ using AcDream.Core.Net.Items; using AcDream.Core.Net.Messages; using Xunit; -namespace AcDream.Core.Tests.Items; +namespace AcDream.Core.Net.Tests.Items; public class ShortcutStoreTests { diff --git a/tests/AcDream.Core.Net.Tests/Messages/InventoryActionsTests.cs b/tests/AcDream.Core.Net.Tests/Messages/InventoryActionsTests.cs index ee71c3a0..298448ae 100644 --- a/tests/AcDream.Core.Net.Tests/Messages/InventoryActionsTests.cs +++ b/tests/AcDream.Core.Net.Tests/Messages/InventoryActionsTests.cs @@ -80,19 +80,19 @@ public sealed class InventoryActionsTests byte[] body = InventoryActions.BuildAddShortcut(seq: 1, index: 0, objectGuid: 0x3E1, spellId: 0, layer: 0); Assert.Equal(24, body.Length); Assert.Equal(InventoryActions.AddShortcutOpcode, - System.Buffers.Binary.BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(8))); - Assert.Equal(0u, System.Buffers.Binary.BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(12))); // index - Assert.Equal(0x3E1u, System.Buffers.Binary.BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(16))); // objectGuid - Assert.Equal((ushort)0, System.Buffers.Binary.BinaryPrimitives.ReadUInt16LittleEndian(body.AsSpan(20))); // spellId - Assert.Equal((ushort)0, System.Buffers.Binary.BinaryPrimitives.ReadUInt16LittleEndian(body.AsSpan(22))); // layer + BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(8))); + Assert.Equal(0u, BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(12))); // index + Assert.Equal(0x3E1u, BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(16))); // objectGuid + Assert.Equal((ushort)0, BinaryPrimitives.ReadUInt16LittleEndian(body.AsSpan(20))); // spellId + Assert.Equal((ushort)0, BinaryPrimitives.ReadUInt16LittleEndian(body.AsSpan(22))); // layer } [Fact] public void BuildAddShortcut_SpellShortcut_PacksSpellAndLayerAsU16s() { byte[] body = InventoryActions.BuildAddShortcut(seq: 1, index: 2, objectGuid: 0, spellId: 0x1234, layer: 3); - Assert.Equal(0x1234, System.Buffers.Binary.BinaryPrimitives.ReadUInt16LittleEndian(body.AsSpan(20))); - Assert.Equal(3, System.Buffers.Binary.BinaryPrimitives.ReadUInt16LittleEndian(body.AsSpan(22))); + Assert.Equal(0x1234, BinaryPrimitives.ReadUInt16LittleEndian(body.AsSpan(20))); + Assert.Equal(3, BinaryPrimitives.ReadUInt16LittleEndian(body.AsSpan(22))); } [Fact]