public async Task ZeroAnagramSolvesLeftForIp() { Settings.MaxAnagramsForIp = 2; _logRepoMock.GetTimesIpMadeAction(Arg.Any <string>(), Arg.Any <UserActionTypes>()).Returns(1, 0, 1, 0); var result = await _logService.CountAnagramsLeftForIpToSolve(); await _logRepoMock.Received(4).GetTimesIpMadeAction(Arg.Any <string>(), Arg.Any <UserActionTypes>()); Assert.AreEqual(0, result); }
public async Task <int> CountAnagramsLeftForIpToSolve() { var ip = GetUserIp(); var timesSearched = await _userLogRepository.GetTimesIpMadeAction(ip, UserActionTypes.GetAnagrams); var timesNewWordAdded = await _userLogRepository.GetTimesIpMadeAction(ip, UserActionTypes.InsertWord); var timesWordDeleted = await _userLogRepository.GetTimesIpMadeAction(ip, UserActionTypes.DeleteWord); var timesWordUpdated = await _userLogRepository.GetTimesIpMadeAction(ip, UserActionTypes.UpdateWord); var timesLeftToSearch = Settings.MaxAnagramsForIp - timesSearched - timesWordDeleted + timesWordUpdated + timesNewWordAdded; return(timesLeftToSearch); }