Beispiel #1
0
        public void ShouldSetTheElementLinkOnlyIfNotEmpty()
        {
            EpisodeControl ec = new EpisodeControl();

            ec.SetTextNodeData("link", "UrlFirst");

            ec.PodcastURL.Should().Be("UrlFirst");

            ec.SetTextNodeData("link", string.Empty);
            ec.PodcastURL.Should().Be("UrlFirst");
        }
Beispiel #2
0
        public void ShouldSetTheElementItunesDescription()
        {
            EpisodeControl ec = new EpisodeControl();

            ec.SetTextNodeData("itunes:summary", "Description");

            ec.Description.Should().Be("Description");
        }
Beispiel #3
0
        public void ShouldNotFalloverForFakeElementDuration()
        {
            EpisodeControl ec = new EpisodeControl();

            ec.SetTextNodeData("itunes:duration", "ALongTime");

            ec.PlayedDetails.ShowLength.Should().Be(0);
        }
Beispiel #4
0
        public void ShouldSetTheElementDuration()
        {
            EpisodeControl ec = new EpisodeControl();

            ec.SetTextNodeData("itunes:duration", "10:10");

            ec.PlayedDetails.ShowLength.Should().Be(1010);
        }
Beispiel #5
0
        public void ShouldSetTheElementDescription()
        {
            EpisodeControl ec = new EpisodeControl();

            ec.SetTextNodeData("description", "Description");

            ec.Description.Should().Be("Description");
        }
Beispiel #6
0
        public void ShouldSetTheElementTitle()
        {
            EpisodeControl ec = new EpisodeControl();

            ec.SetTextNodeData("title", "MyTitle");

            ec.Title.Should().Be("MyTitle");
        }
Beispiel #7
0
        public void ShouldSetTheElementPubDate()
        {
            EpisodeControl ec = new EpisodeControl();

            ec.SetTextNodeData("pubDate", "Sun, 08 Jan 2017 06:47:50 GMT");

            ec.PublishedDate.ToString("dd/MM/yyyy hh:mm:ss").Should().Be("08/01/2017 06:47:50");
        }
Beispiel #8
0
        public static List <EpisodeControl> ReadEpisodes(XmlReader reader)
        {
            List <EpisodeControl> episodes = new List <EpisodeControl>();

            try
            {
                EpisodeControl showData = new EpisodeControl();

                string elementName = string.Empty;

                while (reader.Read())
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                        elementName = reader.Name;

                        if (elementName == "enclosure")
                        {
                            string attr = reader.GetAttribute(0);
                            showData.PodcastURL = attr;
                            if (!showData.PodcastURL.Contains("mp3"))
                            {
                                showData.PodcastURL = reader.GetAttribute(1);
                            }
                            if (!showData.PodcastURL.Contains("mp3"))
                            {
                                showData.PodcastURL = reader.GetAttribute(2);
                            }
                        }

                        break;

                    case XmlNodeType.CDATA:
                        break;

                    case XmlNodeType.Text:
                        showData.SetTextNodeData(elementName, reader.Value);
                        break;

                    case XmlNodeType.EndElement:
                        if (reader.Name == "item")
                        {
                            episodes.Add(showData);
                            showData = new EpisodeControl();
                        }
                        break;
                    }
                }
            }
            catch
            {
            }
            return(episodes);
        }