Ejemplo n.º 1
0
        public void WaitForAssociation_WithinTimeout_ReturnsTrue()
        {
            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");

                var actual = client.WaitForAssociation(10000);
                task.Wait(10000);
                Assert.True(actual);
            }
        }
Ejemplo n.º 2
0
        public void WaitForAssociation_Aborted_ReturnsFalse()
        {
            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.Abort();
                var actual = client.WaitForAssociation(500);

                Assert.Equal(false, actual);
            }
        }
Ejemplo n.º 3
0
        public void Release_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();

                client.Release();
                Thread.Sleep(10);
                Assert.True(task.IsCompleted);
            }
        }
Ejemplo n.º 4
0
        public void WaitForAssociation_TooShortTimeout_ReturnsFalse()
        {
            var port = Ports.GetNext();

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

                var actual = client.WaitForAssociation(1);
                task.Wait(1000);
                Assert.False(actual);
            }
        }
Ejemplo n.º 5
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);
            }
        }
Ejemplo n.º 6
0
        public void WaitForAssociation_Aborted_ReturnsFalse()
        {
            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.Abort();
                var actual = client.WaitForAssociation(500);

                Assert.Equal(false, actual);
            }
        }
Ejemplo n.º 7
0
        public void WaitForAssociation_WithinTimeout_ReturnsTrue()
        {
            int port = Ports.GetNext();
            using (new DicomServer<MockCEchoProvider>(port))
            {
                var client = new DicomClient();
                client.AddRequest(new DicomCEchoRequest());
                var task = client.SendAsync("127.0.0.1", port, false, "SCU", "ANY-SCP");

                var actual = client.WaitForAssociation(10000);
                task.Wait(10000);
                Assert.Equal(true, actual);
            }
        }