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_06_OpenCloseConnection() { ClientMock aClient = new ClientMock(MessagingSystemFactory, ChannelId); ServiceMock aService = new ServiceMock(MessagingSystemFactory, ChannelId); try { aService.InputChannel.StartListening(); // Open the connection. aClient.OutputChannel.OpenConnection(); Assert.IsTrue(aClient.OutputChannel.IsConnected); // handling open connection on the client side. EneterTrace.Info("1"); aClient.WaitUntilConnectionOpenIsNotified(1000); Assert.AreEqual(aClient.OutputChannel.ChannelId, aClient.NotifiedOpenConnection.ChannelId); Assert.AreEqual(aClient.OutputChannel.ResponseReceiverId, aClient.NotifiedOpenConnection.ResponseReceiverId); // handling open connection on the service side. EneterTrace.Info("2"); aService.WaitUntilResponseReceiversConnectNotified(1, 1000); Assert.AreEqual(1, aService.ConnectedResponseReceivers.Count()); if (CompareResponseReceiverId) { Assert.AreEqual(aClient.OutputChannel.ResponseReceiverId, aService.ConnectedResponseReceivers[0].ResponseReceiverId); } aClient.OutputChannel.CloseConnection(); Assert.IsFalse(aClient.OutputChannel.IsConnected); EneterTrace.Info("3"); //aClient.WaitUntilConnectionClosedIsNotified(1000); //Assert.AreEqual(aClient.OutputChannel.ChannelId, aClient.NotifiedCloseConnection.ChannelId); //Assert.AreEqual(aClient.OutputChannel.ResponseReceiverId, aClient.NotifiedCloseConnection.ResponseReceiverId); EneterTrace.Info("4"); aService.WaitUntilAllResponseReceiversDisconnectNotified(1000); Assert.AreEqual(1, aService.DisconnectedResponseReceivers.Count()); if (CompareResponseReceiverId) { Assert.AreEqual(aClient.OutputChannel.ResponseReceiverId, aService.DisconnectedResponseReceivers.First().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_12_CloseFromConnectionOpened() { ClientMock aClient = new ClientMock(MessagingSystemFactory, ChannelId); aClient.DoOnConnectionOpen((x, y) => { if (MessagingSystemFactory is NamedPipeMessagingSystemFactory) { Thread.Sleep(500); } aClient.OutputChannel.CloseConnection(); }); ServiceMock aService = new ServiceMock(MessagingSystemFactory, ChannelId); try { aService.InputChannel.StartListening(); aClient.OutputChannel.OpenConnection(); aClient.WaitUntilConnectionOpenIsNotified(1000); if (MessagingSystemFactory is SynchronousMessagingSystemFactory == false) { aService.WaitUntilResponseReceiversConnectNotified(1, 5000); } // Client is disconnected. //aClient.WaitUntilConnectionClosedIsNotified(1000); // Client should be disconnected from the event handler. aService.WaitUntilAllResponseReceiversDisconnectNotified(2000); } 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); } }
public virtual void Duplex_06_OpenCloseOpenSend() { ClientMock aClient = new ClientMock(MessagingSystemFactory, ChannelId); ServiceMock aService = new ServiceMock(MessagingSystemFactory, ChannelId); aService.DoOnMessageReceived_SendResponse(myResponseMessage); try { aService.InputChannel.StartListening(); // Client opens the connection. aClient.OutputChannel.OpenConnection(); Assert.IsTrue(aClient.OutputChannel.IsConnected); aClient.WaitUntilConnectionOpenIsNotified(1000); Assert.AreEqual(aClient.OutputChannel.ChannelId, aClient.NotifiedOpenConnection.ChannelId); Assert.AreEqual(aClient.OutputChannel.ResponseReceiverId, aClient.NotifiedOpenConnection.ResponseReceiverId); aService.WaitUntilResponseReceiversConnectNotified(1, 1000); Assert.AreEqual(1, aService.ConnectedResponseReceivers.Count()); if (CompareResponseReceiverId) { Assert.AreEqual(aClient.OutputChannel.ResponseReceiverId, aService.ConnectedResponseReceivers[0].ResponseReceiverId); } // Client closes the connection. aClient.OutputChannel.CloseConnection(); Assert.IsFalse(aClient.OutputChannel.IsConnected); //aClient.WaitUntilConnectionClosedIsNotified(1000); //Assert.AreEqual(aClient.OutputChannel.ChannelId, aClient.NotifiedCloseConnection.ChannelId); //Assert.AreEqual(aClient.OutputChannel.ResponseReceiverId, aClient.NotifiedCloseConnection.ResponseReceiverId); aService.WaitUntilAllResponseReceiversDisconnectNotified(3000); Assert.AreEqual(1, aService.DisconnectedResponseReceivers.Count()); if (CompareResponseReceiverId) { Assert.AreEqual(aClient.OutputChannel.ResponseReceiverId, aService.DisconnectedResponseReceivers[0].ResponseReceiverId); } aClient.ClearTestResults(); aService.ClearTestResults(); // Client opens the connection 2nd time. aClient.OutputChannel.OpenConnection(); Assert.IsTrue(aClient.OutputChannel.IsConnected); aClient.WaitUntilConnectionOpenIsNotified(1000); Assert.AreEqual(aClient.OutputChannel.ChannelId, aClient.NotifiedOpenConnection.ChannelId); Assert.AreEqual(aClient.OutputChannel.ResponseReceiverId, aClient.NotifiedOpenConnection.ResponseReceiverId); aService.WaitUntilResponseReceiversConnectNotified(1, 1000); Assert.AreEqual(1, aService.ConnectedResponseReceivers.Count()); if (CompareResponseReceiverId) { Assert.AreEqual(aClient.OutputChannel.ResponseReceiverId, aService.ConnectedResponseReceivers[0].ResponseReceiverId); } // Client sends the message. aClient.OutputChannel.SendMessage(myRequestMessage); aClient.WaitUntilResponseMessagesAreReceived(1, 1000); Assert.AreEqual(myRequestMessage, aService.ReceivedMessages.First().Message); Assert.AreEqual(myResponseMessage, aClient.ReceivedMessages.First().Message); } finally { EneterTrace.Debug("CLEANING AFTER TEST"); aClient.OutputChannel.CloseConnection(); aService.InputChannel.StopListening(); // Wait for traces. Thread.Sleep(100); } }