public void TestBadApiWhenAttemptingToSendImageWithResultsTest()
        {
            var segmentationAnonymisationProtocol = SegmentationAnonymisationProtocol();

            var mockSegmentationClient = GetMockInnerEyeSegmentationClient();

            // Set the client to always return 50%
            mockSegmentationClient.SegmentationResultException = new Exception();

            var resultsDirectory = CreateTemporaryDirectory();

            // Copy files to result directory
            new FileInfo(Directory.EnumerateFiles(@"Images\1ValidSmall\")
                         .ToList()[0]).CopyTo(Path.Combine(resultsDirectory.FullName, $"{Guid.NewGuid()}.dcm"));

            var referenceDicomFiles = resultsDirectory
                                      .GetFiles()
                                      .Select(x => DicomFile.Open(x.FullName))
                                      .CreateNewDicomFileWithoutPixelData(segmentationAnonymisationProtocol.Select(x => x.DicomTagIndex.DicomTag));

            var applicationEntity = new GatewayApplicationEntity("RListenerTest", 141, "127.0.0.1");

            using (var deleteService = CreateDeleteService())
                using (var downloadService = CreateDownloadService(mockSegmentationClient, GetTestDequeueServiceConfig(maximumQueueMessageAgeSeconds: 1)))
                    using (var downloadQueue = downloadService.DownloadQueue)
                    {
                        deleteService.Start();
                        downloadService.Start();

                        Assert.IsTrue(downloadService.IsExecutionThreadRunning);

                        TransactionalEnqueue(
                            downloadQueue,
                            new DownloadQueueItem(
                                segmentationId: Guid.NewGuid().ToString(),
                                modelId: Guid.NewGuid().ToString(),
                                resultsDirectory: resultsDirectory.FullName,
                                referenceDicomFiles: referenceDicomFiles,
                                calledApplicationEntityTitle: applicationEntity.Title,
                                callingApplicationEntityTitle: applicationEntity.Title,
                                destinationApplicationEntity: applicationEntity,
                                tagReplacementJsonString: JsonConvert.SerializeObject(_defaultTagReplacement),
                                associationGuid: Guid.NewGuid(),
                                associationDateTime: DateTime.UtcNow,
                                isDryRun: false));

                        SpinWait.SpinUntil(() => new DirectoryInfo(resultsDirectory.FullName).Exists == false, TimeSpan.FromSeconds(60));

                        Assert.IsFalse(new DirectoryInfo(resultsDirectory.FullName).Exists);
                    }
        }
        public void DownloadServiceExitsCorrectlyTest()
        {
            var segmentationAnonymisationProtocol = SegmentationAnonymisationProtocol();

            var mockSegmentationClient = GetMockInnerEyeSegmentationClient();

            // Set the client to always return 50%
            mockSegmentationClient.SegmentationProgressResult = new ModelResult(50, string.Empty, null);

            var referenceDicomFiles = new DirectoryInfo(@"Images\1ValidSmall\")
                                      .GetFiles()
                                      .Select(x => DicomFile.Open(x.FullName))
                                      .CreateNewDicomFileWithoutPixelData(segmentationAnonymisationProtocol.Select(x => x.DicomTagIndex.DicomTag));

            var applicationEntity = new GatewayApplicationEntity("RListenerTest", 142, "127.0.0.1");

            using (var downloadService = CreateDownloadService(mockSegmentationClient))
                using (var downloadQueue = downloadService.DownloadQueue)
                {
                    TransactionalEnqueue(
                        downloadQueue,
                        new DownloadQueueItem(
                            segmentationId: Guid.NewGuid().ToString(),
                            modelId: Guid.NewGuid().ToString(),
                            resultsDirectory: CreateTemporaryDirectory().FullName,
                            referenceDicomFiles: referenceDicomFiles,
                            calledApplicationEntityTitle: applicationEntity.Title,
                            callingApplicationEntityTitle: applicationEntity.Title,
                            destinationApplicationEntity: applicationEntity,
                            tagReplacementJsonString: JsonConvert.SerializeObject(_defaultTagReplacement),
                            associationGuid: Guid.NewGuid(),
                            associationDateTime: DateTime.UtcNow,
                            isDryRun: false));

                    downloadService.Start();

                    SpinWait.SpinUntil(() => downloadService.IsExecutionThreadRunning);

                    WaitUntilNoMessagesOnQueue(downloadQueue);

                    Assert.IsTrue(downloadService.IsExecutionThreadRunning);

                    downloadService.OnStop();

                    SpinWait.SpinUntil(() => !downloadService.IsExecutionThreadRunning);

                    Assert.IsFalse(downloadService.IsExecutionThreadRunning);
                }
        }
        public void DownloadServiceAPIError()
        {
            var segmentationAnonymisationProtocol = SegmentationAnonymisationProtocol();

            var mockSegmentationClient = GetMockInnerEyeSegmentationClient();

            // Set the client to always return 50%
            mockSegmentationClient.SegmentationProgressResult = new ModelResult(100, "An API error.", null);

            var referenceDicomFiles = new DirectoryInfo(@"Images\1ValidSmall\")
                                      .GetFiles()
                                      .Select(x => DicomFile.Open(x.FullName))
                                      .CreateNewDicomFileWithoutPixelData(segmentationAnonymisationProtocol.Select(x => x.DicomTagIndex.DicomTag));

            var applicationEntity = new GatewayApplicationEntity("RListenerTest", 141, "127.0.0.1");

            using (var downloadService = CreateDownloadService(mockSegmentationClient))
                using (var downloadQueue = downloadService.DownloadQueue)
                    using (var deadLetterQueue = downloadService.DeadletterMessageQueue)
                    {
                        downloadService.Start();

                        Assert.IsTrue(downloadService.IsExecutionThreadRunning);

                        TransactionalEnqueue(
                            downloadQueue,
                            new DownloadQueueItem(
                                segmentationId: Guid.NewGuid().ToString(),
                                modelId: Guid.NewGuid().ToString(),
                                resultsDirectory: CreateTemporaryDirectory().FullName,
                                referenceDicomFiles: referenceDicomFiles,
                                calledApplicationEntityTitle: applicationEntity.Title,
                                callingApplicationEntityTitle: applicationEntity.Title,
                                destinationApplicationEntity: applicationEntity,
                                tagReplacementJsonString: JsonConvert.SerializeObject(_defaultTagReplacement),
                                associationGuid: Guid.NewGuid(),
                                associationDateTime: DateTime.UtcNow,
                                isDryRun: false));

                        WaitUntilNoMessagesOnQueue(downloadQueue);

                        // Check this message has been de-queued
                        Assert.ThrowsException <MessageQueueReadException>(() => TransactionalDequeue <DownloadQueueItem>(downloadQueue));
                        Assert.ThrowsException <MessageQueueReadException>(() => TransactionalDequeue <DownloadQueueItem>(deadLetterQueue));
                    }
        }
Ejemplo n.º 4
0
        public async Task DicomDataReceiverServerStarts()
        {
            var applicationEntity = new GatewayApplicationEntity("RListenerTest", 191, "127.0.0.1");
            var resultsDirectory  = CreateTemporaryDirectory();

            using (var dicomDataReceiver = new ListenerDataReceiver(new ListenerDicomSaver(resultsDirectory.FullName)))
            {
                StartDicomDataReceiver(dicomDataReceiver, applicationEntity.Port);

                var eventCount = 0;
                var folderPath = string.Empty;

                dicomDataReceiver.DataReceived += (sender, e) =>
                {
                    folderPath = e.FolderPath;
                    Interlocked.Increment(ref eventCount);
                };

                Assert.ThrowsException <DicomNetworkException>(() => StartDicomDataReceiver(dicomDataReceiver, applicationEntity.Port));

                var dataSender = new DicomDataSender();
                var echoResult = await dataSender.DicomEchoAsync(
                    "RListener",
                    applicationEntity.Title,
                    applicationEntity.Port,
                    applicationEntity.IpAddress);

                // Check echo
                Assert.IsTrue(echoResult == DicomOperationResult.Success);

                DcmtkHelpers.SendFileUsingDCMTK(
                    @"Images\1ValidSmall\1.dcm",
                    applicationEntity.Port,
                    ScuProfile.LEExplicitCT,
                    TestContext);

                // Wait for all events to finish on the data received
                SpinWait.SpinUntil(() => eventCount >= 3, TimeSpan.FromSeconds(10));

                // Check the file exists
                Assert.IsTrue(File.Exists(Path.Combine(folderPath, @"1.2.840.113619.2.81.290.1.36662.3.1.20151027.220159.dcm")));

                dicomDataReceiver.StopServer();
            }
        }
        public async Task DicomSendFilesTest()
        {
            var dataSender        = new DicomDataSender();
            var applicationEntity = new GatewayApplicationEntity("RListenerTest", 131, "127.0.0.1");

            var dicomFiles = new DirectoryInfo(@"Images\1ValidSmall\").GetFiles().Select(x => DicomFile.Open(x.FullName)).ToArray();
            var rtFile     = await DicomFile.OpenAsync(@"Images\LargeSeriesWithContour\rtstruct.dcm").ConfigureAwait(false);

            var resultsDirectory = CreateTemporaryDirectory();

            using (var dicomDataReceiver = new ListenerDataReceiver(new ListenerDicomSaver(resultsDirectory.FullName)))
            {
                StartDicomDataReceiver(dicomDataReceiver, applicationEntity.Port);

                var results = await dataSender.SendFilesAsync(
                    "Hello",
                    applicationEntity.Title,
                    applicationEntity.Port,
                    applicationEntity.IpAddress,
                    dicomFiles).ConfigureAwait(false);

                foreach (var result in results)
                {
                    // Check we can send non-RT files
                    Assert.AreEqual(DicomOperationResult.Success, result.Item2);
                }

                var rtResult = await dataSender.SendFilesAsync(
                    "Hello",
                    applicationEntity.Title,
                    applicationEntity.Port,
                    applicationEntity.IpAddress,
                    rtFile).ConfigureAwait(false);

                Assert.AreEqual(1, rtResult.Count());

                foreach (var result in rtResult)
                {
                    // Check we can send RT files
                    Assert.AreEqual(DicomOperationResult.Success, result.Item2);
                }

                dicomDataReceiver.StopServer();
            }
        }
Ejemplo n.º 6
0
        public void DicomDataReceiverSamePort()
        {
            var applicationEntity = new GatewayApplicationEntity("RListenerTest", 120, "127.0.0.1");
            var resultsDirectory  = CreateTemporaryDirectory();

            using (var dicomDataReceiver1 = new ListenerDataReceiver(new ListenerDicomSaver(resultsDirectory.FullName)))
            {
                StartDicomDataReceiver(dicomDataReceiver1, applicationEntity.Port);

                using (var dicomDataReceiver2 = new ListenerDataReceiver(new ListenerDicomSaver(resultsDirectory.FullName)))
                {
                    Assert.ThrowsException <DicomNetworkException>(() => StartDicomDataReceiver(dicomDataReceiver2, applicationEntity.Port));

                    // Check you can start again and on a different port with the same AE title and IP address.
                    StartDicomDataReceiver(dicomDataReceiver2, applicationEntity.Port + 1);
                }
            }
        }
Ejemplo n.º 7
0
        public void DicomDataReceiverMutlipleAssociations()
        {
            const int numberOfAssociations = 10;
            const int port = 122;

            var applicationEntity = new GatewayApplicationEntity("RListenerTest", port, "127.0.0.1");
            var resultsDirectory  = CreateTemporaryDirectory();

            using (var dicomDataReceiver = new ListenerDataReceiver(new ListenerDicomSaver(resultsDirectory.FullName)))
            {
                StartDicomDataReceiver(dicomDataReceiver, applicationEntity.Port);

                var associationsReceivedCount = 0;
                var receivedAssociations      = new string[numberOfAssociations];

                dicomDataReceiver.DataReceived += (sender, e) =>
                {
                    if (e.ProgressCode == DicomReceiveProgressCode.AssociationEstablished)
                    {
                        receivedAssociations[int.Parse(e.DicomAssociation.CallingAE)] = e.DicomAssociation.CallingAE;
                        Interlocked.Increment(ref associationsReceivedCount);
                    }
                };

                Parallel.For(0, numberOfAssociations, i =>
                {
                    var dcmtkResult = DcmtkHelpers.SendFileUsingDCMTK(
                        @"Images\1ValidSmall\1.dcm",
                        port,
                        ScuProfile.LEExplicitCT,
                        TestContext,
                        waitForExit: false,
                        applicationEntityTitle: i.ToString());
                });

                SpinWait.SpinUntil(() => associationsReceivedCount == numberOfAssociations, TimeSpan.FromMinutes(1));

                for (var i = 0; i < numberOfAssociations; i++)
                {
                    Assert.IsTrue(receivedAssociations[i] == i.ToString());
                }
            }
        }
        public async Task DicomEchoTest()
        {
            var dataSender = new DicomDataSender();

            var applicationEntity = new GatewayApplicationEntity(
                title: "RListenerTest",
                port: new Random().Next(130, ApplicationEntityValidationHelpers.MaximumPortNumber),
                ipAddress: "127.0.0.1");

            var resultsDirectory = CreateTemporaryDirectory();

            using (var dicomDataReceiver = new ListenerDataReceiver(new ListenerDicomSaver(resultsDirectory.FullName)))
            {
                StartDicomDataReceiver(dicomDataReceiver, applicationEntity.Port);

                var result1 = await dataSender.DicomEchoAsync(
                    "Hello",
                    applicationEntity.Title,
                    applicationEntity.Port,
                    applicationEntity.IpAddress).ConfigureAwait(false);

                Assert.AreEqual(DicomOperationResult.Success, result1);

                dicomDataReceiver.StopServer();
            }

            var result2 = await dataSender.DicomEchoAsync(
                "Hello",
                applicationEntity.Title,
                applicationEntity.Port,
                applicationEntity.IpAddress).ConfigureAwait(false);

            Assert.AreEqual(DicomOperationResult.NoResponse, result2);

            // Try ping with IPv6 Address
            var result3 = await dataSender.DicomEchoAsync("Hello", "RListenerTest", 105, "2a00:1450:4009:800::200e").ConfigureAwait(false);

            Assert.AreEqual(DicomOperationResult.NoResponse, result3);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Pushes the Dicom files to the destination application entity.
        /// </summary>
        /// <param name="pushQueueItem">The queue item.</param>
        /// <param name="ownApplicationEntityTitle">Our own application entity tile.</param>
        /// <param name="destination">The destination.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <param name="dicomFiles">The Dicom files to push.</param>
        /// <returns>The async task.</returns>
        private async Task PushDicomFilesAsync(
            PushQueueItem pushQueueItem,
            string ownApplicationEntityTitle,
            GatewayApplicationEntity destination,
            CancellationToken cancellationToken,
            params DicomFile[] dicomFiles)
        {
            if (cancellationToken.IsCancellationRequested)
            {
                throw new TaskCanceledException();
            }

            if (dicomFiles.Length == 0)
            {
                LogError(LogEntry.Create(AssociationStatus.PushErrorFilesEmpty, pushQueueItem: pushQueueItem),
                         new ProcessorServiceException("No files to push."));
                return;
            }

            LogInformation(LogEntry.Create(AssociationStatus.Pushing,
                                           pushQueueItem: pushQueueItem,
                                           destination: GetDestination(destination)));

            var result = await _dicomDataSender.SendFilesAsync(
                ownApplicationEntityTitle,
                destination.Title,
                destination.Port,
                destination.IpAddress,
                dicomFiles).ConfigureAwait(false);

            if (result.Any(x => x.Item2 != DicomOperationResult.Success))
            {
                throw new ArgumentException("Failed to push");
            }

            LogInformation(LogEntry.Create(AssociationStatus.Pushed,
                                           pushQueueItem: pushQueueItem,
                                           destination: GetDestination(destination)));
        }
Ejemplo n.º 10
0
        public void DownloadServiceInvalidDownloadId()
        {
            var segmentationAnonymisationProtocol = SegmentationAnonymisationProtocol();

            var referenceDicomFiles = new DirectoryInfo(@"Images\1ValidSmall\")
                                      .GetFiles()
                                      .Select(x => DicomFile.Open(x.FullName))
                                      .CreateNewDicomFileWithoutPixelData(segmentationAnonymisationProtocol.Select(x => x.DicomTagIndex.DicomTag));

            var applicationEntity = new GatewayApplicationEntity("RListenerTest", 143, "127.0.0.1");

            using (var downloadService = CreateDownloadService(dequeueServiceConfig: GetTestDequeueServiceConfig(deadLetterMoveFrequencySeconds: 1000)))
                using (var downloadQueue = downloadService.DownloadQueue)
                    using (var deadLetterQueue = downloadService.DeadletterMessageQueue)
                    {
                        downloadService.Start();

                        TransactionalEnqueue(
                            downloadQueue,
                            new DownloadQueueItem(
                                segmentationId: Guid.NewGuid().ToString(),
                                modelId: Guid.NewGuid().ToString(),
                                resultsDirectory: CreateTemporaryDirectory().FullName,
                                referenceDicomFiles: referenceDicomFiles,
                                calledApplicationEntityTitle: applicationEntity.Title,
                                callingApplicationEntityTitle: applicationEntity.Title,
                                destinationApplicationEntity: applicationEntity,
                                tagReplacementJsonString: JsonConvert.SerializeObject(_defaultTagReplacement),
                                associationGuid: Guid.NewGuid(),
                                associationDateTime: DateTime.UtcNow,
                                isDryRun: false));

                        var message = TransactionalDequeue <DownloadQueueItem>(deadLetterQueue, timeoutMs: 60 * 1000);

                        Assert.IsNotNull(message);
                    }
        }
Ejemplo n.º 11
0
        public async Task DownloadServiceLiveCloudMockConfigEndToEndTest()
        {
            var resultDirectory = CreateTemporaryDirectory();

            var(segmentationId, modelId, data) = await StartFakeSegmentationAsync(@"Images\1ValidSmall\").ConfigureAwait(false);

            var applicationEntity = new GatewayApplicationEntity("RListenerTest", 140, "localhost");

            // Create a Data receiver to receive the RT struct result
            using (var dicomDataReceiver = new ListenerDataReceiver(new ListenerDicomSaver(CreateTemporaryDirectory().FullName)))
            {
                var eventCount = 0;
                var folderPath = string.Empty;

                dicomDataReceiver.DataReceived += (sender, e) =>
                {
                    folderPath = e.FolderPath;
                    Interlocked.Increment(ref eventCount);
                };

                StartDicomDataReceiver(dicomDataReceiver, applicationEntity.Port);

                using (var mockSegmentationClient = GetMockInnerEyeSegmentationClient())
                    using (var pushService = CreatePushService())
                        using (var downloadService = CreateDownloadService(mockSegmentationClient))
                            using (var downloadQueue = downloadService.DownloadQueue)
                            {
                                pushService.Start();
                                downloadService.Start();

                                TransactionalEnqueue(
                                    downloadQueue,
                                    new DownloadQueueItem(
                                        segmentationId: segmentationId,
                                        modelId: modelId,
                                        resultsDirectory: resultDirectory.FullName,
                                        referenceDicomFiles: data,
                                        calledApplicationEntityTitle: applicationEntity.Title,
                                        callingApplicationEntityTitle: applicationEntity.Title,
                                        destinationApplicationEntity: applicationEntity,
                                        tagReplacementJsonString: JsonConvert.SerializeObject(_defaultTagReplacement),
                                        associationGuid: Guid.NewGuid(),
                                        associationDateTime: DateTime.UtcNow,
                                        isDryRun: false));

                                // Wait for all events to finish on the data received
                                SpinWait.SpinUntil(() => eventCount >= 3, TimeSpan.FromMinutes(3));
                            }

                dicomDataReceiver.StopServer();

#pragma warning disable CA1508 // Avoid dead conditional code
                Assert.IsFalse(string.IsNullOrWhiteSpace(folderPath));
#pragma warning restore CA1508 // Avoid dead conditional code

                var files = new DirectoryInfo(folderPath).GetFiles();

                // Check we have a file
                Assert.AreEqual(1, files.Length);

                var dicomFile = await DicomFile.OpenAsync(files[0].FullName).ConfigureAwait(false);

                Assert.IsNotNull(dicomFile);
            }
        }
Ejemplo n.º 12
0
        public async Task DownloadServiceNoApiConnection()
        {
            var(segmentationId, modelId, data) = await StartFakeSegmentationAsync(@"Images\1ValidSmall\").ConfigureAwait(false);

            var applicationEntity = new GatewayApplicationEntity("RListenerTest", 144, "127.0.0.1");

            // Create a Data receiver to receive the RT struct result
            using (var dicomDataReceiver = new ListenerDataReceiver(new ListenerDicomSaver(CreateTemporaryDirectory().FullName)))
            {
                var eventCount = 0;
                var folderPath = string.Empty;

                dicomDataReceiver.DataReceived += (sender, e) =>
                {
                    folderPath = e.FolderPath;
                    Interlocked.Increment(ref eventCount);
                };

                StartDicomDataReceiver(dicomDataReceiver, applicationEntity.Port);

                using (var mockSegmentationClient = GetMockInnerEyeSegmentationClient())
                    using (var pushService = CreatePushService())
                        using (var downloadService = CreateDownloadService(mockSegmentationClient))
                            using (var downloadQueue = downloadService.DownloadQueue)
                                using (var deadLetterQueue = downloadService.DeadletterMessageQueue)
                                {
                                    // Fake a no response when getting progress
                                    mockSegmentationClient.SegmentationResultException = new HttpRequestException();

                                    pushService.Start();
                                    downloadService.Start();

                                    downloadQueue.Clear();

                                    TransactionalEnqueue(
                                        downloadQueue,
                                        new DownloadQueueItem(
                                            segmentationId: segmentationId,
                                            modelId: modelId,
                                            resultsDirectory: CreateTemporaryDirectory().FullName,
                                            referenceDicomFiles: data,
                                            calledApplicationEntityTitle: applicationEntity.Title,
                                            callingApplicationEntityTitle: applicationEntity.Title,
                                            destinationApplicationEntity: applicationEntity,
                                            tagReplacementJsonString: JsonConvert.SerializeObject(_defaultTagReplacement),
                                            associationGuid: Guid.NewGuid(),
                                            associationDateTime: DateTime.UtcNow,
                                            isDryRun: false));

                                    // Wait
                                    await Task.Delay(TimeSpan.FromSeconds(5)).ConfigureAwait(false);

                                    // Null the exception from the mock client
                                    mockSegmentationClient.SegmentationResultException = null;

                                    // Wait for all events to finish on the data received
                                    SpinWait.SpinUntil(() => eventCount >= 3, TimeSpan.FromMinutes(5));

                                    WaitUntilNoMessagesOnQueue(downloadQueue);

                                    // Check this message has been de-queued
                                    Assert.ThrowsException <MessageQueueReadException>(() => TransactionalDequeue <DownloadQueueItem>(downloadQueue));

                                    Assert.ThrowsException <MessageQueueReadException>(() => TransactionalDequeue <DownloadQueueItem>(deadLetterQueue));
                                }

                dicomDataReceiver.StopServer();

#pragma warning disable CA1508 // Avoid dead conditional code
                Assert.IsFalse(string.IsNullOrWhiteSpace(folderPath));
#pragma warning restore CA1508 // Avoid dead conditional code

                var files = new DirectoryInfo(folderPath).GetFiles();

                // Check we have a file
                Assert.AreEqual(1, files.Length);

                var dicomFile = await DicomFile.OpenAsync(files[0].FullName).ConfigureAwait(false);

                Assert.IsNotNull(dicomFile);
            }
        }
Ejemplo n.º 13
0
        public async Task PushServiceTest()
        {
            var tempFolder = CreateTemporaryDirectory();

            // Copy all files in the P4_Prostate directory to the temporary directory
            Directory.EnumerateFiles(@"Images\1ValidSmall\")
            .Select(x => new FileInfo(x))
            .ToList()
            .ForEach(x => x.CopyTo(Path.Combine(tempFolder.FullName, x.Name)));

            var applicationEntity = new GatewayApplicationEntity("RListenerTest", 108, "127.0.0.1");
            var resultDirectory   = CreateTemporaryDirectory();

            // Create a Data receiver to receive the RT struct result
            using (var dicomDataReceiver = new ListenerDataReceiver(new ListenerDicomSaver(resultDirectory.FullName)))
            {
                var eventCount = 0;

                dicomDataReceiver.DataReceived += (sender, e) =>
                {
                    Interlocked.Increment(ref eventCount);
                };

                StartDicomDataReceiver(dicomDataReceiver, applicationEntity.Port);

                var dataSender = new DicomDataSender();
                var echoResult = await dataSender.DicomEchoAsync("RListener", applicationEntity.Title, applicationEntity.Port, applicationEntity.IpAddress);

                // Check echo
                Assert.IsTrue(echoResult == DicomOperationResult.Success);

                var testAETConfigModel = GetTestAETConfigModel();

                using (var deleteService = CreateDeleteService())
                    using (var pushService = CreatePushService())
                        using (var pushQueue = pushService.PushQueue)
                        {
                            deleteService.Start();
                            pushService.Start();

                            TransactionalEnqueue(
                                pushQueue,
                                new PushQueueItem(
                                    destinationApplicationEntity: applicationEntity,
                                    calledApplicationEntityTitle: testAETConfigModel.CalledAET,
                                    callingApplicationEntityTitle: applicationEntity.Title,
                                    associationGuid: Guid.NewGuid(),
                                    associationDateTime: DateTime.UtcNow,
                                    filePaths: tempFolder.GetFiles().Select(x => x.FullName).ToArray()));

                            // Wait for all events to finish on the data received
                            SpinWait.SpinUntil(() => eventCount >= 3, TimeSpan.FromMinutes(3));

                            SpinWait.SpinUntil(() => new DirectoryInfo(tempFolder.FullName).Exists == false, TimeSpan.FromSeconds(30));

                            Assert.IsFalse(new DirectoryInfo(tempFolder.FullName).Exists);

                            Assert.AreEqual(20, resultDirectory.GetDirectories()[0].GetFiles().Length);
                        }
            }
        }
Ejemplo n.º 14
0
 private static (string ipAddress, string title, int port) GetDestination(GatewayApplicationEntity gatewayApplicationEntity) =>
 (gatewayApplicationEntity.IpAddress, gatewayApplicationEntity.Title, gatewayApplicationEntity.Port);