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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }