Пример #1
0
        public async Task RssAsync_Returns_An_Rss_2_Point_0_Feed_And_Passes_The_QueryString_Through_To_Links()
        {
            var req = TestHelper.CreateHttpRequest("https://nzb.mtighe.dev/api/cart/rss?del=1");

            _cartTable.SetupSegmentedQuery(new[] {
                new CartEntry {
                    Category = "Cat", Description = "", DetailsUrl = "https://no.where/details/cat", GrabUrl = "https://no.where/nzb/cat", Title = "item 1"
                },
                new CartEntry {
                    Category = "Dog", Description = "", DetailsUrl = "https://no.where/details/dog", GrabUrl = "https://no.where/nzb/dog", Title = "item 2"
                },
            });

            var result = await _function.RssAsync(req, _cartTable.Object);

            var cr    = Assert.IsType <ContentResult>(result);
            var doc   = XDocument.Parse(cr.Content);
            var items = doc.Root.Element("channel").Elements("item");

            Assert.Equal(200, cr.StatusCode);
            Assert.Equal("text/xml", cr.ContentType);
            Assert.Equal("rss", doc.Root.Name.LocalName);
            Assert.Equal("2.0", doc.Root.Attribute("version").Value);
            Assert.Equal(2, items.Count());
            Assert.All(items, x =>
            {
                Assert.EndsWith("?del=1", x.Element("link").Value);
                Assert.EndsWith("?del=1", x.Element("enclosure").Attribute("url").Value);
            });
        }