예제 #1
0
        public async Task ReleaseAsync_AfterAssociation_SendIsCompleted()
        {
            int port = Ports.GetNext();

            using (DicomServer.Create <MockCEchoProvider>(port))
            {
                var client = new DicomClient();
                client.AddRequest(new DicomCEchoRequest());
                var task = client.SendAsync("127.0.0.1", port, false, "SCU", "ANY-SCP");

                client.WaitForAssociation();

                await client.ReleaseAsync();

                Thread.Sleep(10);
                Assert.True(task.IsCompleted);
            }
        }
예제 #2
0
        public async Task ReleaseAsync_AfterAssociation_SendIsCompleted()
        {
            int port = Ports.GetNext();
            using (DicomServer.Create<MockCEchoProvider>(port))
            {
                var client = new DicomClient();
                client.AddRequest(new DicomCEchoRequest());
                var task = client.SendAsync("127.0.0.1", port, false, "SCU", "ANY-SCP");

                client.WaitForAssociation();

                await client.ReleaseAsync();
                Thread.Sleep(10);
                Assert.True(task.IsCompleted);
            }
        }
예제 #3
0
        //[InlineData(100)]
        public async Task SendAsync_MultipleTimes_AllRecognized(int expected)
        {
            int port = Ports.GetNext();

            using (var server = DicomServer.Create<DicomCEchoProvider>(port))
            {
                while (!server.IsListening) await Task.Delay(50);

                var actual = 0;

                var client = new DicomClient();
                for (var i = 0; i < expected; i++)
                {
                    client.AddRequest(new DicomCEchoRequest { OnResponseReceived = (req, res) => Interlocked.Increment(ref actual) });
                    await client.SendAsync("127.0.0.1", port, false, "SCU", "ANY-SCP");
                }

                await client.ReleaseAsync();
                Assert.Equal(expected, actual);
            }
        }