using Heimdall.Application.Discovery.Queries.GetTestSession; using Heimdall.Application.Common; using Heimdall.Application.DTOs; using Heimdall.Application.Services; using NSubstitute; namespace Heimdall.Application.Tests.Handlers.Discovery; public class GetTestSessionHandlerTests { [Fact] public async Task Get_test_session_should_return_session() { var service = Substitute.For(); var session = new StreamTestSession(Guid.NewGuid(), "running", 5, 2, 1, []); service.GetTestSessionAsync(session.SessionId, Arg.Any()) .Returns(ServiceResult.Success(session)); var handler = new GetTestSessionQueryHandler(service); var result = await handler.Handle( new GetTestSessionQuery(session.SessionId), CancellationToken.None); result.IsSuccess.ShouldBeTrue(); result.Data.ShouldNotBeNull(); result.Data.Status.ShouldBe("running"); } [Fact] public async Task Get_completed_session_should_show_done() { var service = Substitute.For(); var session = new StreamTestSession(Guid.NewGuid(), "done", 2, 2, 2, [new StreamTestResult("rtsp://cam/stream", ["H264"], 1920, 1080, 30, "shot.jpg", true)]); service.GetTestSessionAsync(session.SessionId, Arg.Any()) .Returns(ServiceResult.Success(session)); var handler = new GetTestSessionQueryHandler(service); var result = await handler.Handle( new GetTestSessionQuery(session.SessionId), CancellationToken.None); result.IsSuccess.ShouldBeTrue(); result.Data!.Status.ShouldBe("done"); result.Data.Alive.ShouldBe(2); } }