public TwitterService Create(User user) { var isAuthenticated = user != null && !string.IsNullOrEmpty(user.AuthData.Secret) && !string.IsNullOrEmpty(user.AuthData.Token); if (!isAuthenticated) return new TwitterService(Config.Twitter.ConsumerKey, Config.Twitter.ConsumerSecret); return new TwitterService(Config.Twitter.ConsumerKey, Config.Twitter.ConsumerSecret, user.AuthData.Token, user.AuthData.Secret); }
public AuthenticatedHomePageViewModel(User user, ITwitterFactory twitter) { Email = user.Email; var twitterUser = twitter.CurrentUser; if (twitterUser == null) throw new InvalidOperationException("twitterUser was not found or was just null"); ProfilePicUrl = twitterUser.ProfileImageUrl; TwitterHandle = twitterUser.ScreenName; var service = twitter.Create(); if (twitterUser == null) throw new InvalidOperationException("Twitter service was null or just couldn't be constructed"); Favorites = service.ListFavoriteTweets(2, 5); }
public EmailResult LoginEmail(User model) { model.LoginKey = Guid.NewGuid(); userRepository.Save(model); Subject = "Welcome to TweetDigest"; From = "*****@*****.**"; To.Add(model.Email); return Email("LoginEmail", new LoginEmailViewModel { TwitterHandle = model.TwitterHandles.FirstOrDefault() ?? model.Email, ReturnKey = model.LoginKey.Value }); }
public void It_sends_login_email_when_twitter_creds_are_already_stored() { var user = new User { AuthData = new TwitterAuthData {Secret = "foo", Token = "bar"} }; mocker.Use<IUserRepository>(x => x.GetByEmail("*****@*****.**") == user); mocker.Use<IMailController>(x => x.LoginEmail(user) == new EmailResult(Mock.Of<IMailInterceptor>(), Mock.Of<IMailSender>(), new MailMessage(), string.Empty, string.Empty, Encoding.Default, false)); Sut.Index(new SetEmailViewModel {UserEmail = "*****@*****.**"}); mocker.Verify<IMailController>(x => x.LoginEmail(user)); }
public IEnumerable<TwitterStatus> GetFavoritesForUser(User user) { var twitterService = twitterFactory.Create(user); return twitterService.ListFavoriteTweets(); }
public void Save(User user) { users.Save(user); }
private AuthenticatedHomePageViewModel GetAuthenticatedHomePageViewModel(User user) { return new AuthenticatedHomePageViewModel(user, twitterFactory); }