public IActionResult Index(string id = null) { List <string> anagrams = new List <string>(); if (String.IsNullOrEmpty(id)) { foreach (var cookie in Request.Cookies) { if (cookie.Key == "inputWord") { return(View(_anagramSolver.GetAnagrams(cookie.Value).ToList())); } } return(View()); } else { CookieOptions options = new CookieOptions { Expires = DateTime.Now.AddDays(1) }; Response.Cookies.Append("inputWord", id, options); } AnagramsSearchInfoModel anagramsSearchResult = _anagramsSearchService.GetAnagrams(id, HttpContext.Connection.LocalIpAddress.ToString()); if (!anagramsSearchResult.isValidToSearch) { return(View("NotAllowedToSearch")); } return(View(anagramsSearchResult.Anagrams)); //return View(_cachedWordsService.CacheWords(id, HttpContext.Connection.LocalIpAddress.ToString())); }
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); }