public void IntegrationCheckAddToDatabase()
        {
            string table    = "users";
            string login    = "******";
            string password = "******";
            string name     = "name1231112";
            int    expID    = 100;

            //var mock = new Mock<InteractionDB>();
            string connectionStr = "server = localhost;user = root; database = test_pm_database; password = root";
            //string connectionStr = "server=localhost;user=root;database=PM_DB;password=root";
            MySqlConnection connection = new MySqlConnection(connectionStr);

            connection.Close();
            connection.Open();

            //string commandStr = "create table users ( id INT, login   varchar(50), username varchar(30), pass    varchar(100)); ";
            //MySqlCommand command = new MySqlCommand("drop table users", connection);
            //MySqlCommand command = new MySqlCommand(commandStr, connection);

            InteractionDB interactionDB = new InteractionDB(connection);

            bool rez = interactionDB.AddToDB(table, "'" + login + "','" + name + "','" + password + "'");

            connection.Open();
            MySqlCommand    command = new MySqlCommand("Select * from " + table + " where login = '******' and pass = '******'", connection);
            MySqlDataReader reader  = command.ExecuteReader();

            Assert.IsTrue(rez, "Function AddToDB returned value 'false'");
            Assert.IsTrue(reader.Read(), "User exist in table ");
            connection.Close();
        }
Exemple #2
0
        private void butComplete_Click(object sender, EventArgs e)
        {
            try
            {
                Client   cl           = Client.getInstance();
                int      ID           = InteractionDB.CountNextID();
                DateTime DateOfBirth  = DateTime.Parse(textBoxDateOfBirth.Text);
                DateTime PassportDate = DateTime.Parse(textBoxPassportDate.Text);
                string   gender;
                if (checkBoxFemale.Checked == true)
                {
                    gender = "женский";
                }
                else
                {
                    gender = "мужской";
                }
                string education = null;
                foreach (object item in checkedListBoxEducation.SelectedItems)
                {
                    education += item.ToString();
                    education += "/";
                }
                switch (checkedListBoxFamily.SelectedIndex)
                {
                case 0:
                    Family = "Женат/Замужем";

                    break;

                case 1:
                    Family = "Холост/Не замужем";
                    break;

                case 2:
                    Family = "Гражданский брак";
                    break;

                case 3:
                    Family = "Разведен/Разведена";
                    break;

                case 4:
                    Family = "Вдова/Вдовец";
                    break;
                }
                cl.CreateSQLQuery(textBoxLogin.Text, textBoxPassword.Text, textBoxSurname.Text, textBoxName.Text, textBoxPatronymic.Text,
                                  DateOfBirth, textBoxPlaceOfBirth.Text, textBoxINN.Text, gender, textBoxPassportSeries.Text, textBoxPassportNumber.Text,
                                  PassportDate, textBoxPassportCode.Text, textBoxPassportPlace.Text, textBoxPhoneNumber.Text, textBoxHomeNumber.Text,
                                  textBoxEmail.Text, education, Family, textBoxAdressIndex.Text, textBoxAdressRegion.Text, textBoxAdressArea.Text, textBoxAdressCity.Text);
                InteractionDB.AddClient(cl);
                this.Close();
                AuthLink.Visible = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Проверьте вводимые значения!", "Ошибка при выполнении");
            }
        }
        public void IntegrationCheckGetUserByID()
        {
            string table    = "users";
            string login    = "******";
            string password = "******";
            string name     = "name112";
            int    expID    = 100;

            string          connectionStr = "server = localhost;user = root; database = test_pm_database; password = root";
            MySqlConnection connection    = new MySqlConnection(connectionStr);

            connection.Close();
            connection.Open();

            string commandStr = "insert into users(id, login, pass, username) values (" + expID.ToString() + ",'" + login + "','" + password + "','" + name + "'";

            InteractionDB interactionDB = new InteractionDB(connection);

            int rez = interactionDB.GetIDByUsername(name);

            Assert.AreEqual(rez, expID, "expID is {0} but no {1}", expID, rez);
            connection.Close();
        }