/// <summary>
        /// Post a story to a user timeline
        /// </summary>
        /// <param name="recipientUserName">Name of the user that owns the timeline in which you want to post the message</param>
        /// <param name="message">Massege you want to post to the timeline</param>
        public void Post(string recipientUserName, string message)
        {
            //Creates the story entity to post
            var story = new Story
            {
                Message = message,
                PostedOn = DateTime.Now
            };

            //Gets the user from the repository
            var user = userRepository.GetOrCreate(recipientUserName);

            //Adds the story to the user's timeline
            user.Timeline.Add(story);
        }
Beispiel #2
0
 public void Should_FormatStory_When_PostedYesterday()
 {
     var story = new Story { Message = "Yesterday's story", PostedOn = fakeTime.Date.AddDays(-1) };
     CoreTestLogic(story, "Yesterday's story (yesterday)");
 }
Beispiel #3
0
 public void Should_FormatStory_When_PostedSecondsAgo()
 {
     var story = new Story { Message = "Seconds ago story", PostedOn = fakeTime.AddSeconds(-10) };
     CoreTestLogic(story, "Seconds ago story (10 seconds ago)");
 }
Beispiel #4
0
 public void Should_FormatStory_When_PostedMinutesAgo()
 {
     var story = new Story { Message = "Minutes ago story", PostedOn = fakeTime.AddMinutes(-7) };
     CoreTestLogic(story, "Minutes ago story (7 minutes ago)");
 }
Beispiel #5
0
 public void Should_FormatStory_When_PostedHoursAgo()
 {
     var story = new Story { Message = "Hours ago story", PostedOn = fakeTime.AddHours(-4) };
     CoreTestLogic(story, "Hours ago story (4 hours ago)");
 }
Beispiel #6
0
 public void Should_FormatStory_When_PostedDaysAgo()
 {
     var story = new Story { Message = "Days ago story", PostedOn = fakeTime.AddDays(-10) };
     CoreTestLogic(story, "Days ago story (10 days ago)");
 }
Beispiel #7
0
 public void Should_FormatStory_When_PostedAnHourAgo()
 {
     var story = new Story { Message = "An hour ago story", PostedOn = fakeTime.AddMinutes(-70) };
     CoreTestLogic(story, "An hour ago story (1 hour ago)");
 }
Beispiel #8
0
 public void Should_FormatStory_When_PostedAMinuteAgo()
 {
     var story = new Story { Message = "A minute ago story", PostedOn = fakeTime.AddSeconds(-70) };
     CoreTestLogic(story, "A minute ago story (1 minute ago)");
 }
Beispiel #9
0
        /// <summary>
        /// Common test logic called by all the test cases in this class
        /// </summary>
        /// <param name="arrangedStory">Input story to be formatted by the SUT</param>
        /// <param name="expectedResult">Output expected from the SUT</param>
        private void CoreTestLogic(Story arrangedStory, string expectedResult)
        {
            string actual;

            // Arrange
            using (var shimsContext = ShimsContext.Create())
            {
                //Sets a fake fixed time in order to better check the elapsed string returned by the formatter
                System.Fakes.ShimDateTime.NowGet = () => fakeTime;

                // Act
                actual = sut.Format(arrangedStory);
            }

            //Assert
            Assert.AreEqual(expectedResult, actual, "Formatted story different than expected");
        }