コード例 #1
0
ファイル: Form1.cs プロジェクト: jayp33/RockDouble
 private void timer1_Tick(object sender, EventArgs e)
 {
     textBoxInterval.BackColor = Color.Yellow;
     Application.DoEvents();
     var rockland = new RocklandParser();
     var songs = rockland.GetSongs(new Uri("http://www.rockland.fm/start.php?playlist"));
     if (songs.Count == 0)
         return;
     if (listBoxSongs.Items[0].Equals("Loading songs..."))
         listBoxSongs.Items.Clear();
     songs.Sort();
     foreach (var song in songs)
     {
         if (!m_songs.Contains(song))
             m_songs.Add(song);
     }
     foreach (var m_song in m_songs)
     {
         if (!m_song.Added)
         {
             listBoxSongs.Items.Insert(0, m_song);
             m_song.Added = true;
         }
     }
     if (CheckForRockDouble())
     {
         this.BackColor = Color.Red;
         this.WindowState = FormWindowState.Normal;
         this.Activate();
         string message = "*** RockDouble found ***";
         if (!listBoxSongs.Items[0].Equals(message))
             listBoxSongs.Items.Insert(0, message);
     }
     textBoxInterval.BackColor = m_intervalOriginalColor;
 }
コード例 #2
0
ファイル: SongTests.cs プロジェクト: jayp33/RockDouble
 public void SongsCanBeSortedByTimestamp()
 {
     var html = new HtmlAgilityPack.HtmlDocument();
     var path = System.IO.Path.GetDirectoryName(
         System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\..\..\TestData";
     html.Load(path + @"\ROCKLAND - Mach an und laut!.html");
     var parser = new RocklandParser();
     var songs = parser.GetSongs(html);
     Assert.AreEqual("Russ Ballard", songs.First().Artist);
     songs.Sort();
     Assert.AreEqual("Russ Ballard", songs.Last().Artist);
 }
コード例 #3
0
        public void ParsePlaylistSongs()
        {
            var htmlWeb = new HtmlAgilityPack.HtmlWeb();
            var html = htmlWeb.Load("http://www.rockland.fm/start.php?playlist");
            var parser = new RocklandParser();
            var songs = parser.GetSongs(html);

            Assert.IsTrue(songs.Count > 0);
            foreach (var song in songs)
            {
                Assert.IsTrue(song.TimestampText.EndsWith("Uhr"));
            }
        }
コード例 #4
0
ファイル: SongTests.cs プロジェクト: jayp33/RockDouble
 public void UniqueSongCanOnlyBeAddedOnce()
 {
     var html = new HtmlAgilityPack.HtmlDocument();
     var path = System.IO.Path.GetDirectoryName(
         System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\..\..\TestData";
     html.Load(path + @"\ROCKLAND - Mach an und laut!.html");
     var parser = new RocklandParser();
     var songs = parser.GetSongs(html);
     var songDuplicate = new Song();
     songDuplicate.TimestampText = songs[5].TimestampText;
     songDuplicate.Timestamp = songs[5].Timestamp;
     songDuplicate.Artist = songs[5].Artist;
     songDuplicate.Title = songs[5].Title;
     if (!songs.Contains(songDuplicate))
         songs.Add(songDuplicate);
     Assert.AreEqual(8, songs.Count);
 }
コード例 #5
0
        public void ParsePlaylistSongs_offline()
        {
            var html = new HtmlAgilityPack.HtmlDocument();
            var path = System.IO.Path.GetDirectoryName(
                System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\..\..\TestData";
            html.Load(path + @"\ROCKLAND - Mach an und laut!.html");
            var parser = new RocklandParser();
            var songs = parser.GetSongs(html);

            Assert.AreEqual(8, songs.Count);
            Assert.AreEqual("Metallica", songs[2].Artist);
            Assert.AreEqual("11:32 Uhr Russ Ballard - Voices",                             songs[0].ToString());
            Assert.AreEqual("11:26 Uhr Neil Young - Heart Of Gold",                        songs[1].ToString());
            Assert.AreEqual("11:21 Uhr Metallica - I Disappear",                           songs[2].ToString());
            Assert.AreEqual("11:18 Uhr Lenny Kravitz - Rock'n'Roll Is Dead",               songs[3].ToString());
            Assert.AreEqual("11:15 Uhr Hooters - Johnny B.",                               songs[4].ToString());
            Assert.AreEqual("11:11 Uhr Steve Harley & Cockney Rebel - Make Me Smile ", songs[5].ToString());
            Assert.AreEqual("11:08 Uhr Foreigner - When It Comes To Love",                 songs[6].ToString());
            Assert.AreEqual("11:04 Uhr Glenn Frey - The Heat Is On ",                      songs[7].ToString());
        }