acdream/tests/AcDream.Core.Tests/Items/ItemManaStateTests.cs
Erik fa1da02783 feat(ui): port retail selected-item mana
Parse and route the complete 0x0264 guid/fraction/valid response, send exact 0x0263 item-mana queries, and reproduce retail meter visibility plus guid-zero cancellation for mana and health selection changes. Keep the behavior in Core state and the retained selected-object controller with wire/state/UI conformance coverage.

Co-Authored-By: Codex <codex@openai.com>
2026-07-11 11:16:21 +02:00

33 lines
1 KiB
C#

using AcDream.Core.Items;
using Xunit;
namespace AcDream.Core.Tests.Items;
public sealed class ItemManaStateTests
{
[Fact]
public void ValidResponseCachesAndRaisesEvent()
{
var state = new ItemManaState();
(uint Guid, float Percent, bool Valid)? observed = null;
state.ItemManaChanged += (guid, percent, valid) => observed = (guid, percent, valid);
state.OnQueryItemManaResponse(0x50000A01u, 0.75f, valid: true);
Assert.Equal((0x50000A01u, 0.75f, true), observed);
Assert.True(state.HasMana(0x50000A01u));
Assert.Equal(0.75f, state.GetManaPercent(0x50000A01u));
}
[Fact]
public void InvalidResponseClearsCachedValueAndRaisesEvent()
{
var state = new ItemManaState();
state.OnQueryItemManaResponse(0x50000A01u, 0.75f, valid: true);
state.OnQueryItemManaResponse(0x50000A01u, 0f, valid: false);
Assert.False(state.HasMana(0x50000A01u));
Assert.Equal(0f, state.GetManaPercent(0x50000A01u));
}
}