public void SearchTest() { BookSearch bookSearch = new BookSearch(); var result = bookSearch.Search("Spinning Silver"); Assert.AreEqual(result != null, true); }
public async void SearchAsync() { StartSearch = true; SearchResult = null; CanLoadMore = false; _searchQuery = Query; _busyIndicatorManager.Start(); List <BookSearchResult> items; try { items = await _bookSearch.Search(_book, _searchQuery, LOAD_COUNT); } catch (SearchInBookInterruptedException) { //skip search an interrupted exception (it has occurred after FAS), search will be repeated at OnActivate return; } finally { _busyIndicatorManager.Stop(); } SearchResult = new BindableCollection <SearchInBookResultItemDataModel>( items.Select(result => _searchController.ToDataModel(result, _searchQuery, BookId))); CanLoadMore = items.Count >= LOAD_COUNT; }
public ActionResult BookSearch(string query) { BookSearch bookSearch = new BookSearch(); List <BookModel> bookModels = bookSearch.Search(query); return(View(bookModels)); }
public void SearchesBooks() { void ShouldSearch(string input, BookInfo expected) { BookInfo result = BookSearch.Search(input); Assert.AreEqual(expected.Title, result.Title); Assert.AreEqual(expected.Author, result.Author); Assert.AreEqual(expected.ISBN, result.ISBN); } ShouldSearch("Brandon Sanderson - Mistborn 02 - The Well of Ascension pt 1", new BookInfo() { Title = "The Well of Ascension (Mistborn, Book 2)", Author = "Brandon Sanderson", ISBN = "9780765316882" }); }
internal static void InsertNewBooks(IEnumerable <ScannedBook> books) { using (var db = new HonyomiContext()) { foreach (ScannedBook book in books) { if (!db.Books.Any(x => x.DirectoryPath == book.Path)) { var ibook = new IndexedBook() { DirectoryPath = book.Path, Title = book.Name }; var bookInfo = book.Files.Select(x => BookSearch.Search(x.Name)).FirstOrDefault(x => x != null); if (bookInfo != null) { ibook.Author = bookInfo.Author; ibook.ISBN = bookInfo.ISBN; ibook.Title = bookInfo.Title; } else if (book.Files.Count > 1) { ibook.Title = Util.LCS(book.Files[0].Name, book.Files[1].Name); } var files = book.Files.Select(x => new IndexedFile() { TrackIndex = x.Index, Filename = x.Name, Title = x.Name, FilePath = x.Path, MimeType = x.MimeType, Duration = x.Duration.TotalSeconds }).ToList(); ibook.Files = files; db.Books.Add(ibook); } } db.SaveChanges(); } }