private void searchButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         //Searchs for books and lists matches below to aid updating
         BookSearch search = new BookSearch(books, people, searchTextBox.Text.Trim());
         search.SearchAllFields();
         booksListBox.DataContext = search.FoundBooks;
     }
     catch (Exception ex)
     {
         errorLabel.Content = ErrorHandler.InnermostExceptionMessage(ex);
     }
 }
Example #2
0
        public void TestSearchAllFieldsForISBN()
        {
            //Arrange
            PersonBLLCollection people = CreatePersonBLLCollection();
            BookBLLCollection   books  = CreateBookCollection();

            string query = "3003";
            //Act
            BookSearch search = new BookSearch(books, people, query);

            search.SearchAllFields();

            //Assert
            Assert.AreEqual(1, search.FoundBooks.Count);
        }
Example #3
0
        public void TestSearchForWordNotThere()
        {
            //Arrange
            PersonBLLCollection people = CreatePersonBLLCollection();
            BookBLLCollection   books  = CreateBookCollection();

            string query = "Zebra";

            //Act
            BookSearch search = new BookSearch(books, people, query);

            search.SearchAllFields();

            //Assert
            Assert.AreEqual(0, search.FoundBooks.Count);
        }
Example #4
0
        private void searchButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (searchTextBox.Text == "")
                {
                    errorLabel.Content = "Please enter terms to search for books, including ISBN,\nsubject, words from the title, or author's name.";
                    searchTextBox.Focus();
                }
                else
                {
                    string     searchQuery = searchTextBox.Text.Trim();
                    BookSearch newQuery    = new BookSearch(books, people, searchQuery);
                    newQuery.SearchAllFields();
                    ResetFields();

                    this.NavigationService.Navigate(new SearchResultsPage(newQuery));
                }
            }
            catch (Exception ex)
            {
                errorLabel.Content = ErrorHandler.InnermostExceptionMessage(ex);
            }
        }