Пример #1
0
        public void AddImagesToView_adds_linked_resources()
        {
            var embedder = new ImageEmbedder(s => new LinkedResource(new MemoryStream()));
            var cid = embedder.ReferenceImage("test.png");
            using (var view = AlternateView.CreateAlternateViewFromString("<img src=\"cid:" + cid.ContentId + "\" />", new ContentType("text/html")))
            {
                embedder.AddImagesToView(view);

                view.LinkedResources.Count.ShouldEqual(1);
                view.LinkedResources[0].ShouldBeSameAs(cid);
            }
        }
        public void AddImagesToView_adds_linked_resources()
        {
            var embedder = new ImageEmbedder(s => new LinkedResource(new MemoryStream()));
            var cid      = embedder.ReferenceImage("test.png");

            using (var view = AlternateView.CreateAlternateViewFromString("<img src=\"cid:" + cid.ContentId + "\" />", new ContentType("text/html")))
            {
                embedder.AddImagesToView(view);

                view.LinkedResources.Count.ShouldBe(1);
                view.LinkedResources[0].ShouldBeSameAs(cid);
            }
        }
Пример #3
0
        public void ReplaceLinkedImagesWithEmbeddedImages_replaces_cid_reference_with_correct_mime()
        {
            var embedder = new ImageEmbedder();
            var resource = embedder.ReferenceImage("postal.png");

            string body = "<img src=\"cid:" + resource.ContentId + @"""/>";
            var    view = AlternateView.CreateAlternateViewFromString(body);

            embedder.AddImagesToView(view);

            string replaced = EmailViewResult.ReplaceLinkedImagesWithEmbeddedImages(view, body);

            Assert.Contains("data:image/png;base64,", replaced);
        }
Пример #4
0
        public void ReplaceLinkedImagesWithEmbeddedImages_replaces_cid_reference()
        {
            var embedder = new ImageEmbedder();
            var resource = embedder.ReferenceImage("postal.png");

            string body = "<img src=\"cid:" + resource.ContentId + @"""/>";
            var    view = AlternateView.CreateAlternateViewFromString(body);

            embedder.AddImagesToView(view);

            string replaced = TemplateViewResult.ReplaceLinkedImagesWithEmbeddedImages(view, body);

            Assert.DoesNotContain("cid:", replaced);
        }
        public void ReplaceLinkedImagesWithEmbeddedImages_replaces_cid_reference_with_correct_mime()
        {
            var embedder = new ImageEmbedder();
            var resource = embedder.ReferenceImage("postal.png");

            string body = "<img src=\"cid:" + resource.ContentId + @"""/>";
            var view = AlternateView.CreateAlternateViewFromString(body);
            embedder.AddImagesToView(view);
            
            string replaced = EmailViewResult.ReplaceLinkedImagesWithEmbeddedImages(view, body);
            Assert.Contains("data:image/png;base64,", replaced);
        }
Пример #6
0
        public void ReplaceLinkedImagesWithEmbeddedImages_replaces_cid_reference()
        {
            var embedder = new ImageEmbedder();
            var resource = embedder.ReferenceImage("postal.png");

            string body = "<img src=\"cid:" + resource.ContentId + @"""/>";
            var view = AlternateView.CreateAlternateViewFromString(body);
            embedder.AddImagesToView(view);

            string replaced = TemplateViewResult.ReplaceLinkedImagesWithEmbeddedImages(view, body);
            Assert.DoesNotContain("cid:", replaced);
        }