public void OldCStoreRequestSend_16BitJpegFileToScpThatDoesNotSupportJpeg_TransferSuccessfulImplicitLENoPixelData() { const string file = @"Test Data/GH538-jpeg14sv1.dcm"; var handle = new ManualResetEventSlim(); var success = false; var port = Ports.GetNext(); using (DicomServer.Create <VideoCStoreProvider>(port)) { var request = new DicomCStoreRequest(file); request.OnResponseReceived = (req, rsp) => { if (req.Dataset.InternalTransferSyntax.Equals(DicomTransferSyntax.ImplicitVRLittleEndian) && !req.Dataset.Contains(DicomTag.PixelData) && rsp.Status == DicomStatus.Success) { success = true; } handle.Set(); }; var client = new Network.DicomClient(); client.AddRequest(request); client.Send("localhost", port, false, "STORESCU", "STORESCP"); handle.Wait(10000); Assert.True(success); } }
public void OldCStoreRequestSend_VideoFileServerSupportsMPEG4_TransferSuccessful() { const string fileName = @"Test Data/test_720.dcm"; var success = false; var handle = new ManualResetEventSlim(); var port = Ports.GetNext(); using (DicomServer.Create <VideoCStoreProvider>(port)) { var request = new DicomCStoreRequest(fileName); request.OnResponseReceived = (req, rsp) => { success = req.Dataset.InternalTransferSyntax.Equals( DicomTransferSyntax.Lookup(DicomUID.MPEG4HP41)) && rsp.Status == DicomStatus.Success; handle.Set(); }; var client = new Network.DicomClient(); client.AddRequest(request); client.Send("localhost", port, false, "STORESCU", "STORESCP"); handle.Wait(10000); Assert.True(success); } }
public void OldCStoreRequestSend_8And16BitJpegFiles_TransferSuccessful() { const string file1 = @"Test Data/GH538-jpeg1.dcm"; const string file2 = @"Test Data/GH538-jpeg14sv1.dcm"; var handle1 = new ManualResetEventSlim(); var handle2 = new ManualResetEventSlim(); var successes = 0; var port = Ports.GetNext(); using (DicomServer.Create <SimpleCStoreProvider>(port)) { var request1 = new DicomCStoreRequest(file1); request1.OnResponseReceived = (req, rsp) => { if (req.Dataset.InternalTransferSyntax.Equals(DicomTransferSyntax.JPEGProcess1) && rsp.Status == DicomStatus.Success) { ++successes; } handle1.Set(); }; var request2 = new DicomCStoreRequest(file2); request2.OnResponseReceived = (req, rsp) => { if (req.Dataset.InternalTransferSyntax.Equals(DicomTransferSyntax.JPEGProcess14SV1) && rsp.Status == DicomStatus.Success) { ++successes; } handle2.Set(); }; var client = new Network.DicomClient(); client.AddRequest(request1); client.AddRequest(request2); client.Send("localhost", port, false, "STORESCU", "STORESCP"); handle1.Wait(10000); handle2.Wait(10000); Assert.Equal(2, successes); } }
public async Task OldDicomClientShallNotCloseConnectionTooEarly_CEchoSerialAsync(int expected) { var port = Ports.GetNext(); var testLogger = _logger.IncludePrefix("GH745"); var clientLogger = _logger.IncludePrefix(nameof(Network.DicomClient)); var serverLogger = _logger.IncludePrefix(nameof(DicomCEchoProvider)); using (var server = DicomServer.Create <DicomCEchoProvider>(port)) { server.Logger = serverLogger; while (!server.IsListening) { await Task.Delay(50); } var actual = 0; var client = new Network.DicomClient() { Logger = clientLogger, Linger = 1 // No need to linger, we only send one request at a time }; for (var i = 0; i < expected; i++) { client.AddRequest( new DicomCEchoRequest { OnResponseReceived = (req, res) => { testLogger.Info("Response #{0} / expected #{1}", actual, req.UserState); Interlocked.Increment(ref actual); testLogger.Info(" #{0} / expected #{1}", actual - 1, req.UserState); }, UserState = i } ); testLogger.Info("Sending #{0}", i); await client.SendAsync("127.0.0.1", port, false, "SCU", "ANY-SCP", 600 * 1000).ConfigureAwait(false); testLogger.Info("Sent (or timed out) #{0}", i); //if (i != actual-1) //{ // output.WriteLine(" waiting #{0}", i); // await Task.Delay((int)TimeSpan.FromSeconds(1).TotalMilliseconds); // output.WriteLine(" waited #{0}", i); //} } Assert.Equal(expected, actual); } }
public async Task OldDicomClientShallNotCloseConnectionTooEarly_CEchoParallelAsync(int expected) { int port = Ports.GetNext(); var testLogger = _logger.IncludePrefix("GH745"); var clientLogger = _logger.IncludePrefix(nameof(Network.DicomClient)); var serverLogger = _logger.IncludePrefix(nameof(DicomCEchoProvider)); using (var server = DicomServer.Create <DicomCEchoProvider>(port)) { server.Logger = serverLogger; while (!server.IsListening) { await Task.Delay(50); } var actual = 0; var requests = Enumerable.Range(0, expected).Select( async requestIndex => { var client = new Network.DicomClient() { Logger = clientLogger }; client.AddRequest( new DicomCEchoRequest { OnResponseReceived = (req, res) => { testLogger.Info("Response #{0}", requestIndex); Interlocked.Increment(ref actual); } } ); testLogger.Info("Sending #{0}", requestIndex); await client.SendAsync("127.0.0.1", port, false, "SCU", "ANY-SCP", 600 * 1000).ConfigureAwait(false); testLogger.Info("Sent (or timed out) #{0}", requestIndex); } ).ToArray(); await Task.WhenAll(requests).ConfigureAwait(false); Assert.Equal(expected, actual); } }
public void Send_FromDicomClient_DoesNotDeadlock() { var port = Ports.GetNext(); using (var server = DicomServer.Create <DicomCEchoProvider>(port)) { server.Logger = new XUnitDicomLogger(_output).IncludeTimestamps().IncludeThreadId().IncludePrefix("DicomCEchoProvider"); var client = new Network.DicomClient { Logger = new XUnitDicomLogger(_output).IncludeTimestamps().IncludeThreadId().IncludePrefix("DicomClient") }; for (var i = 0; i < 10; i++) { client.AddRequest(new DicomCEchoRequest()); } client.Send("127.0.0.1", port, false, "SCU", "ANY-SCP"); Assert.False(client.IsSendRequired); } }