acdream/tests/AcDream.App.Tests/LiveEntityRuntimeFixture.cs
Erik 5ef8b5371d refactor(runtime): own canonical entity and object lifetime
Introduce one presentation-free RuntimeEntityObjectLifetime for the exact entity directory and ClientObjectTable. Make GameWindow, graphical projections, retained UI, interaction, session routing, create/delete integration, and reset borrow that owner while preserving synchronous retail ordering, dormant retention, and retry semantics.

Co-authored-by: Codex <codex@openai.com>
2026-07-26 05:54:46 +02:00

50 lines
1.7 KiB
C#

using AcDream.App.Streaming;
using AcDream.App.World;
using AcDream.Runtime.Entities;
namespace AcDream.App.Tests;
/// <summary>
/// Explicit isolated lifetime-group seam for App projection tests. Production
/// composition supplies its session-owned group from GameWindow; focused tests
/// use a fresh group per runtime so identity never leaks between fixtures.
/// </summary>
internal static class LiveEntityRuntimeFixture
{
public static LiveEntityRuntime Create(
GpuWorldState spatial,
ILiveEntityResourceLifecycle resources,
uint firstLocalEntityId = RuntimeEntityDirectory.FirstLocalEntityId)
{
var lifetime = new RuntimeEntityObjectLifetime(firstLocalEntityId);
return new LiveEntityRuntime(spatial, resources, lifetime);
}
public static LiveEntityRuntime Create(
GpuWorldState spatial,
ILiveEntityResourceLifecycle resources,
Action<LiveEntityRecord> tearDownRuntimeComponents,
uint firstLocalEntityId = RuntimeEntityDirectory.FirstLocalEntityId)
{
var lifetime = new RuntimeEntityObjectLifetime(firstLocalEntityId);
return new LiveEntityRuntime(
spatial,
resources,
tearDownRuntimeComponents,
lifetime);
}
public static LiveEntityRuntime Create(
GpuWorldState spatial,
ILiveEntityResourceLifecycle resources,
ILiveEntityRuntimeComponentLifecycle runtimeComponentLifecycle,
uint firstLocalEntityId = RuntimeEntityDirectory.FirstLocalEntityId)
{
var lifetime = new RuntimeEntityObjectLifetime(firstLocalEntityId);
return new LiveEntityRuntime(
spatial,
resources,
runtimeComponentLifecycle,
lifetime);
}
}