using Recordingtest.EngineBridge.Client; using Xunit; namespace Recordingtest.EngineBridge.IntegrationTests; public class HmEgHttpSnapshotTests { [Fact] public void Client_SelectionEndpoint_ReturnsIds() { using var srv = new FakeBridgeServer(); srv.Responses["/selection"] = "{\"selected_ids\":[\"a\",\"b\"]}"; using var c = new HmEgHttpSnapshot(srv.BaseUrl); Assert.Equal(new[] { "a", "b" }, c.SelectedObjectIds); } [Fact] public void Client_CameraEndpoint_ReturnsCameraState() { using var srv = new FakeBridgeServer(); srv.Responses["/camera"] = "{\"eye\":[1,2,3],\"target\":[4,5,6],\"up\":[0,0,1],\"fov\":50}"; using var c = new HmEgHttpSnapshot(srv.BaseUrl); var cam = c.Camera; Assert.Equal(new double[] { 1, 2, 3 }, cam.EyePoint); Assert.Equal(new double[] { 4, 5, 6 }, cam.Target); Assert.Equal(50, cam.Fov); } [Fact] public void Client_SceneEndpoint_ReturnsSceneSummary() { using var srv = new FakeBridgeServer(); srv.Responses["/scene"] = "{\"object_count\":42,\"document_path\":\"C:/m.hmeg\"}"; using var c = new HmEgHttpSnapshot(srv.BaseUrl); var s = c.Scene; Assert.Equal(42, s.ObjectCount); Assert.Equal("C:/m.hmeg", s.DocumentPath); } [Fact] public void Client_RenderEndpoint_ReturnsIsComplete() { using var srv = new FakeBridgeServer(); srv.Responses["/render"] = "{\"complete\":true}"; using var c = new HmEgHttpSnapshot(srv.BaseUrl); Assert.True(c.IsRenderComplete); } [Fact] public void Client_HealthEndpoint_ReturnsOk() { using var srv = new FakeBridgeServer(); srv.Responses["/health"] = "{\"status\":\"ok\",\"port\":1}"; using var c = new HmEgHttpSnapshot(srv.BaseUrl); Assert.True(c.IsHealthy); } [Fact] public void Client_Timeout_ThrowsEngineBridgeException() { using var srv = new FakeBridgeServer { ResponseDelay = TimeSpan.FromSeconds(5) }; srv.Responses["/selection"] = "{\"selected_ids\":[]}"; using var c = new HmEgHttpSnapshot(srv.BaseUrl, timeout: TimeSpan.FromMilliseconds(500)); Assert.Throws(() => _ = c.SelectedObjectIds); } }