Пример #1
0
        public void ParceAddress_portIsNotNumerics_falsereturned()
        {
            // input data
            ParcedAddress parcedAddress   = new ParcedAddress();
            var           testInputString = "domaine:port";

            bool actual = Parcer.ParceAddress(testInputString, parcedAddress);

            Assert.IsFalse(actual);
        }
Пример #2
0
        public void ParceAddress_validDomaineAndPort_truereturned()
        {
            // input data
            ParcedAddress parcedAddress   = new ParcedAddress();
            var           testInputString = "domain:1234";

            bool actual = Parcer.ParceAddress(testInputString, parcedAddress);

            Assert.IsTrue(actual);
        }
Пример #3
0
        public void ParceAddress_withoutSplitter_falsereturned()
        {
            // input data
            ParcedAddress parcedAddress   = new ParcedAddress();
            var           testInputString = "domain1234";

            bool actual = Parcer.ParceAddress(testInputString, parcedAddress);

            Assert.IsFalse(actual);
        }
Пример #4
0
        private void buttonEnter_Click(object sender, EventArgs e)
        {
            if (loginBox.Text.Length == 0)
            {
                MessageBox.Show("Login field is empty");
                return;
            }

            if (passwordBox.Text.Length == 0)
            {
                MessageBox.Show("Password field is empty");
                return;
            }

            FormManager.Instance.GetForm(FormType.Contacts).AddOwnedForm(this);             // просто костыль. я щас слишком спать хочу чтоб разбираться, что оно делает и почему без него не работает.

            OperationStatus.Instance.AuthFeedback = false;
            OperationStatus.Instance.AuthSuccess  = false;

            ParcedAddress address = new ParcedAddress();

            if (!Parcer.ParceAddress(addressBox.Text, address))
            {
                // if parced failed
                MessageBox.Show("Address format error! Example: 127.0.0.1:6666");
                return;
            }

            conData    = new ConnectionData(address.IP, address.Port, loginBox.Text, passwordBox.Text);
            connection = new ServerConnection();

            Session.Instance.Data = conData;
            if (!connection.Open(conData.Address, conData.Port))
            {
                MessageBox.Show("Connection failed. Host " + conData.Address + ":" + conData.Port.ToString() + " not found.");
                return;
            }
            connection.StartListen();

            ConnectionService.Instance.StartHandling(connection);

            RequestQueue outputQueue = RequestRepository.Instance.OutputRequests;

            outputQueue.Enqueue(new AuthRequest(conData.Login, conData.Password));
            while (!OperationStatus.Instance.AuthFeedback)
            {
                // do nothing
                Thread.Sleep(100);
            }

            if (!OperationStatus.Instance.AuthSuccess)
            {
                MessageBox.Show("Incorrect login/password");
                ConnectionService.Instance.Close(connection);
                return;
            }
            else
            {
                FormManager.Instance.GetForm(FormType.Contacts).Show();
            }

            outputQueue.Enqueue(new ContactListRequest());

            outputQueue.Enqueue(new MessageRequest("test", "mainadmin"));             // debugging

            this.Hide();
        }