Example #1
0
        public void GivenThatAliceAndBobHavePostedAMessage_WhenBobSeeHisWall_BothMessagesAppears()
        {
            var userService = new Mock<UserService>();
            var codurer = new Codurer(userService.Object);
            var alice = "Alice";
            var aliceMessageText = "AliceMessage";
            var aliceMessage = new Message(alice, aliceMessageText, DateTime.Now.AddMinutes(-5), null);
            var aliceMessages = new ReadOnlyCollection<Message>(
                            new List<Message> { aliceMessage });

            var bob = "Bob";
            var bobMessageText = "Bob message";
            var bobMessage = new Message(bob, bobMessageText, DateTime.Now.AddMinutes(-2), null);
            var bobMessages = new ReadOnlyCollection<Message>(
                            new List<Message> { bobMessage });

            userService.Setup(uService => uService.GetMessagesFrom(alice)).Returns(aliceMessages);
            userService.Setup(uService => uService.GetMessagesFromFollowingUsersFrom(alice)).Returns(bobMessages);

            codurer.Follow(alice, bob);

            IEnumerable<string> wall = codurer.GetWall(alice);

            wall.Should().HaveCount(2);
            wall.First().Should().Contain(bob);
            wall.Skip(1).Take(1).First().Should().Contain(alice);
        }
Example #2
0
        public void GivenAMessagePostedOneSecondAgo_FormatReturnsTheMessagePlus1SecondAgo()
        {
            var message = new Message(userName, messageText, DateTime.Now.AddSeconds(-1), formatRules);

            var result = message.Format();

            result.Should().Be(messageText + " (1 second ago)");
        }
Example #3
0
        public void GivenAMessagePostedMoreThanOneSecondAgoAndLessThanOneMinuteAgo_FormatReturnsTheMessagePlusSeconds()
        {
            var message = new Message(userName, messageText, DateTime.Now.AddSeconds(-2), formatRules);

            var result = message.Format();

            result.Should().Be(messageText + " (2 seconds ago)");
        }
Example #4
0
        public void GivenAMessagePostedLessThanOneSecondAgo_FormatReturnsTheMessagePlusNow()
        {
            var message = new Message(userName, messageText, DateTime.Now, formatRules);

            var result = message.Format();

            result.Should().Be(messageText + " (now)");
        }
Example #5
0
 internal void AddMessage(Message message)
 {
     messages.Add(message);
 }
Example #6
0
 private static string FormatMessageForWall(Message message)
 {
     return string.Format("{0} - {1}", message.UserName, message.Format());
 }