Example #1
0
        public int GetUserInfo()
        {
            var checkIP = _userInfoRepository.CheckForUserIP(_userIP);

            if (checkIP == null)
            {
                NewUser();
            }
            return(_userInfoRepository.GetSearchesByIP(_userIP));
        }
        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>());
        }