public void UpsertRespondentVkontakte_CorrectRoutinesCalled()
        {
            var service = Create();

            _userValidation.ValidateToken(Arg.Is <string>(z => z == "A")).Returns(true);
            RespondentUser respondentUser = new RespondentUser();

            _respondentsRepository.CreateNew().Returns(respondentUser);
            _respondentsRepository.FindById(Arg.Is(respondentUser.Id)).Returns(respondentUser);

            service.UpsertRespondentVkontakte("A", 120, "25081d7553e5fab");

            Thread.Sleep(10);
            _respondentsRepository.Received().FindByVkontakteId(Arg.Is(120));
            _vksocialNetworkGrabber.Received().Enqueue(Arg.Any <int>(), Arg.Is <string>("25081d7553e5fab"));
            _respondentsRepository.Received().Save(Arg.Any <RespondentUser>());
        }
示例#2
0
        public long UpsertRespondentFacebook(string token, string facebookId, string fbAccessToken)
        {
            if (!_userValidation.ValidateToken(token))
            {
                throw new AddressAccessDeniedException();
            }
            _log.Information($"{GetCurrentMethod()} called.");

            var respondent = _respondentsRepository.FindByFacebookId(facebookId);

            if (respondent == null)
            {
                respondent      = _respondentsRepository.CreateNew();
                respondent.FbId = facebookId;
                _respondentsRepository.Save(respondent);
            }

            _log.Information($"[{token}] Request for fb info respId {respondent?.Id ?? -1}, {fbAccessToken}");
            _gfb.Enqueue(respondent.Id, fbAccessToken);
            return(respondent.Id);
        }