예제 #1
0
파일: ChatForm.cs 프로젝트: ilia844/KSiS
 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;
 }
예제 #2
0
        public void Test_Connect_ReceivedDisconnectFromIMessageSender()
        {
            var mockConnection = Substitute.For <IMessageSender>();
            var client         = new ChatClient.Client(mockConnection);

            client.Disconnect();

            mockConnection.Received().Disconnect();
        }
예제 #3
0
        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);
        }