public PostCommand(User user, ITweetsRepository tweetsRepository, ParsedInput parsedInput, TextWriter textWriter) { _user = user; _tweetsRepository = tweetsRepository; _parsedInput = parsedInput; _textWriter = textWriter; }
public WallCommand(User user, ITweetsRepository tweetsRepository, TextWriter textWriter, ParsedInput parsedInput) { _user = user; _tweetsRepository = tweetsRepository; _textWriter = textWriter; _parsedInput = parsedInput; }
public ICommand Create(User user, ParsedInput parsedInput, ITweetsRepository tweetsRepository, TextWriter textWriter) { switch (parsedInput.CommandType) { case CommandType.Read: { return new ReadCommand(user, tweetsRepository, textWriter, parsedInput); } case CommandType.Follow: { return new FollowCommand(user, new User(parsedInput.RequiredAction), textWriter); } case CommandType.Wall: { return new WallCommand(user, tweetsRepository, textWriter, parsedInput); } case CommandType.Post: default: { return new PostCommand(user, tweetsRepository, parsedInput, textWriter); } } }
public string FormatTweets(User user, bool isWall) { var formattedOutput = new StringBuilder(); var aggregatedList = _tweetsRepository.GetTweets(user).ToList(); if (isWall) { foreach (var followedUser in user.Following) { formattedOutput.AppendLine($"{user.Name} follows {followedUser.Name}"); aggregatedList.AddRange(_tweetsRepository.GetTweets(followedUser)); } } aggregatedList = aggregatedList.OrderByDescending(tweet => tweet.DatePublished).ToList(); foreach (var tweet in aggregatedList) { var dateDiff = (_currentTime - tweet.DatePublished); formattedOutput.AppendLine( $"{tweet.User.Name} - {tweet.Message} ({DateTimeHelper.GetFriendlyRelativeTime(dateDiff)})"); } return formattedOutput.ToString(); }
public FollowCommand(User user, User userToFollow, TextWriter textWriter) { _user = user; _userToFollow = userToFollow; _textWriter = textWriter; }
public IEnumerable<Tweet> GetTweets(User user) { return Tweets.Where(tweet => tweet.User.Name.Equals(user.Name, StringComparison.CurrentCultureIgnoreCase)); }
public void WhenTheyFollowUser(string userToFollow) { famousUser = new User(userToFollow); _user.Follow(famousUser); }
public void GivenAUserHasAnAccount(string username) { _user = new User(username); _timeline = new Timeline(_tweetsRepository, _today); }
public void GivenTheUserHasFollowed(string username, string userToFollow) { User user = _usersRepository.GetUser(username); User famousUser = new User(userToFollow); user.Following.Add(famousUser); }
IEnumerable<Tweet> GetTweets(User user) { return _tweetsRepository.GetTweets(user); }
public void Follow(User follower) { Following.Add(follower); }
public Tweet(User user, string message, DateTime datePublished) { User = user; Message = message; DatePublished = datePublished; }