コード例 #1
0
        public void ToXElement_HasItem_ReturnsXElementWithItem()
        {
            // Arrange
            TurboChannel channel = new TurboChannel()
            {
                Items = new List <TurboFeedItem>()
                {
                    new TurboFeedItem()
                    {
                        Link    = "https://sample.ru",
                        Author  = "Author 1",
                        Content = "Content 1",
                        PubDate = DateTime.Now,
                        Source  = "https://source2.ru",
                        Topic   = "Item 1",
                        Turbo   = "true"
                    }
                }
            };

            // Act
            XElement result = channel.ToXElement();

            // Assert
            result.Should().HaveElement("item");
        }
コード例 #2
0
        public void TurboChannel_DefaultLanguageIsRu()
        {
            // Act
            TurboChannel channel = new TurboChannel();

            // Assert
            channel.Language.Should().BeEquivalentTo("ru");
        }
コード例 #3
0
        public void GetFeed_HasItems_ReturnsTurboFeedWithFeedItems()
        {
            // Arrange
            _channel = new TurboChannel()
            {
                Title       = "RSS channel name",
                Link        = new Uri("https://turbo-feed.com"),
                Description = "Short RSS channel description",
                Items       = new List <TurboFeedItem>()
                {
                    new TurboFeedItem()
                    {
                        Link    = "https://sample.ru",
                        Author  = "Author 1",
                        Content = "Content 1",
                        PubDate = DateTime.Now,
                        Source  = "https://source2.ru",
                        Topic   = "Item 1",
                        Turbo   = "true"
                    },
                    new TurboFeedItem()
                    {
                        Link    = "https://sample2.ru",
                        Author  = "Author 2",
                        Content = "Content 2",
                        PubDate = DateTime.Now,
                        Source  = "https://source2.ru",
                        Topic   = "Item 2",
                        Turbo   = "false"
                    }
                }
            };
            _turboFeed = new TurboFeed(_channel);

            // Act
            XDocument result = _turboFeed.GetFeed();

            // Assert
            result.Should().NotBeNull();

            XElement root = result.Root;

            root.Should().NotBeNull();

            root.Should().HaveElement(ChannelElementName);
            root.Element(ChannelElementName).HasAttributes.Should().BeFalse();
            root.Element(ChannelElementName).HasElements.Should().BeTrue();
            root.Element(ChannelElementName).Elements("item").Count().Should().Equals(2);
        }
コード例 #4
0
        public void ToXElement_HasAdNetwork_ReturnsXElementWithAdNetwork()
        {
            // Arrange
            TurboChannel channel = new TurboChannel()
            {
                AdNetworks = new List <TurboAdNetwork>()
                {
                    new AdFox("turbo-ad-id", "<script>ad script</script>")
                }
            };

            // Act
            XElement result = channel.ToXElement();

            // Assert
            result.Should().HaveElement(TurboYandexNamespace + "adNetwork");
        }
コード例 #5
0
        public void ToXElement_HasAnaytics_ReturnsXElementWithAnalytics()
        {
            // Arrange
            TurboChannel channel = new TurboChannel()
            {
                Analytics = new List <TurboAnalytics>()
                {
                    new GoogleAnalytics("ga-12345")
                }
            };

            // Act
            XElement result = channel.ToXElement();

            // Assert
            result.Should().HaveElement(TurboYandexNamespace + "analytics");
        }
コード例 #6
0
 public void SetUp()
 {
     _channel = new TurboChannel()
     {
         Title       = "RSS channel name",
         Link        = new Uri("https://turbo-feed.com"),
         Description = "Short RSS channel description",
         Analytics   = new List <TurboAnalytics>()
         {
             new YandexMetrika("12345")
         },
         AdNetworks = new List <TurboAdNetwork>()
         {
             new YandexAd("yandex-block-id", "yandex_ad_place"),
             new AdFox("adfox-bock-id", AdFoxScript)
         }
     };
     _turboFeed = new TurboFeed(_channel);
 }
コード例 #7
0
        public void ToXElement_ReturnsXElement()
        {
            // Arrange
            TurboChannel channel = new TurboChannel()
            {
                Title       = "Channel title",
                Link        = new Uri("https://website.com"),
                Description = "Channel' description",
                Language    = "en"
            };

            // Act
            XElement result = channel.ToXElement();

            // Assert
            result.Should().HaveElement("link", channel.Link.ToString());
            result.Should().HaveElement("language", channel.Language);
            result.Should().HaveElement("title", channel.Title);
            result.Should().HaveElement("description", channel.Description);

            result.Element(TurboYandexNamespace + "analytics").Should().BeNull();
            result.Element(TurboYandexNamespace + "adNetwork").Should().BeNull();
            result.Element("item").Should().BeNull();
        }