Exemplo n.º 1
0
        public void TestGoogleBookSearch()
        {
            string[] searchTerms = new string[] { "Harry Potter", "Spongebob", "Herr der Ringe" };
            ObservableCollection <Book> books = null;

            foreach (var item in searchTerms)
            {
                books = GoogleBookSearch.SearchBooks(item).GetAwaiter().GetResult();
                Assert.AreEqual(10, books.Count);
            }

            books = GoogleBookSearch.SearchBooks("asdasdadasdadaa").GetAwaiter().GetResult();
            Assert.AreEqual(0, books.Count);
        }
        public BookSearchViewModel()
        {
            SearchCommand = new DelegateCommand(async p =>
            {
                //Buchsuche
                _searchTriggered?.Invoke(this, EventArgs.Empty);
                Books = await GoogleBookSearch.SearchBooks(SearchTerm);
            },
                                                p =>
                                                //Wann kann die Suche angestoßen werden?
                                                !string.IsNullOrWhiteSpace(SearchTerm)
                                                );

            BookSelectedCommand = new DelegateCommand(p =>
            {
                if (p is Book book)
                {
                    //TODO: ViewModel bauen
                    TodoViewModel model = new TodoViewModel(book);
                    ServicesHelper.NavigationService.Navigate(Interfaces.NavigationTarget.TodoItems, model);
                }
            });
        }