public void ShouldReturnTrueForUniqueUrlEpisodes() { EpisodeControl episodeA = CreateEpisode("MyFirstEpisode", "UrlDiff"); EpisodeControl episodeB = CreateEpisode("MyFirstEpisode", "Url"); episodeA.SameAs(episodeB).Should().BeTrue(); }
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)); }
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); }
public void ShouldSetTheElementItunesDescription() { EpisodeControl ec = new EpisodeControl(); ec.SetTextNodeData("itunes:summary", "Description"); ec.Description.Should().Be("Description"); }
public void ShouldSetTheElementDuration() { EpisodeControl ec = new EpisodeControl(); ec.SetTextNodeData("itunes:duration", "10:10"); ec.PlayedDetails.ShowLength.Should().Be(1010); }
public void ShouldSetTheElementDescription() { EpisodeControl ec = new EpisodeControl(); ec.SetTextNodeData("description", "Description"); ec.Description.Should().Be("Description"); }
public void ShouldSetTheElementTitle() { EpisodeControl ec = new EpisodeControl(); ec.SetTextNodeData("title", "MyTitle"); ec.Title.Should().Be("MyTitle"); }
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"); }
public void ShouldNotFalloverForFakeElementDuration() { EpisodeControl ec = new EpisodeControl(); ec.SetTextNodeData("itunes:duration", "ALongTime"); ec.PlayedDetails.ShowLength.Should().Be(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); }
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"); }
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); }
public void ShouldSeeEpisodesAreSame() { EpisodeControl ec = new EpisodeControl { Title = "Title", PodcastURL = "PodcastURL" }; EpisodeControl ecB = new EpisodeControl { Title = "Title", PodcastURL = "PodcastURL" }; ec.SameAs(ecB).Should().BeTrue(); }
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"); }
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; } } }
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"); }
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"); }
public void PlayEpisode(EpisodeControl episode) { _mediaPlayer.Open(new Uri(episode.UrlToPlay)); _mediaPlayer.Position = new TimeSpan(episode.PlayedLength); _mediaPlayer.Play(); }