public async Task ShouldCorrectlyIndicateIfNothingIsFound() { var response = new FeedlyRoot { Results = new List <FeedlyItem>() }; _searchService.Search("q").Returns(response); _searchViewModel.SearchQuery = "q"; _searchViewModel.Search.Execute().Subscribe(); await Task.Delay(100); _searchViewModel.IsGreeting.Should().BeFalse(); _searchViewModel.IsLoading.Should().BeFalse(); _searchViewModel.IsEmpty.Should().BeTrue(); _searchViewModel.Feeds.Should().BeEmpty(); }
public async Task ShouldTriggerFetchCommandWhenSearchQueryChanges() { var response = new FeedlyRoot { Results = new List <FeedlyItem> { new FeedlyItem() } }; _searchService.Search("q").Returns(response); _searchViewModel.SearchQuery = "q"; await Task.Delay(1100); _searchViewModel.IsGreeting.Should().BeFalse(); _searchViewModel.IsLoading.Should().BeFalse(); _searchViewModel.IsEmpty.Should().BeFalse(); _searchViewModel.Feeds.Count.Should().Be(1); }
public async Task ShouldNotifyOfPropertyChange() { var response = new FeedlyRoot { Results = new List <FeedlyItem>() }; _searchService.Search("q").Returns(response); var triggered = false; var notifyPropertyChanged = (INotifyPropertyChanged)(object)_searchViewModel; notifyPropertyChanged.PropertyChanged += delegate { triggered = true; }; _searchViewModel.SearchQuery = "q"; _searchViewModel.Search.Execute().Subscribe(); await Task.Delay(100); triggered.Should().BeTrue(); }
public async Task ShouldLoadItemsReceivedFromSearchService() { var response = new FeedlyRoot { Results = new List <FeedlyItem> { new FeedlyItem() } }; _searchService.Search("q").Returns(response); _searchViewModel.SearchQuery = "q"; _searchViewModel.Search.Execute().Subscribe(); await Task.Delay(100); _searchViewModel.IsGreeting.Should().BeFalse(); _searchViewModel.IsLoading.Should().BeFalse(); _searchViewModel.IsEmpty.Should().BeFalse(); _searchViewModel.Feeds.Count.Should().Be(1); await _searchService.Received().Search("q"); }
public async Task ShouldTryToAddFeedWhenInputIsCompletelyValid() { var handled = false; var item = new FeedlyItem { FeedId = "feed/http://google.com" }; var categories = new List <Category> { new Category { Title = "Foo" } }; var response = new FeedlyRoot { Results = new List <FeedlyItem> { item } }; _categoryManager.GetAll().Returns(categories); _searchService.Search("q").Returns(response); _searchViewModel.SearchQuery = "q"; _searchViewModel.Added.RegisterHandler(handle => handle.SetOutput(handled = true)); _searchViewModel.RefreshCategories.Execute().Subscribe(); _searchViewModel.Search.Execute().Subscribe(); await Task.Delay(100); _searchViewModel.IsLoading.Should().BeFalse(); _searchViewModel.Feeds.Should().NotBeEmpty(); _searchViewModel.SelectedCategory = _searchViewModel.Categories.First(); _searchViewModel.SelectedFeed = _searchViewModel.Feeds.First(); _searchViewModel.Add.Execute().Subscribe(); await _categoryManager.Received(1).Update(Arg.Any <Category>()); handled.Should().BeTrue(); }