private void buttonRegister_Click(object sender, EventArgs e) { try { ValidateRegister.isUserNameValid(textBoxUsername.Text); UserName = textBoxUsername.Text; ValidateRegister.areFirstAndLastNameValid(textBoxFirstName.Text, textBoxFirstName.Text); FirstName = textBoxFirstName.Text; LastName = textBoxLastName.Text; ValidateRegister.isPasswordCorrect(textBoxPassword.Text); Password = textBoxPassword.Text; ValidateRegister.isEMailCorrect(textBoxEmail.Text); Email = textBoxEmail.Text; if (radioButtonMale.Checked == true) { Gender = "M"; ValidateRegister.isGenderValid(Gender); } if (radioButtonFemale.Checked == true) { Gender = "F"; ValidateRegister.isGenderValid(Gender); } ValidateRegister.isAgeValid(int.Parse(comboBoxAge.Text)); Age = int.Parse(comboBoxAge.Text); if (rp.RegisterUser()) { this.Hide(); mainForm.ShowForm(); this.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Invalid input", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void isUserValidThrowsException() { Assert.Throws <IncorrectUserDataException>(() => ValidateRegister.isUserNameValid("Pesho!")); }