public void Search_querySetSearchTypeName_returnsResults()
 {
     List<PhoneBookSearchResult> expected = new List<PhoneBookSearchResult>();
     expected.Add( new PhoneBookSearchResult() );
     var provider = new Mock<IPhoneBookSearchProvider>();
     provider.Setup( p => p.GetEntriesForQuery( It.IsAny<string>() ) ).Returns( expected );
     var search = new PhoneBookSearch( provider.Object );
     var query = new PhoneBookQuery() {
         SearchType = Library.Enums.SearchType.Name,
         StringToSearch = "test"
     };
     var results = search.Search( query );
     provider.Verify( p => p.GetEntriesForQuery( "test" ), Times.Once() );
     Assert.AreEqual( expected.Count, results.Count );
 }
Esempio n. 2
0
 private static PhoneBookSearch GenerateSearcherForQueryType( 
     ADConfiguration config, Library.Enums.SearchType type)
 {
     var searcher = null as PhoneBookSearch;
     switch(type) {
         case Library.Enums.SearchType.Department:
             searcher = new PhoneBookSearch( new DepartmentADPhoneBookSearchProvider( config ) );
             break;
         case Library.Enums.SearchType.PhoneNumber:
             searcher = new PhoneBookSearch( new PhoneNumberADPhoneBookSearchProvider( config ) );
             break;
         case Library.Enums.SearchType.Name:
         default:
             searcher = new PhoneBookSearch( new NameADPhoneBookSearchProvider( config ) );
             break;
     }
     return searcher;
 }
 public void Search_queryNull_throwsArgumentNullException()
 {
     var provider = new Mock<IPhoneBookSearchProvider>();
     var search = new PhoneBookSearch( provider.Object );
     var results = search.Search( null );
 }
 public void Constructor_providerSet_providerSet()
 {
     var provider = new Mock<IPhoneBookSearchProvider>();
     var search = new PhoneBookSearch( provider.Object );
     Assert.IsNotNull( search.Provider );
 }
 public void Constructor_providerNull_throwsArgumentNullException()
 {
     var search = new PhoneBookSearch( null );
 }
 private List<PhoneBookSearchResult> TriggerSearchForType( Library.Enums.SearchType type )
 {
     var query = new PhoneBookQuery() {
         SearchType = type,
         StringToSearch = tbSearch.Text
     };
     switch (type) {
         case Library.Enums.SearchType.Department:
             m_searcher = new PhoneBookSearch( new DepartmentADPhoneBookSearchProvider( m_config ) );
             break;
         case Library.Enums.SearchType.PhoneNumber:
             m_searcher = new PhoneBookSearch( new PhoneNumberADPhoneBookSearchProvider( m_config ) );
             break;
         case Library.Enums.SearchType.Name:
         default:
             m_searcher = new PhoneBookSearch( new NameADPhoneBookSearchProvider( m_config ) );
             break;
     }
     return m_searcher.Search( query );
 }
 private void CleanUpSearchResults()
 {
     m_searcher = null;
     if (null != this.SearchResults) {
         this.SearchResults.Clear();
         this.SearchResults = null;
     }
 }