public void GetPostAttachments_WithImageSrcAsRelativePath_ReturnsAttachment() { // arrange var subtextContext = new Mock <ISubtextContext>(); subtextContext.Setup(c => c.Blog).Returns(new Blog { Host = "test.example.com" }); subtextContext.Setup(c => c.UrlHelper.AppRoot()).Returns("/"); var converter = new BlogMLExportMapper(subtextContext.Object); // act var attachments = converter.GetPostAttachments(@"<em>Test <img src=""foo.jpg"" /></em>", false); // assert Assert.AreEqual(1, attachments.Count()); Assert.AreEqual("foo.jpg", attachments.First().Path); Assert.AreEqual("foo.jpg", attachments.First().Url); }
public void GetPostAttachments_WithBlogInVirtualAppFullyQualifiedImageSrcWithHostSameAsBlog_ReturnsAttachment() { // arrange var subtextContext = new Mock <ISubtextContext>(); subtextContext.Setup(c => c.Blog).Returns(new Blog { Host = "test.example.com" }); subtextContext.Setup(c => c.UrlHelper.AppRoot()).Returns("/Subtext.Web/"); var converter = new BlogMLExportMapper(subtextContext.Object); // act var attachments = converter.GetPostAttachments(@"<em>Test <img src=""http://test.example.com/subtext.web/images/foo.jpg"" /></em>", false); // assert Assert.AreEqual(1, attachments.Count()); Assert.AreEqual("/subtext.web/images/foo.jpg", attachments.First().Path); Assert.AreEqual("http://test.example.com/subtext.web/images/foo.jpg", attachments.First().Url); }