public async Task Create_SubclassedServer_SufficientlyCreated() { var port = Ports.GetNext(); using var server = DicomServerFactory.Create <DicomCEchoProvider, DicomCEchoProviderServer>(null, port, logger: _logger.IncludePrefix("DicomServer")); Assert.IsType <DicomCEchoProviderServer>(server); Assert.Equal(DicomServerRegistry.Get(port)?.DicomServer, server); var status = DicomStatus.UnrecognizedOperation; var handle = new ManualResetEventSlim(); var client = DicomClientFactory.Create("127.0.0.1", port, false, "SCU", "ANY-SCP"); client.Logger = _logger.IncludePrefix("DicomClient"); await client.AddRequestAsync(new DicomCEchoRequest { OnResponseReceived = (req, rsp) => { status = rsp.Status; handle.Set(); } }); await client.SendAsync(); handle.Wait(1000); Assert.Equal(DicomStatus.Success, status); }
public void IsListening_DicomServerNotInitializedOnPort_ReturnsFalse() { var port = Ports.GetNext(); using (DicomServerFactory.Create <DicomCEchoProvider>(port, logger: _logger.IncludePrefix("DicomServer"))) { Assert.False(DicomServerRegistry.Get(Ports.GetNext())?.DicomServer?.IsListening ?? false); } }
public void Create_GetInstanceSamePortAfterDisposal_ReturnsNull() { var port = Ports.GetNext(); using (DicomServerFactory.Create <DicomCEchoProvider>(port, logger: _logger.IncludePrefix("DicomServer"))) { /* do nothing here */ } var server = DicomServerRegistry.Get(port)?.DicomServer; Assert.Null(server); }
public void Create_GetInstanceSamePort_ReturnsInstance() { var port = Ports.GetNext(); using (DicomServerFactory.Create <DicomCEchoProvider>(port, logger: _logger.IncludePrefix("DicomServer"))) { var server = DicomServerRegistry.Get(port)?.DicomServer; Assert.Equal(port, server.Port); } }
public void Create_GetInstanceDifferentPort_ReturnsNull() { var port = Ports.GetNext(); using (DicomServerFactory.Create <DicomCEchoProvider>(port, logger: _logger.IncludePrefix("DicomServer"))) { var server = DicomServerRegistry.Get(Ports.GetNext()); Assert.Null(server); } }
public void IsListening_DicomServerRunningOnPort_ReturnsTrue() { var port = Ports.GetNext(); using var server = DicomServerFactory.Create <DicomCEchoProvider>(port, logger: _logger.IncludePrefix("DicomServer")); while (!server.IsListening) { Thread.Sleep(10); } Assert.True(DicomServerRegistry.Get(port).DicomServer.IsListening); }
public void Create_TwiceOnSamePortWithDisposalInBetween_DoesNotThrow() { var port = Ports.GetNext(); using (DicomServerFactory.Create <DicomCEchoProvider>(port, logger: _logger.IncludePrefix("DicomServer"))) { /* do nothing here */ } var e = Record.Exception( () => { using (DicomServerFactory.Create <DicomCEchoProvider>(port, logger: _logger.IncludePrefix("DicomServer"))) { Assert.NotNull(DicomServerRegistry.Get(port)?.DicomServer); } }); Assert.Null(e); }
public void IsListening_DicomServerStoppedOnPort_ReturnsFalse() { var port = Ports.GetNext(); using var server = DicomServerFactory.Create <DicomCEchoProvider>(port, logger: _logger.IncludePrefix("DicomServer")); while (!server.IsListening) { Thread.Sleep(10); } server.Stop(); while (server.IsListening) { Thread.Sleep(10); } var dicomServer = DicomServerRegistry.Get(port)?.DicomServer; Assert.NotNull(dicomServer); Assert.False(dicomServer.IsListening); }
public void Create_MultipleInstancesDifferentPorts_AllRegistered() { var ports = new int[20].Select(i => Ports.GetNext()).ToArray(); foreach (var port in ports) { var server = DicomServerFactory.Create <DicomCEchoProvider>(port, logger: _logger.IncludePrefix("DicomServer")); while (!server.IsListening) { Thread.Sleep(10); } } foreach (var port in ports) { Assert.Equal(port, DicomServerRegistry.Get(port)?.DicomServer.Port); } foreach (var port in ports) { DicomServerRegistry.Get(port)?.DicomServer.Dispose(); } }