using Heimdall.Application.Discovery.Commands.TestStreams; using Heimdall.Application.Common; using Heimdall.Application.DTOs; using Heimdall.Application.Services; using NSubstitute; namespace Heimdall.Application.Tests.Handlers.Discovery; public class TestStreamsHandlerTests { [Fact] public async Task Test_streams_should_return_session() { var service = Substitute.For(); var session = new StreamTestSession(Guid.NewGuid(), "running", 3, 1, 0, []); service.TestStreamsAsync(Arg.Any(), Arg.Any()) .Returns(ServiceResult.Success(session)); var handler = new TestStreamsCommandHandler(service); var result = await handler.Handle( new TestStreamsCommand("src-1", ["rtsp://cam1/stream1", "rtsp://cam1/stream2"]), CancellationToken.None); result.IsSuccess.ShouldBeTrue(); result.Data.ShouldNotBeNull(); result.Data.Status.ShouldBe("running"); } [Fact] public async Task Test_streams_with_single_url_should_work() { var service = Substitute.For(); var session = new StreamTestSession(Guid.NewGuid(), "done", 1, 1, 1, [new StreamTestResult("rtsp://cam1/stream1", ["H264"], 1920, 1080, 50, "shot.jpg", true)]); service.TestStreamsAsync(Arg.Any(), Arg.Any()) .Returns(ServiceResult.Success(session)); var handler = new TestStreamsCommandHandler(service); var result = await handler.Handle( new TestStreamsCommand("src-1", ["rtsp://cam1/stream1"]), CancellationToken.None); result.IsSuccess.ShouldBeTrue(); result.Data!.Tested.ShouldBe(1); result.Data.Alive.ShouldBe(1); } }