private void Search() { IsBusy = true; // a search string is required. if it's empty, set it to "all" if (string.IsNullOrWhiteSpace(SearchString)) { SearchString = "*"; } // create our search client var client = new AzureSearchClient(); // after we load the search results & set the facet collections, two way binding will clear the currently selected facet. // we'll store these temporarily and reapply them later var sourceFacet = SourceFacet; var retweetsFacet = RetweetsFacet; var followingFacet = FollowingFacet; var followersFacet = FollowersFacet; DocumentSearchResponse <MarchMadnessTweet> searchResult = null; var executionTime = string.Empty; Task.Run(async delegate { var start = DateTime.Now; searchResult = await client.Search <MarchMadnessTweet>(SearchString, SearchField, SourceFacet, RetweetsFacet, FollowingFacet, FollowersFacet); var end = DateTime.Now; executionTime = (end.Subtract(start)).TotalMilliseconds.ToString("#####.##") + " milliseconds"; }).Wait(); SearchExecutionTime = executionTime; Tweets = searchResult.Results.ToObservableCollection(); SourceFacets = searchResult.Facets["source"].Where(f => f.Count > 0).ToObservableCollection(); RetweetsFacets = searchResult.Facets["retweets"].Where(f => f.Count > 0).ToObservableCollection(); FollowingFacets = searchResult.Facets["following"].Where(f => f.Count > 0).ToObservableCollection(); FollowersFacets = searchResult.Facets["followers"].Where(f => f.Count > 0).ToObservableCollection(); SourceFacet = sourceFacet; RetweetsFacet = retweetsFacet; FollowingFacet = followingFacet; FollowersFacet = followersFacet; IsBusy = false; }
public async Task Search_WithNullQuery_ThrowsException() { Func <Task <Core.Search.SearchResult <object> > > action = () => _client.Search(null as IAzureSearchQuery <object>); await action.Should().ThrowExactlyAsync <ArgumentNullException>(); }