feat(D.5.1): ItemRepository.EnrichItem (icon/name/type from CreateObject)

Adds EnrichItem(objectId, iconId, name, type) — enriches an existing
stub created from PlayerDescription with the fuller data carried by its
CreateObject message. Returns false when the item isn't tracked yet
(phase 1: enrich-existing only). Raises ItemPropertiesUpdated on success
so bound widgets (the toolbar) re-render.

Two xUnit tests: enrich-existing updates IconId/Name/raises event (true),
unknown-id returns false.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Erik 2026-06-16 21:48:44 +02:00
parent da171cb4e3
commit f8da98b67f
2 changed files with 40 additions and 0 deletions

View file

@ -116,4 +116,27 @@ public sealed class ItemRepositoryTests
repo.Clear();
Assert.Equal(0, repo.ItemCount);
}
[Fact]
public void EnrichItem_updatesIconOnExistingStub_andRaisesUpdated()
{
var repo = new ItemRepository();
repo.AddOrUpdate(new ItemInstance { ObjectId = 0x5001u, WeenieClassId = 42u }); // stub from PlayerDescription
ItemInstance? updated = null;
repo.ItemPropertiesUpdated += i => updated = i;
bool hit = repo.EnrichItem(0x5001u, iconId: 0x06001234u, name: "Mana Stone", type: ItemType.Misc);
Assert.True(hit);
Assert.Equal(0x06001234u, repo.GetItem(0x5001u)!.IconId);
Assert.Equal("Mana Stone", repo.GetItem(0x5001u)!.Name);
Assert.NotNull(updated);
}
[Fact]
public void EnrichItem_returnsFalse_whenItemUnknown()
{
var repo = new ItemRepository();
Assert.False(repo.EnrichItem(0x9999u, 0x06001234u, "x", ItemType.Misc));
}
}