public void ConvertTrackback_WithNullFeedBackItem_ThrowsArgumentNullException()
        {
            // arrange
            var subtextContext = new Mock<ISubtextContext>();
            var converter = new BlogMLExportMapper(subtextContext.Object);

            // act, assert
            UnitTestHelper.AssertThrows<ArgumentException>(() => converter.ConvertTrackback(null));
        }
        public void ConvertTrackback_WithFeedBackItemHavingNonTrackbackFeedbackType_ThrowsArgumentException()
        {
            // arrange
            var feedback = new FeedbackItem(FeedbackType.Comment);
            var subtextContext = new Mock<ISubtextContext>();
            var converter = new BlogMLExportMapper(subtextContext.Object);

            // act, assert
            UnitTestHelper.AssertThrows<ArgumentException>(() => converter.ConvertTrackback(feedback));
        }
        public void ConvertTrackback_WithFeedBackItem_ConvertsToBlogMlComment()
        {
            // arrange
            var feedback = new FeedbackItem(FeedbackType.PingTrack)
            {
                Id = 213,
                Title = "Comment Title",
                Approved = true,
                Author = "Anonymous Troll",
                Email = "*****@*****.**",
                SourceUrl = new Uri("http://subtextproject.com/"),
                Body = "<p>First!</p>",
            };
            var subtextContext = new Mock<ISubtextContext>();
            subtextContext.Setup(c => c.Blog).Returns(new Blog());
            var converter = new BlogMLExportMapper(subtextContext.Object);

            // act
            var comment = converter.ConvertTrackback(feedback);

            // assert
            Assert.AreEqual("213", comment.ID);
            Assert.AreEqual("Comment Title", comment.Title);
            Assert.IsTrue(comment.Approved);
            Assert.AreEqual("http://subtextproject.com/", comment.Url);
        }
        public void ConvertTrackback_WithDateModified_ConvertsDateModifiedToUtc()
        {
            // arrange
            DateTime dateModified = DateTime.ParseExact("2009/08/15 05:00 PM", "yyyy/MM/dd hh:mm tt", CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal);
            DateTime dateModifiedUtc = DateTime.ParseExact("2009/08/15 11:00 PM", "yyyy/MM/dd hh:mm tt", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal);

            var dateCreated = DateTime.Now.AddDays(-1);
            var feedback = new FeedbackItem(FeedbackType.PingTrack)
            {
                Id = 213,
                Title = "Comment Title",
                Approved = true,
                Author = "Anonymous Troll",
                Email = "*****@*****.**",
                SourceUrl = new Uri("http://subtextproject.com/"),
                Body = "<p>First!</p>",
                DateCreated = dateCreated,
                DateModified = dateModified
            };
            var subtextContext = new Mock<ISubtextContext>();
            subtextContext.Setup(c => c.Blog.TimeZone.ToUtc(dateModified)).Returns(dateModifiedUtc);
            var converter = new BlogMLExportMapper(subtextContext.Object);

            // act
            var comment = converter.ConvertTrackback(feedback);

            // assert
            Assert.AreEqual(dateModifiedUtc, comment.DateModified);
        }