public void TestCancelledStatusEvents() { LyricsFetchManager lfm = new LyricsFetchManager(); lfm.RegisterSource(new AlwaysFailLyricsSource()); lfm.RegisterSource(new AlwaysSuccessLyricsSource()); lfm.StatusEvent += new EventHandler<LyricsFetchStatusEventArgs>(this.HandleCancelledStatusEvent); cancelledEventCount = 0; lfm.Queue(s1); lfm.Queue(s2); lfm.CancelAll(); Assert.AreEqual(cancelledEventCount, 2); }
public void TestAutoUpdateLyrics() { LyricsFetchManager lfm = new LyricsFetchManager(); lfm.AutoUpdateLyrics = true; lfm.RegisterSource(new LyricsSourceLyrdb()); lfm.RegisterSource(new LyricsSourceLyricsFly()); List<Song> songs = this.GetSongs(); foreach (Song s in songs) Assert.IsNull(s.Lyrics); Song song1 = new TestSong("Test Title 1", "Some Artist Name", "Beauty and the Beat", "Pop"); song1.Lyrics = "Original Lyrics"; songs.Add(song1); lfm.Queue(songs); lfm.Start(); lfm.WaitUntilFinished(); foreach (Song s in songs) Assert.AreNotEqual("", s.Lyrics); // This song cannot be found and its lyrics should not be changed Assert.AreEqual("Original Lyrics", song1.Lyrics); }
public void TestDoneStatusEvents() { LyricsFetchManager lfm = new LyricsFetchManager(); lfm.RegisterSource(new AlwaysFailLyricsSource()); lfm.RegisterSource(new AlwaysSuccessLyricsSource()); lfm.StatusEvent += new EventHandler<LyricsFetchStatusEventArgs>(this.HandleDoneStatusEvent); doneEventCount = 0; lfm.Start(); lfm.Queue(s1); lfm.Queue(s2); lfm.WaitUntilFinished(); Assert.AreEqual(2, doneEventCount); }
public void TestRealLyricsFetch() { LyricsFetchManager lfm = new LyricsFetchManager(); lfm.StatusEvent += new EventHandler<LyricsFetchStatusEventArgs>(this.HandleDoneStatusEvent2); lfm.RegisterSource(new LyricsSourceLyrdb()); lfm.RegisterSource(new LyricsSourceLyricsFly()); List<Song> songs = this.GetSongs(); foreach (Song s in songs) Assert.IsNull(s.Lyrics); lfm.Queue(songs); lfm.Start(); lfm.WaitUntilFinished(); foreach (Song s in songs) Assert.AreNotEqual("", s.Lyrics); }
public void TestQueueAndCancelAll() { LyricsFetchManager lfm = new LyricsFetchManager(); Assert.AreEqual(lfm.CountWaiting, 0); lfm.Queue(s1); lfm.Queue(s2); lfm.CancelAll(); Assert.AreEqual(lfm.CountWaiting, 0); }
public void TestGetStatus2() { LyricsFetchManager lfm = new LyricsFetchManager(); lfm.RegisterSource(new AlwaysFailLyricsSource()); lfm.RegisterSource(new AlwaysSuccessLyricsSource()); Assert.AreEqual(LyricsFetchStatus.NotFound, lfm.GetStatus(s1)); Assert.AreEqual(LyricsFetchStatus.NotFound, lfm.GetStatus(s2)); Assert.AreEqual(LyricsFetchStatus.NotFound, lfm.GetStatus(s3)); lfm.Queue(s1); lfm.Queue(s2); lfm.Queue(s3); Assert.AreEqual(LyricsFetchStatus.Waiting, lfm.GetStatus(s1)); Assert.AreEqual(LyricsFetchStatus.Waiting, lfm.GetStatus(s2)); Assert.AreEqual(LyricsFetchStatus.Waiting, lfm.GetStatus(s3)); lfm.Start(); lfm.WaitUntilFinished(); Assert.AreEqual(LyricsFetchStatus.NotFound, lfm.GetStatus(s1)); Assert.AreEqual(LyricsFetchStatus.NotFound, lfm.GetStatus(s2)); Assert.AreEqual(LyricsFetchStatus.NotFound, lfm.GetStatus(s3)); }
public void TestGetStatus() { LyricsFetchManager lfm = new LyricsFetchManager(); Assert.AreEqual(LyricsFetchStatus.NotFound, lfm.GetStatus(s1)); Assert.AreEqual(LyricsFetchStatus.NotFound, lfm.GetStatus(s2)); lfm.Queue(s1); lfm.Queue(s2); Assert.AreEqual(LyricsFetchStatus.Waiting, lfm.GetStatus(s1)); Assert.AreEqual(LyricsFetchStatus.Waiting, lfm.GetStatus(s2)); lfm.CancelAll(); Assert.AreEqual(LyricsFetchStatus.NotFound, lfm.GetStatus(s1)); Assert.AreEqual(LyricsFetchStatus.NotFound, lfm.GetStatus(s2)); }