public void DisplayUserWallHasMessagesAndFollowersMessagesTest()
        {
            // act
            string input = "Charlie";
            var user = new User { UserId = Guid.NewGuid(), Username = input };
            var userMessages = new List<Message>
            {
                new Message
                {
                    Description = "I’m in New York today! Anyone wants to have a coffee?",
                    PostedDt = DateTime.UtcNow.AddSeconds(-15),
                    UserId = user.UserId
                }
            };

            var child = new User { UserId = Guid.NewGuid(), Username = "******" };
            var followers = new List<User> { child };
            var followersMessages = new List<Message>
            {
                new Message
                {
                    Description = "Good game though.",
                    PostedDt = DateTime.UtcNow.AddMinutes(-1),
                    UserId = child.UserId
                },
                new Message
                {
                    Description = "Damn! We lost!",
                    PostedDt = DateTime.UtcNow.AddMinutes(-2),
                    UserId = child.UserId
                }
            };

            var output = new StringBuilder();
            output.AppendLine("Charlie - I’m in New York today! Anyone wants to have a coffee? (15 second(s) ago)");
            output.AppendLine("Bob - Good game though. (1 minute(s) ago)");
            output.AppendLine("Bob - Damn! We lost! (2 minute(s) ago)");

            _userManagerMock.Setup(x => x.GetUserByUsername("Charlie", true)).Returns(user);
            _messageManagerMock.Setup(x => x.GetMessages(user)).Returns(userMessages);
            _userManagerMock.Setup(x => x.GetFollowers(user)).Returns(followers);
            _messageManagerMock.Setup(x => x.GetMessages(child)).Returns(followersMessages);
            _userManagerMock.Setup(x => x.GetUserByUserId(user.UserId, true)).Returns(user);
            _userManagerMock.Setup(x => x.GetUserByUserId(child.UserId, true)).Returns(child);

            var wall = new Wall(_userManagerMock.Object, _messageManagerMock.Object);

            // actual
            var actual = wall.Perform(input);

            // assert
            Assert.AreEqual(actual, output.ToString());
            _userManagerMock.VerifyAll();
            _messageManagerMock.VerifyAll();
        }
        public void FollowMultipleNewUserTest()
        {
            // act
            string input = "Charlie follows Alice";
            var parent = new User { Username = "******" };
            var child = new User { Username = "******" };

            _userManagerMock.Setup(x => x.GetUserByUsername(parent.Username, true)).Returns(parent);
            _userManagerMock.Setup(x => x.GetUserByUsername(child.Username, true)).Returns(child);
            _userManagerMock.Setup(x => x.CheckFollowerExists(parent, child));
            _userManagerMock.Setup(x => x.FollowUser(parent, child));

            var follow = new Follow(_userManagerMock.Object);

            // actual
            var actual = follow.Perform(input);

            // assert
            Assert.AreEqual(actual, string.Empty);
            _userManagerMock.Verify(x => x.FollowUser(parent, child), Times.Once);
        }
        public void FollowAlreadyFollowedUserTest()
        {
            // act
            string input = "Charlie follows Alice";

            var parent = new User { Username = "******" };
            var child = new User { Username = "******" };
            var children = new List<User> { child };

            _userManagerMock.Setup(x => x.GetUserByUsername(parent.Username, true)).Returns(parent);
            _userManagerMock.Setup(x => x.GetUserByUsername(child.Username, true)).Returns(child);
            _userManagerMock.Setup(x => x.CheckFollowerExists(parent, child)).Throws(new Exception("Alice already followed!"));

            var follow = new Follow(_userManagerMock.Object);

            // actual
            var actual = follow.Perform(input);

            // assert
            Assert.AreEqual(actual, "Alice already followed!");
        }
        public void DisplayUserWallHasNoMessagesAndNoFollowersTest()
        {
            // act
            string input = "Alice";
            var user = new User { UserId = Guid.NewGuid(), Username = input };
            var userMessages = new List<Message>();

            _userManagerMock.Setup(x => x.GetUserByUsername("Alice", true)).Returns(user);
            _messageManagerMock.Setup(x => x.GetMessages(user)).Returns(userMessages);

            var wall = new Wall(_userManagerMock.Object, _messageManagerMock.Object);

            // actual
            var actual = wall.Perform(input);

            // assert
            Assert.AreEqual(actual, string.Empty);
        }
        public void DisplayUserWallHasNoMessagesAndHasFollowersWithMessagesTest()
        {
            // act
            string input = "Alice";
            var user = new User { UserId = Guid.NewGuid(), Username = input };
            var child = new User { UserId = Guid.NewGuid(), Username = "******" };
            var userMessages = new List<Message>();

            var followers = new List<User> {child};
            var followersMessages = new List<Message> { new Message
            {
                Description = "Good game though.",
                PostedDt = DateTime.UtcNow.AddMinutes(-1),
                UserId = child.UserId
            } };

            var output = new StringBuilder();
            output.AppendLine("Bob - Good game though. (1 minute(s) ago)");

            _userManagerMock.Setup(x => x.GetUserByUsername("Alice", true)).Returns(user);
            _messageManagerMock.Setup(x => x.GetMessages(user)).Returns(userMessages);
            _userManagerMock.Setup(x => x.GetFollowers(user)).Returns(followers);
            _messageManagerMock.Setup(x => x.GetMessages(child)).Returns(followersMessages);
            _userManagerMock.Setup(x => x.GetUserByUserId(child.UserId, true)).Returns(child);

            var wall = new Wall(_userManagerMock.Object, _messageManagerMock.Object);

            // actual
            var actual = wall.Perform(input);

            // assert
            Assert.AreEqual(actual, output.ToString());
            _userManagerMock.VerifyAll();
            _messageManagerMock.VerifyAll();
        }