public void ValidateUrlGenerator() { var tokenRepository = new Mock <IRepository <Token> >(); var userRepository = new LocalRepository <InsideUser>(); var provider = new AccessTokenProvider(tokenRepository.Object, userRepository); var userId = "NewGuidString"; userRepository.Add(new InsideUser() { Id = userId }); var urlResult = provider.GenerateAccessUrl(userId, "www.return.url/Action"); tokenRepository.Verify(tr => tr.Add(It.IsAny <Token>()), Times.Once); tokenRepository.Verify(tr => tr.SaveChanges(), Times.Once); Assert.IsTrue(urlResult.Contains("&returnUrl=www.return.url%2fAction")); }
public ActionResult SendSms() { var jsonCoverter = new JsonUtcConverter(); var tokenRepository = new Repository <Token>(db => context.Token, context); var userRepository = new Repository <InsideUser>(db => context.InsideUser, context); var accessTokenProvider = new AccessTokenProvider(tokenRepository, userRepository); var url = accessTokenProvider.GenerateAccessUrl(User.Identity.GetUserId(), "/report/" + 10 + "/contact/" + 111818); var shortUrl = GetShortURL(url); string AccountSid = "ACf527710731ad6e3852be97b937c418b5"; string AuthToken = "51653777a7b97d349e0da8cb966359a1"; var twilio = new TwilioRestClient(AccountSid, AuthToken); var message = twilio.SendMessage("+46769438884", "0722524969", "Du har fått ett nytt telefonsamtal från 0722524969: " + shortUrl); return(Content(jsonCoverter.Serilize(message), "application/json")); }