public UserInfoService(IHttpManagerService httpManagerService, IConfiguration configuration, IUserInfoRepository userInfoRepository) { _userInfoRepository = userInfoRepository; _httpManagerService = httpManagerService; _userIP = _httpManagerService.GetIP(); Configuration = configuration; }
public void Should_ReturnSearchAmount_When_IPNotNull() { //mock _httpManagerService.GetIP().Returns(_userIP); _userInfoRepository.CheckForUserIP(Arg.Any <string>()).Returns(_userIP); _userInfoRepository.GetSearchesByIP(Arg.Any <string>()).Returns(50); _userInfoService = new UserInfoService(_httpManagerService, configuration, _userInfoRepository); //call var result = _userInfoService.GetUserInfo(); //compare var expected = 50; Assert.AreEqual(expected, result); //check if _userInfoRepository.Received().CheckForUserIP(_userIP); _userInfoRepository.Received().GetSearchesByIP(Arg.Any <string>()); }