using AcDream.Core.Items; using AcDream.Core.Net; using AcDream.Core.Net.Messages; namespace AcDream.Core.Net.Tests; /// /// D.5.4 Task 7 — ObjectTableWiring. /// /// Integration test is omitted: WorldSession.EntitySpawned has no internal /// test seam to fire it without a real Tick + packet bytes, so subscription /// correctness is covered by build (type-checks) + the live run. Only the /// pure mapping (ToWeenieData) is unit-tested here. /// public sealed class ObjectTableWiringTests { [Fact] public void ToWeenieData_CopiesFieldsFromSpawn() { // Every EntitySpawn item field is set to a DISTINCT recognisable value so // a positional transposition in ObjectTableWiring.ToWeenieData would trip // at least one Assert. All 22 WeenieData fields are verified below. var spawn = new WorldSession.EntitySpawn( Guid: 0x00000600u, Position: null, SetupTableId: null, AnimPartChanges: System.Array.Empty(), TextureChanges: System.Array.Empty(), SubPalettes: System.Array.Empty(), BasePaletteId: null, ObjScale: null, Name: "Iron Sword", ItemType: (uint)ItemType.MeleeWeapon, MotionState: null, MotionTableId: null) with { WeenieClassId = 0x00001001u, IconId = 0x06001111u, IconOverlayId = 0x06002222u, IconUnderlayId = 0x06003333u, UiEffects = 0x00000004u, Value = 7, StackSize = 1, StackSizeMax = 1, Burden = 300, ContainerId = 0x000000C9u, WielderId = 0x000000DAu, ValidLocations = 0x00000012u, // MeleeWeapon wield mask CurrentWieldedLocation = 0x00000002u, // right-hand Priority = 0x00000005u, ItemsCapacity = 0, ContainersCapacity = 0, Structure = 80, MaxStructure = 100, Workmanship = 4.5f, }; var d = ObjectTableWiring.ToWeenieData(spawn); // --- identity --- Assert.Equal(0x00000600u, d.Guid); Assert.Equal("Iron Sword", d.Name); Assert.Equal(ItemType.MeleeWeapon, d.Type); // --- weenie / icon --- Assert.Equal(0x00001001u, d.WeenieClassId); Assert.Equal(0x06001111u, d.IconId); Assert.Equal(0x06002222u, d.IconOverlayId); Assert.Equal(0x06003333u, d.IconUnderlayId); Assert.Equal(0x00000004u, d.Effects); // --- quantity / economy --- Assert.Equal(7, d.Value); Assert.Equal(1, d.StackSize); Assert.Equal(1, d.StackSizeMax); Assert.Equal(300, d.Burden); // --- container / wielder --- Assert.Equal(0x000000C9u, d.ContainerId); Assert.Equal(0x000000DAu, d.WielderId); // --- equip masks --- Assert.Equal(0x00000012u, d.ValidLocations); Assert.Equal(0x00000002u, d.CurrentWieldedLocation); Assert.Equal(0x00000005u, d.Priority); // --- capacity --- Assert.Equal(0, d.ItemsCapacity); Assert.Equal(0, d.ContainersCapacity); // --- durability --- Assert.Equal(80, d.Structure); Assert.Equal(100, d.MaxStructure); Assert.Equal(4.5f, d.Workmanship); } }