- 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) <noreply@anthropic.com>
42 lines
1.4 KiB
C#
42 lines
1.4 KiB
C#
using System.Collections.Generic;
|
|
using AcDream.Core.Net.Items;
|
|
using AcDream.Core.Net.Messages;
|
|
using Xunit;
|
|
|
|
namespace AcDream.Core.Net.Tests.Items;
|
|
|
|
public class ShortcutStoreTests
|
|
{
|
|
[Fact]
|
|
public void Load_mapsIndexToObjId_skipsEmptyAndOutOfRange()
|
|
{
|
|
var store = new ShortcutStore();
|
|
var entries = new List<PlayerDescriptionParser.ShortcutEntry>
|
|
{
|
|
new(Index: 0, ObjectGuid: 0x5001u, SpellId: 0, Layer: 0),
|
|
new(Index: 3, ObjectGuid: 0x5002u, SpellId: 0, Layer: 0),
|
|
new(Index: 5, ObjectGuid: 0u, SpellId: 7, Layer: 1), // spell-only → skipped (item store)
|
|
new(Index: 99, ObjectGuid: 0x5003u, SpellId: 0, Layer: 0), // out of range → skipped
|
|
};
|
|
store.Load(entries);
|
|
Assert.Equal(0x5001u, store.Get(0));
|
|
Assert.Equal(0x5002u, store.Get(3));
|
|
Assert.Equal(0u, store.Get(5));
|
|
Assert.True(store.IsEmpty(1));
|
|
}
|
|
|
|
[Fact]
|
|
public void SetRemoveGet_roundtrip_andBoundsSafe()
|
|
{
|
|
var store = new ShortcutStore();
|
|
store.Set(4, 0xABCDu);
|
|
Assert.Equal(0xABCDu, store.Get(4));
|
|
Assert.False(store.IsEmpty(4));
|
|
store.Remove(4);
|
|
Assert.True(store.IsEmpty(4));
|
|
Assert.Equal(0u, store.Get(-1));
|
|
Assert.Equal(0u, store.Get(18));
|
|
store.Set(18, 1u); // no-op, no throw
|
|
store.Remove(-1); // no-op, no throw
|
|
}
|
|
}
|