Esempio n. 1
0
        public void Search_Book_by_word_Test()
        {
            string     book_word   = "Book";
            Book       book3       = new Book("Book", "Author");
            StudLibSys studLibSys5 = new StudLibSys();

            studLibSys5.Add_Book(book3);

            Assert.IsNotNull(studLibSys5.Search_Book_by_word(book_word));
        }
Esempio n. 2
0
        public void Delete_Book_Test()
        {
            string     book_name1   = "Books";
            string     book_author1 = "Author";
            Book       book1        = new Book(book_name1, book_author1);
            StudLibSys studLibSys1  = new StudLibSys();

            studLibSys1.Add_Book(book1);
            studLibSys1.Delete_Book(book1);

            Assert.IsNull(studLibSys1.Search_Book_by_word(book1.Book_Name));
        }
Esempio n. 3
0
        public void Change_Book_Test()
        {
            string     new_book_name   = "qwerty123";
            string     new_book_author = "New_Author";
            int        option1         = 1;
            int        option2         = 2;
            Book       book2           = new Book("qwerty", "author");
            StudLibSys studLibSys2     = new StudLibSys();

            studLibSys2.Add_Book(book2);
            studLibSys2.Change_Book(book2, new_book_name, option1);
            studLibSys2.Change_Book(book2, new_book_author, option2);

            Assert.AreEqual(new_book_name, book2.Book_Name);
            Assert.AreEqual(new_book_author, book2.Book_Author);
        }
Esempio n. 4
0
        //створення нової книги
        private void Button_New_Book(object sender, RoutedEventArgs e)
        {
            try
            {
                string pattern = @"[А-ЯЇІЄҐ]{1}[а-яїієґ]{2,15}";
                if (Regex.IsMatch(New_Book_Name.Text, pattern))
                {
                    if (Regex.IsMatch(New_Book_Author.Text, pattern))
                    {
                        Book book = new Book(New_Book_Name.Text, New_Book_Author.Text);
                        studLibSys.Add_Book(book);
                    }
                    else
                    {
                        throw new Exception("Автора книги написано неправильно");
                    }
                }
                else
                {
                    throw new Exception("Назву книги написано неправильно");
                }
                ListView_Books.Items.Refresh();
                New_Book_Name.Text              = "";
                New_Book_Author.Text            = "";
                Add_Book.Visibility             = Visibility.Visible;
                Give_Out_Book.Visibility        = Visibility.Visible;
                Book_Delete.Visibility          = Visibility.Visible;
                Add_book_btn.Visibility         = Visibility.Hidden;
                New_Book_Name.Visibility        = Visibility.Hidden;
                New_Book_Author.Visibility      = Visibility.Hidden;
                Btn_Back.Visibility             = Visibility.Hidden;
                New_Book_Name_Text.Visibility   = Visibility.Hidden;
                New_Book_Author_Text.Visibility = Visibility.Hidden;
                Search_Btn.Visibility           = Visibility.Visible;
                Search_TextBox.Visibility       = Visibility.Visible;
                Back_Search_Btn.Visibility      = Visibility.Hidden;
                Search_TextBlock.Visibility     = Visibility.Visible;

                throw new Exception("Книгу успішно створено!");
            }
            catch (Exception l)
            {
                MessageBox.Show(l.Message);
            }
        }