acdream/tests/AcDream.Core.Tests/Items/ClientObjectTableUpdateTests.cs
Erik b56087b498 feat(core): D.2b-B B-Wire — ClientObjectTable.UpsertProperties (create-if-absent)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-21 18:48:04 +02:00

41 lines
1.1 KiB
C#

using AcDream.Core.Items;
using Xunit;
namespace AcDream.Core.Tests.Items;
public sealed class ClientObjectTableUpdateTests
{
[Fact]
public void UpsertProperties_unknownObject_createsThenMerges()
{
var t = new ClientObjectTable();
bool added = false;
t.ObjectAdded += _ => added = true;
var bundle = new PropertyBundle();
bundle.Ints[5] = 1234; // EncumbranceVal
t.UpsertProperties(0x50000001u, bundle);
var o = t.Get(0x50000001u);
Assert.NotNull(o);
Assert.Equal(1234, o!.Properties.Ints[5]);
Assert.True(added);
}
[Fact]
public void UpsertProperties_existingObject_mergesAndFiresUpdated()
{
var t = new ClientObjectTable();
t.AddOrUpdate(new ClientObject { ObjectId = 0x50000001u });
bool updated = false;
t.ObjectUpdated += _ => updated = true;
var bundle = new PropertyBundle();
bundle.Ints[5] = 99;
t.UpsertProperties(0x50000001u, bundle);
Assert.Equal(99, t.Get(0x50000001u)!.Properties.Ints[5]);
Assert.True(updated);
}
}