public async void ShouldIgnoreEmptyOrNullSearchString() { var vm = new RepoSearchViewModel(); await vm.Refresh(); GitHubClientMock.Verify(m => m.Search.SearchRepo(It.IsAny<SearchRepositoriesRequest>()), Times.Never()); Assert.AreEqual(0, vm.SearchResults.Count()); }
public void ShouldRefreshOnSearchStringChangeAndUpdateSearchResults() { var vm = new RepoSearchViewModel(); vm.SearchString = "search"; GitHubClientMock.Verify(m => m.Search.SearchRepo(It.Is<SearchRepositoriesRequest>(sr => sr.Term == "search")), Times.Once()); Assert.AreEqual(1, vm.SearchResults.Count()); Assert.AreEqual(1337, vm.SearchResults.FirstOrDefault().Id); }
public async void ShouldSearchOnSearchCommand() { var vm = new RepoSearchViewModel { SearchString = "search" }; await vm.SearchCommand.Execute(); // refreshes once when search string changed, then again when command executed GitHubClientMock.Verify(m => m.Search.SearchRepo(It.IsAny<SearchRepositoriesRequest>()), Times.Exactly(2)); Assert.AreEqual(1, vm.SearchResults.Count()); Assert.AreEqual(1337, vm.SearchResults.FirstOrDefault().Id); }