public void CreateFileFromAttachment_WithOutEmbeddedAttachment_RewritesPostContent() { // arrange var attachment = new BlogMLAttachment { Url = "http://old.example.com/images/my-mug.jpg", Embedded = false }; string attachmentDirectoryPath = ImageDirectory; Directory.CreateDirectory(attachmentDirectoryPath); const string originalPostContent = @"<img src=""http://old.example.com/images/my-mug.jpg"" />"; // act string postContent = BlogImportService.CreateFileFromAttachment(attachment, attachmentDirectoryPath, "http://example.com/images/", originalPostContent); // assert Assert.AreEqual(@"<img src=""http://example.com/images/my-mug.jpg"" />", postContent); }
public void CreateFileFromAttachment_WithEmbeddedAttachment_CreatesFile() { // arrange var data = new byte[] { 1, 2, 3 }; var attachment = new BlogMLAttachment { Url = "http://old.example.com/images/my-mug.jpg", Embedded = true, Data = data }; string attachmentDirectoryPath = Path.Combine(Environment.CurrentDirectory, "images"); Directory.CreateDirectory(ImageDirectory); // act BlogImportService.CreateFileFromAttachment(attachment, attachmentDirectoryPath, "http://example.com/images/", "Some Content"); // assert Assert.IsTrue(File.Exists(Path.Combine(ImageDirectory, "my-mug.jpg"))); }