feat(objects): ObjectCacheGenerator core + GenObjects command

Wraps introspection, categorization sync, and cache-building into a
single file-I/O-free Generate() so the full pipeline is testable
without a shard; GenObjects is a thin command that adds file I/O and
operator messaging on top.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Kamron Batman 2026-07-19 11:21:12 -07:00
parent a55d83fc21
commit 0ac505d7b6
No known key found for this signature in database
GPG key ID: 7D81DF26D9A5D94A
3 changed files with 155 additions and 0 deletions

View file

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using Server.Commands;
using Server.Items;
using Xunit;
namespace UOContent.Tests.Commands.Objects;
[Collection("Sequential UOContent Tests")]
public class ObjectCacheGeneratorTests
{
[Fact]
public void Generate_builds_index_and_chunks_from_extracted_objects()
{
var discovered = new List<Type> { typeof(Runebook), typeof(Katana) };
var categorization = new List<CAGJson>(); // empty -> both land in Items.Uncategorized
var result = ObjectCacheGenerator.Generate(categorization, discovered);
Assert.Equal(2, result.Index.Objects.Count);
Assert.NotEmpty(result.Chunks);
var runebook = Assert.Single(result.Index.Objects, o => o.Type == "Runebook");
Assert.True(runebook.ItemID > 0);
Assert.Equal(1041267, runebook.Cliloc);
Assert.Equal("items.uncategorized", runebook.Chunk);
Assert.Contains("Runebook", result.Report.Appended);
Assert.Contains("items.uncategorized", result.Chunks.Keys);
Assert.Contains("Runebook", result.Chunks["items.uncategorized"].Keys);
}
}