예제 #1
0
 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());
 }
예제 #2
0
 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);
 }
예제 #3
0
        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);
        }