public void Search_Users_by_word_Test() { string user_word = "Dima"; User user3 = new User("Dima", "Holubenko", 220); StudLibSys studLibSys4 = new StudLibSys(); studLibSys4.Add_User(user3); Assert.IsNotNull(studLibSys4.Search_Users_by_word(user_word)); }
//створення нового користувача private void Button_New_User(object sender, RoutedEventArgs e) { try { string pattern = @"[А-ЯЇІЄҐ]{1}[а-яїієґ]{2,15}"; if (Regex.IsMatch(New_First_Name.Text, pattern)) { if (Regex.IsMatch(New_Last_Name.Text, pattern)) { if (int.Parse(New_Acad_Group.Text) > 0) { User user = new User(New_First_Name.Text, New_Last_Name.Text, int.Parse(New_Acad_Group.Text)); studLibSys.Add_User(user); } else { throw new Exception("Неправильний номер групи"); } } else { throw new Exception("Прізвище написано неправильно"); } } else { throw new Exception("Ім'я написано неправильно"); } ListView_Users.Items.Refresh(); New_First_Name.Text = ""; New_Last_Name.Text = ""; New_Acad_Group.Text = ""; Add_User.Visibility = Visibility.Visible; User_Delete.Visibility = Visibility.Visible; New_First_Name.Visibility = Visibility.Hidden; New_Last_Name.Visibility = Visibility.Hidden; New_Acad_Group.Visibility = Visibility.Hidden; Add_user_btn.Visibility = Visibility.Hidden; Btn_Back.Visibility = Visibility.Hidden; New_First_Name_Text.Visibility = Visibility.Hidden; New_Last_Name_Text.Visibility = Visibility.Hidden; New_Acad_Group_Text.Visibility = Visibility.Hidden; Search_Btn.Visibility = Visibility.Visible; Search_TextBox.Visibility = Visibility.Visible; Search_TextBlock.Visibility = Visibility.Visible; throw new Exception("Користувач успішно створений!"); } catch (Exception l) { MessageBox.Show(l.Message); } }
public void Delete_User_Test() { List <User> users = new List <User>(); string first_name1 = "Dimaaaa"; string last_name1 = "Holubenko"; int acad_group1 = 220; User user1 = new User(first_name1, last_name1, acad_group1); StudLibSys studLibSys = new StudLibSys(); studLibSys.Add_User(user1); studLibSys.Delete_User(user1); Assert.IsNull(studLibSys.Search_Users_by_word(first_name1)); }
public void Change_User_Test() { string new_first_name = "Firts_Name"; string new_last_name = "Last_Name"; string new_acad_group = "321"; int option1 = 1; int option2 = 2; int option3 = 3; User user2 = new User("User", "Dima", 123); StudLibSys studLibSys3 = new StudLibSys(); studLibSys3.Add_User(user2); studLibSys3.Change_User(user2, new_first_name, option1); studLibSys3.Change_User(user2, new_last_name, option2); studLibSys3.Change_User(user2, new_acad_group, option3); Assert.AreEqual(new_first_name, user2.First_Name); Assert.AreEqual(new_last_name, user2.Last_Name); Assert.AreEqual(Int32.Parse(new_acad_group), user2.Acad_Group); }