public async Task Atom10_EmptyCollection() { var itemCollection = new List <FeedEntry>(); var rw = new FeedGenerator { HostUrl = "https://996.icu", HeadTitle = "996 ICU", HeadDescription = "Work 996 and get into ICU", Copyright = "(c) 2020 996.icu", Generator = "Fubao Generator", FeedItemCollection = itemCollection, TrackBackUrl = "https://996.icu/trackback", MaxContentLength = 996, GeneratorVersion = "9.9.6" }; using var ms = new MemoryStream(); await rw.WriteAtomStreamAsync(ms); await ms.FlushAsync(); var bytes = ms.ToArray(); var xmlContent = Encoding.UTF8.GetString(bytes); Assert.IsNotNull(xmlContent); Assert.IsTrue(xmlContent.StartsWith(@"<?xml version=""1.0"" encoding=""utf-8""?><feed xmlns=""http://www.w3.org/2005/Atom""><title>996 ICU</title><subtitle>Work 996 and get into ICU</subtitle><rights>(c) 2020 996.icu</rights>")); }
public async Task <byte[]> GetAtomStreamData() { var itemCollection = await GetFeedEntriesAsync(); var rw = new FeedGenerator { HostUrl = _baseUrl, HeadTitle = _blogConfig.FeedSettings.RssTitle, HeadDescription = _blogConfig.FeedSettings.RssDescription, Copyright = _blogConfig.FeedSettings.RssCopyright, Generator = $"Moonglade v{Utils.AppVersion}", FeedItemCollection = itemCollection, TrackBackUrl = _baseUrl, MaxContentLength = 0 }; using var ms = new MemoryStream(); await rw.WriteAtomStreamAsync(ms); await ms.FlushAsync(); return(ms.ToArray()); }