public virtual void Duplex_10_DisconnectResponseReceiver() { ClientMock aClient = new ClientMock(MessagingSystemFactory, ChannelId); ServiceMock aService = new ServiceMock(MessagingSystemFactory, ChannelId); try { aService.InputChannel.StartListening(); aClient.OutputChannel.OpenConnection(); aService.WaitUntilResponseReceiversConnectNotified(1, 1000); aClient.WaitUntilConnectionOpenIsNotified(1000); //string aConnectedResponseReceiverId = aService.ConnectedResponseReceivers[0].ResponseReceiverId; aService.InputChannel.DisconnectResponseReceiver(aService.ConnectedResponseReceivers.First().ResponseReceiverId); aClient.WaitUntilConnectionClosedIsNotified(1000); //aService.WaitUntilAllResponseReceiversDisconnectNotified(1000); //Assert.AreEqual(aConnectedResponseReceiverId, aService.DisconnectedResponseReceivers[0].ResponseReceiverId); } finally { EneterTrace.Debug("CLEANING AFTER TEST"); aClient.OutputChannel.CloseConnection(); aService.InputChannel.StopListening(); // Wait for traces. Thread.Sleep(100); } }
public virtual void Duplex_13_DisconnectFromResponseReceiverConnected() { ClientMock aClient = new ClientMock(MessagingSystemFactory, ChannelId); ServiceMock aService = new ServiceMock(MessagingSystemFactory, ChannelId); aService.DoOnResponseReceiverConnected((x, y) => { if (MessagingSystemFactory is SynchronousMessagingSystemFactory == false) { aClient.WaitUntilConnectionOpenIsNotified(1000); } aService.InputChannel.DisconnectResponseReceiver(y.ResponseReceiverId); }); try { aService.InputChannel.StartListening(); // The ecent will try to close connection. aClient.OutputChannel.OpenConnection(); aClient.WaitUntilConnectionOpenIsNotified(1000); //aService.WaitUntilAllResponseReceiversDisconnectNotified(1000); aClient.WaitUntilConnectionClosedIsNotified(1000); } finally { EneterTrace.Debug("CLEANING AFTER TEST"); aClient.OutputChannel.CloseConnection(); aService.InputChannel.StopListening(); // Wait for traces. Thread.Sleep(100); } }
public virtual void Duplex_08_OpenFromConnectionClosed() { ClientMock aClient = new ClientMock(MessagingSystemFactory, ChannelId); bool anIsConnected = false; aClient.DoOnConnectionClosed((x, y) => { EneterTrace.Debug("DoOnConnectionClosed"); anIsConnected = aClient.OutputChannel.IsConnected; if (MessagingSystemFactory is SharedMemoryMessagingSystemFactory) { Thread.Sleep(300); } aClient.OutputChannel.OpenConnection(); }); ServiceMock aService = new ServiceMock(MessagingSystemFactory, ChannelId); try { aService.InputChannel.StartListening(); // Client opens the connection. aClient.OutputChannel.OpenConnection(); aClient.WaitUntilConnectionOpenIsNotified(1000); Assert.IsFalse(anIsConnected); aService.WaitUntilResponseReceiversConnectNotified(1, 1000); string aConnectedResponseReceiverId = aService.ConnectedResponseReceivers[0].ResponseReceiverId; aClient.ClearTestResults(); aService.ClearTestResults(); // Service disconnects the client. aService.InputChannel.DisconnectResponseReceiver(aConnectedResponseReceiverId); //aService.WaitUntilResponseRecieverIdDisconnectNotified(aConnectedResponseReceiverId, 1000); aClient.WaitUntilConnectionClosedIsNotified(3000); //Assert.AreEqual(aConnectedResponseReceiverId, aService.DisconnectedResponseReceivers[0].ResponseReceiverId); // Client should open the connection again. aClient.WaitUntilConnectionOpenIsNotified(1000); if (MessagingSystemFactory is SynchronousMessagingSystemFactory == false) { aService.WaitUntilResponseReceiversConnectNotified(1, 1000); } } finally { EneterTrace.Debug("CLEANING AFTER TEST"); aClient.OutputChannel.CloseConnection(); aService.InputChannel.StopListening(); // Wait for traces. Thread.Sleep(500); } }