public void ScuShallReceiveProposedTransferSyntaxes()
        {
            var testCase = "1-scu-with-multiple-transferSyntaxes";
            var queue    = new Queue <TaskResponse>();

            _dicomAdapterFixture.ResultsService.Setup(p => p.GetPendingJobs(It.IsAny <string>(), It.IsAny <CancellationToken>(), It.IsAny <int>()))
            .ReturnsAsync((string agent, CancellationToken token, int count) =>
            {
                if (agent != AET_ClaraSCU)
                {
                    return(null);
                }

                IList <TaskResponse> items = new List <TaskResponse>();
                while (queue.Count() > 0)
                {
                    items.Add(queue.Dequeue());
                }
                return(items);
            });

            string[] scpLogs   = null;
            var      fileCount = _testFileFixture.FileSetPaths[testCase].Count;

            using (var scp = new StoreScpWrapper("+xa", ScpPort))
            {
                AddToQueue(queue, testCase);
                int timeout = 0;
                while (_downloadCount < fileCount)
                {
                    Assert.InRange(timeout++, 0, 20 * fileCount);
                    Thread.Sleep(500);
                }

                timeout = 0;
                while ((_succeededCount + _failedCount) == 0)
                {
                    Assert.InRange(timeout++, 0, 20 * fileCount);
                    Thread.Sleep(500);
                }

                scpLogs = scp.GetLogs();
            }

            Thread.Sleep(500);

            scpLogs.Filter("Received Store Request")
            .Should()
            .HaveCount(fileCount);

            Assert.Equal(1, _succeededCount);
            Assert.Equal(0, _failedCount);
        }
        public void ScuShallRetryOnFailure(string testCase, string expectedScpError, string args, int receivedInstanceCount)
        {
            var queue = new Queue <TaskResponse>();

            _dicomAdapterFixture.ResultsService.Setup(p => p.GetPendingJobs(It.IsAny <string>(), It.IsAny <CancellationToken>(), It.IsAny <int>()))
            .ReturnsAsync((string agent, CancellationToken token, int count) =>
            {
                if (agent != AET_ClaraSCU)
                {
                    return(null);
                }
                IList <TaskResponse> items = new List <TaskResponse>();
                while (queue.Count() > 0)
                {
                    items.Add(queue.Dequeue());
                }
                return(items);
            });

            string[] scpLogs   = null;
            var      fileCount = _testFileFixture.FileSetPaths[testCase].Count;

            using (var scp = new StoreScpWrapper($"+x= {args}", ScpPort))
            {
                AddToQueue(queue, testCase);
                int timeout = 0;
                while (_downloadCount < fileCount)
                {
                    Assert.InRange(timeout++, 0, 20 * fileCount);
                    Thread.Sleep(500);
                }

                timeout = 0;
                while ((_succeededCount + _failedCount) == 0)
                {
                    Assert.InRange(timeout++, 0, 20 * fileCount);
                    Thread.Sleep(500);
                }

                scpLogs = scp.GetLogs();
            }

            scpLogs.Filter("Received Store Request")
            .Should()
            .HaveCount(receivedInstanceCount);

            scpLogs.Filter(expectedScpError)
            .Should()
            .HaveCountGreaterOrEqualTo(fileCount);

            Assert.Equal(0, _succeededCount);
            Assert.Equal(1, _failedCount);
        }
        public void ScuDownloadFailureFromPayloadShallNotCrash()
        {
            _dicomAdapterFixture.Payloads.Reset();
            _dicomAdapterFixture.Payloads.Setup(p => p.Download(It.IsAny <string>(), It.IsAny <string>()))
            .Throws(new Exception());

            var testCase = "1-scu-with-multiple-transferSyntaxes";
            var queue    = new Queue <TaskResponse>();

            _dicomAdapterFixture.ResultsService.Setup(p => p.GetPendingJobs(It.IsAny <string>(), It.IsAny <CancellationToken>(), It.IsAny <int>()))
            .ReturnsAsync((string agent, CancellationToken token, int count) =>
            {
                if (agent != AET_ClaraSCU)
                {
                    return(null);
                }
                IList <TaskResponse> items = new List <TaskResponse>();
                while (queue.Count() > 0)
                {
                    items.Add(queue.Dequeue());
                }
                return(items);
            });

            string[] scpLogs   = null;
            var      fileCount = _testFileFixture.FileSetPaths[testCase].Count;

            using (var scp = new StoreScpWrapper("+xa", ScpPort))
            {
                AddToQueue(queue, testCase);
                Thread.Sleep(3000);

                scpLogs = scp.GetLogs();
            }

            scpLogs.Filter("Received Store Request")
            .Should()
            .HaveCount(0);

            Assert.Equal(0, _succeededCount);
            Assert.Equal(1, _failedCount);
        }