private void btDisconnect_Click(object sender, EventArgs e) { client?.SendMessage(new LANMessage(MessageType.ClientExit, client.ClientId, tbName.Text)); client?.Disconnect(); client = null; btDisconnect.Enabled = false; btSendMessage.Enabled = false; foreach (DialogInfo dialog in communityData.Dialogs.Values) { dialog.IsActive = false; } UpdateParticipants(); btConnect.Enabled = true; cbIsConnected.Checked = false; tbName.ReadOnly = false; tbPassword.ReadOnly = false; }
public void Test_Connect_ReceivedDisconnectFromIMessageSender() { var mockConnection = Substitute.For <IMessageSender>(); var client = new ChatClient.Client(mockConnection); client.Disconnect(); mockConnection.Received().Disconnect(); }
public void Test_Disconnect_GoodDisconnect() { var stubSender = Substitute.For <IMessageSender>(); var client = new ChatClient.Client(stubSender); stubSender.IsConnected.Returns(false); client.Disconnect(); Assert.IsFalse(client.IsConnected); }