Ejemplo n.º 1
0
        private async Task addChannelImageAsync(RssFeedWriter rssFeedWriter)
        {
            if (string.IsNullOrWhiteSpace(_feedChannel.FeedImageContentPath))
            {
                return;
            }

            var syndicationImage = new SyndicationImage(_httpContextInfo.AbsoluteContent(_feedChannel.FeedImageContentPath))
            {
                Title = _feedChannel.FeedImageTitle,
                Link  = new SyndicationLink(_httpContextInfo.AbsoluteContent(_feedChannel.FeedImageContentPath))
            };
            await rssFeedWriter.Write(syndicationImage);
        }
        public async Task WriteImage()
        {
            var icon = new SyndicationImage(new Uri("http://contoso.com/icon.ico"), AtomImageTypes.Icon);
            var logo = new SyndicationImage(new Uri("http://contoso.com/logo.png"), AtomImageTypes.Logo);

            var sw = new StringWriterWithEncoding(Encoding.UTF8);

            using (var xmlWriter = XmlWriter.Create(sw))
            {
                var writer = new AtomFeedWriter(xmlWriter);

                await writer.Write(icon);

                await writer.Write(logo);

                await writer.Flush();
            }

            string res = sw.ToString();

            Assert.True(CheckResult(res, $"<icon>{icon.Url}</icon><logo>{logo.Url}</logo>"));
        }