Example #1
0
        public void ConvertComment_WithFeedBackItem_ConvertsBodyToBase64EncodedText()
        {
            // arrange
            var feedback = new FeedbackItem(FeedbackType.Comment)
            {
                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.ConvertComment(feedback);

            // assert
            Assert.AreEqual("213", comment.ID);
            Assert.AreEqual("Comment Title", comment.Title);
            Assert.IsTrue(comment.Approved);
            Assert.AreEqual("Anonymous Troll", comment.UserName);
            Assert.AreEqual("*****@*****.**", comment.UserEMail);
            Assert.AreEqual("http://subtextproject.com/", comment.UserUrl);
            Assert.AreEqual("<p>First!</p>", comment.Content.Text);
        }
Example #2
0
        public void ConvertComment_WithNullFeedBackItem_ThrowsArgumentNullException()
        {
            // arrange
            var subtextContext = new Mock <ISubtextContext>();
            var converter      = new BlogMLExportMapper(subtextContext.Object);

            // act, assert
            UnitTestHelper.AssertThrows <ArgumentException>(() => converter.ConvertComment(null));
        }
Example #3
0
        public void ConvertComment_WithFeedBackItemHavingNonCommentFeedbackType_ThrowsArgumentException()
        {
            // arrange
            var feedback       = new FeedbackItem(FeedbackType.PingTrack);
            var subtextContext = new Mock <ISubtextContext>();
            var converter      = new BlogMLExportMapper(subtextContext.Object);

            // act, assert
            UnitTestHelper.AssertThrows <ArgumentException>(() => converter.ConvertComment(feedback));
        }
        public void ConvertComment_WithDateModified_ConvertsToUtc()
        {
            // arrange
            DateTime dateModifiedUtc = DateTime.ParseExact("2009/08/15 11:00 PM", "yyyy/MM/dd hh:mm tt", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal).ToUniversalTime();
            var      feedback        = new FeedbackItem(FeedbackType.Comment)
            {
                DateModifiedUtc = dateModifiedUtc,
            };
            var subtextContext = new Mock <ISubtextContext>();
            var converter      = new BlogMLExportMapper(subtextContext.Object);

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

            // assert
            Assert.AreEqual(dateModifiedUtc, comment.DateModified);
        }
Example #5
0
        public void ConvertComment_WithDateCreated_ConvertsToUtc()
        {
            // arrange
            DateTime dateCreated    = DateTime.ParseExact("2009/08/15 05:00 PM", "yyyy/MM/dd hh:mm tt", CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal);
            DateTime dateCreatedUtc = DateTime.ParseExact("2009/08/15 11:00 PM", "yyyy/MM/dd hh:mm tt", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal);
            var      feedback       = new FeedbackItem(FeedbackType.Comment)
            {
                DateCreated = dateCreated,
            };
            var subtextContext = new Mock <ISubtextContext>();

            subtextContext.Setup(c => c.Blog.TimeZone.ToUtc(dateCreated)).Returns(dateCreatedUtc);
            var converter = new BlogMLExportMapper(subtextContext.Object);

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

            // assert
            Assert.AreEqual(dateCreatedUtc, comment.DateCreated);
        }
Example #6
0
        public void ConvertComment_WithFeedBackItem_ConvertsToBlogMlComment()
        {
            // arrange
            var feedback = new FeedbackItem(FeedbackType.Comment)
            {
                Id   = 213,
                Body = "<p><![CDATA[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.ConvertComment(feedback);

            // assert
            Assert.AreEqual("<p><![CDATA[First!]]></p>", comment.Content.UncodedText);
            Assert.AreEqual(ContentTypes.Base64, comment.Content.ContentType);
        }