public void GetAnagrams_IfUserWithIpIsRegistered_ShouldNotSetUserAgain() { User user = new User() { Id = 1, UserIp = ip, SearchesLeft = 0 }; _userManagingService.CheckIfRegistered(ip).Returns(true); var result = _anagramsSearchService.GetAnagrams("test", ip); _userContract.DidNotReceive().SetUser(ip); }
public AnagramsSearchInfoModel GetAnagrams(string requestWord, string userIp) { var anagramsSearchInfoModel = new AnagramsSearchInfoModel(); if (!_userManagingService.CheckIfRegistered(userIp)) { _userContract.SetUser(userIp); } anagramsSearchInfoModel.isValidToSearch = _userManagingService.CheckIfValidToSearch(userIp); if (!anagramsSearchInfoModel.isValidToSearch) { return(anagramsSearchInfoModel); } if (_cachedWords.CheckIfCached(requestWord)) { _logger.Log(requestWord, userIp); anagramsSearchInfoModel.Anagrams = _cachedWords.GetCachedAnagrams(requestWord); return(anagramsSearchInfoModel); } anagramsSearchInfoModel.Anagrams = _anagramSolver.GetAnagrams(requestWord).ToList(); _requestWordContract.SetRequestWord(requestWord); _cachedWords.SetCachedAnagrams(anagramsSearchInfoModel.Anagrams, requestWord); _logger.Log(requestWord, userIp); return(anagramsSearchInfoModel); }