acdream/tests/AcDream.App.Tests/World/LiveWorldOriginStateTests.cs
Erik e91f310279 refactor(update): cut over the frame orchestrator
Reduce GameWindow.OnUpdate to one typed orchestration call and remove transitive window callbacks from teardown, liveness, teleport placement, live presentation, auto-entry, and entity packet routing. Preserve the frozen retail object/network order while making the production owner graph explicit and testable.
2026-07-22 03:31:38 +02:00

76 lines
2.1 KiB
C#

using System.Numerics;
using AcDream.App.World;
namespace AcDream.App.Tests.World;
public sealed class LiveWorldOriginStateTests
{
[Fact]
public void Placeholder_IsNotAuthoritativeUntilFirstInitialization()
{
var state = new LiveWorldOriginState();
state.SetPlaceholder(42, 43);
Assert.Equal(42, state.CenterX);
Assert.Equal(43, state.CenterY);
Assert.False(state.IsKnown);
Assert.True(state.TryInitialize(10, 11));
Assert.Equal(10, state.CenterX);
Assert.Equal(11, state.CenterY);
Assert.True(state.IsKnown);
Assert.False(state.TryInitialize(20, 21));
Assert.Equal(10, state.CenterX);
Assert.Equal(11, state.CenterY);
}
[Fact]
public void Recenter_ReplacesKnownOriginAndResetRetainsItAsPlaceholder()
{
var state = new LiveWorldOriginState();
Assert.True(state.TryInitialize(1, 2));
state.Recenter(3, 4);
state.Reset();
Assert.Equal(3, state.CenterX);
Assert.Equal(4, state.CenterY);
Assert.False(state.IsKnown);
Assert.True(state.TryInitialize(5, 6));
}
[Fact]
public void RecenterBeforeInitialization_PreservesUnknownAndResetIsIdempotent()
{
var state = new LiveWorldOriginState();
state.SetPlaceholder(20, 21);
state.Recenter(30, 31);
state.Reset();
state.Reset();
Assert.Equal(30, state.CenterX);
Assert.Equal(31, state.CenterY);
Assert.False(state.IsKnown);
Assert.True(state.TryInitialize(40, 41));
state.Recenter(50, 51);
Assert.True(state.IsKnown);
Assert.Equal(50, state.CenterX);
Assert.Equal(51, state.CenterY);
}
[Fact]
public void CellLocalForSeed_UsesTheCurrentLandblockOrigin()
{
var state = new LiveWorldOriginState();
state.SetPlaceholder(0x30, 0x32);
Vector3 local = state.CellLocalForSeed(
new Vector3(200f, -300f, 5f),
0x3130_0001u);
Assert.Equal(new Vector3(8f, 84f, 5f), local);
}
}