public void Should_Not_Call_Words_Repository_When_No_Word_Is_Received(string searchValue)
        {
            _wordsRepository.GetSearchedWords(searchValue).Returns(new List <WordResponseModel> {
            });

            _dictionaryController.Search(searchValue);

            _wordsRepository.DidNotReceive().GetSearchedWords(searchValue);
        }
Beispiel #2
0
        public IActionResult Search(string search)
        {
            if (search != null && search.Length > 0)
            {
                _dictionaryModel.wordsDictionary = _wordsRepository.GetSearchedWords(search);
                _dictionaryModel.SearchString    = search;
            }

            return(View(_dictionaryModel));
        }
 public IActionResult Find(string searchValue)
 {
     try
     {
         List <WordResponseModel> searchResults = _wordsRepository.GetSearchedWords(searchValue);
         if (searchResults.Count > 0)
         {
             return(Ok(new { words = searchResults }));
         }
         else
         {
             return(NotFound("No words matching search string were found."));
         }
     } catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }