コード例 #1
0
        public void ShouldReturnTrueForUniqueUrlEpisodes()
        {
            EpisodeControl episodeA = CreateEpisode("MyFirstEpisode", "UrlDiff");
            EpisodeControl episodeB = CreateEpisode("MyFirstEpisode", "Url");

            episodeA.SameAs(episodeB).Should().BeTrue();
        }
コード例 #2
0
        private void TreeView_OnSelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            XmlElement node = ((XmlElement)e.NewValue);

            if (node == null)
            {
                return;
            }

            SeriesControlGrid.Children.Clear();

            if (node.Name == "WatchSeries")
            {
                var  shownode     = node.SelectSingleNode("Show");
                Show selectedShow = shownode.ToType <Show>();

                ShowControl seriesctrl = new ShowControl(selectedShow);
                SeriesControlGrid.Children.Add(seriesctrl);
            }
            if (node.Name == "Episode")
            {
                Episode        selectedEpisode = node.ToType <Episode>();
                EpisodeControl episodectrl     = new EpisodeControl(selectedEpisode);
                SeriesControlGrid.Children.Add(episodectrl);
            }
            //seriesctrl.imgPoster.LoadImage();
            //string imdbid = ((XmlElement) e.NewValue).Attributes["Imdbid"]?.Value ?? "";
            //if (imdbid == "") return;
            //OmdbLookup2View(new TvDbRequestBuilder(imdbid, RequestBy.ImdbId, PlotType.Full));
        }
コード例 #3
0
        public void ShouldUpdateNewEpisodes()
        {
            ShowControl sc = new ShowControl();

            List <EpisodeControl> episodes = new List <EpisodeControl>();
            EpisodeControl        episode  = new EpisodeControl()
            {
                Title      = "MyFirstEpisode",
                PodcastURL = "UrlA"
            };

            episodes.Add(episode);

            episode = new EpisodeControl()
            {
                Title      = "MySecondEpisode",
                PodcastURL = "UrlB"
            };

            episodes.Add(episode);

            sc.UpdateEpisode(episodes);

            sc.Episodes.Should().HaveCount(2);
        }
コード例 #4
0
        public void ShouldSetTheElementItunesDescription()
        {
            EpisodeControl ec = new EpisodeControl();

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

            ec.Description.Should().Be("Description");
        }
コード例 #5
0
        public void ShouldSetTheElementDuration()
        {
            EpisodeControl ec = new EpisodeControl();

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

            ec.PlayedDetails.ShowLength.Should().Be(1010);
        }
コード例 #6
0
        public void ShouldSetTheElementDescription()
        {
            EpisodeControl ec = new EpisodeControl();

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

            ec.Description.Should().Be("Description");
        }
コード例 #7
0
        public void ShouldSetTheElementTitle()
        {
            EpisodeControl ec = new EpisodeControl();

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

            ec.Title.Should().Be("MyTitle");
        }
コード例 #8
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");
        }
コード例 #9
0
        public void ShouldNotFalloverForFakeElementDuration()
        {
            EpisodeControl ec = new EpisodeControl();

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

            ec.PlayedDetails.ShowLength.Should().Be(0);
        }
コード例 #10
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);
        }
コード例 #11
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");
        }
コード例 #12
0
        private EpisodeControl CreateEpisode(string title, DateTime date)
        {
            EpisodeControl e = new EpisodeControl
            {
                Title              = title,
                PublishedDate      = date,
                PodcastURL         = title,
                PlayedLength       = 150,
                PlayedLengthScaled = 150,
                Hidden             = true
            };

            return(e);
        }
コード例 #13
0
        public void ShouldSeeEpisodesAreSame()
        {
            EpisodeControl ec = new EpisodeControl
            {
                Title      = "Title",
                PodcastURL = "PodcastURL"
            };

            EpisodeControl ecB = new EpisodeControl
            {
                Title      = "Title",
                PodcastURL = "PodcastURL"
            };

            ec.SameAs(ecB).Should().BeTrue();
        }
コード例 #14
0
        public void ShouldShowNameCount()
        {
            ShowControl sc = new ShowControl
            {
                Title = "MyShow"
            };

            List <EpisodeControl> episodes = new List <EpisodeControl>();
            EpisodeControl        episode  = new EpisodeControl()
            {
                Title      = "MyFirstEpisode",
                PodcastURL = "UrlA"
            };

            episodes.Add(episode);

            sc.UpdateEpisode(episodes);
            sc.ToString().Should().StartWith("MyShow");
            sc.ToString().Should().Contain("1");
        }
コード例 #15
0
        public void UpDateInterval(EpisodeControl episode, out bool playNextEpsoide)
        {
            playNextEpsoide = false;
            if (_mediaPlayer.Source != null && _mediaPlayer.NaturalDuration.HasTimeSpan)
            {
                episode.PlayedLength = _mediaPlayer.Position.Ticks;

                double MaxLength = 781;

                double totalWidth = MaxLength;

                totalWidth /= _mediaPlayer.NaturalDuration.TimeSpan.TotalMilliseconds;
                totalWidth *= _mediaPlayer.Position.TotalMilliseconds;
                episode.PlayedLengthScaled = (float)totalWidth;

                if (episode.PlayedLengthScaled >= MaxLength - 2)
                {
                    playNextEpsoide = true;
                }
            }
        }
コード例 #16
0
        public void ShouldParse4Episodes()
        {
            XmlReader         reader   = null;
            XmlReaderSettings settings = new XmlReaderSettings
            {
                DtdProcessing = DtdProcessing.Parse
            };

            var assembly     = Assembly.GetExecutingAssembly();
            var resourceName = "eWolfPodcasterCoreUnitTests.Examples.4Episodes.xml";

            List <EpisodeControl> episodes;

            using (Stream stream = assembly.GetManifestResourceStream(resourceName))
            {
                reader   = XmlReader.Create(stream, settings);
                episodes = RSSHelper.ReadEpisodes(reader);
            }

            episodes.Should().HaveCount(4);

            EpisodeControl episode = episodes[0];

            episode.Title.Should().Be("84. Algorithms You Should Know");
            episode.PodcastURL.Should().Be("http://media.blubrry.com/codingblocks/www.podtrac.com/pts/redirect.mp3/traffic.libsyn.com/codingblocks/coding-blocks-episode-84.mp3");

            episode = episodes[1];
            episode.Title.Should().Be("83. Search Driven Apps");
            episode.PodcastURL.Should().Be("http://media.blubrry.com/codingblocks/www.podtrac.com/pts/redirect.mp3/traffic.libsyn.com/codingblocks/coding-blocks-episode-83.mp3");

            episode = episodes[2];
            episode.Title.Should().Be("82. Programmer Strengths and Weaknesses");
            episode.PodcastURL.Should().Be("http://media.blubrry.com/codingblocks/www.podtrac.com/pts/redirect.mp3/traffic.libsyn.com/codingblocks/coding-blocks-episode-82.mp3");

            episode = episodes[3];
            episode.Title.Should().Be("81. Understanding Complexity Theory");
            episode.PodcastURL.Should().Be("http://media.blubrry.com/codingblocks/www.podtrac.com/pts/redirect.mp3/traffic.libsyn.com/codingblocks/coding-blocks-episode-81.mp3");
        }
コード例 #17
0
        public void ShouldParseIsaacArthurEpisodes()
        {
            XmlReader         reader   = null;
            XmlReaderSettings settings = new XmlReaderSettings
            {
                DtdProcessing = DtdProcessing.Parse
            };

            var assembly     = Assembly.GetExecutingAssembly();
            var resourceName = "eWolfPodcasterCoreUnitTests.Examples.Isaac Arthur.xml";

            List <EpisodeControl> episodes;

            using (Stream stream = assembly.GetManifestResourceStream(resourceName))
            {
                reader   = XmlReader.Create(stream, settings);
                episodes = RSSHelper.ReadEpisodes(reader);
            }

            EpisodeControl episode = episodes[0];

            episode.Title.Should().Be("Programmable & Smart Matter");
            episode.PodcastURL.Should().Be("https://feeds.soundcloud.com/stream/1241912254-isaac-arthur-148927746-programmable-smart-matter.mp3");
        }
コード例 #18
0
 public void PlayEpisode(EpisodeControl episode)
 {
     _mediaPlayer.Open(new Uri(episode.UrlToPlay));
     _mediaPlayer.Position = new TimeSpan(episode.PlayedLength);
     _mediaPlayer.Play();
 }