예제 #1
0
        public void TestBasicFetchAll()
        {
            SongLibrary db = this.GetLibrary();

            db.MaxSongsToFetch = MAX_SONGS_TO_FETCH;
            db.LoadSongs();
            db.WaitLoad();

            Assert.IsTrue(db.HasSongs);
            Assert.AreEqual(db.Songs.Count, db.MaxSongsToFetch);
        }
예제 #2
0
        public void TestFetchUntriedSongs()
        {
            SongLibrary db = this.GetLibrary();

            db.MaxSongsToFetch = MAX_SONGS_TO_FETCH;
            db.LoadSongs();
            db.WaitLoad();

            Assert.IsTrue(db.UntriedSongs.TrueForAll(
                              delegate(Song s) {
                return(String.IsNullOrEmpty(s.Lyrics));
            }
                              ));
        }
예제 #3
0
        public void TestFetchSongsWithoutLyrics()
        {
            SongLibrary db = this.GetLibrary();

            db.MaxSongsToFetch = MAX_SONGS_TO_FETCH;
            db.LoadSongs();
            db.WaitLoad();

            Assert.IsTrue(db.SongsWithoutLyrics.TrueForAll(
                              delegate(Song s) {
                return(String.IsNullOrEmpty(s.Lyrics) ||
                       s.Lyrics.StartsWith("Failed") ||
                       s.Lyrics.StartsWith("[[LyricsFetcher failed"));
            }
                              ));
        }
예제 #4
0
        public void TestFetchEvents()
        {
            SongLibrary db = this.GetLibrary();

            db.ProgessEvent += new EventHandler <ProgressEventArgs>(db_LoadingProgessEvent1);
            db.DoneEvent    += new EventHandler <ProgressEventArgs>(db_LoadingDoneEvent1);

            this.doneEventCalled = false;
            for (int i = 0; i <= 100; i++)
            {
                this.progressPercentages[i] = i;
            }

            db.MaxSongsToFetch = Math.Max(100, MAX_SONGS_TO_FETCH);
            db.LoadSongs();
            db.WaitLoad();

            Assert.IsTrue(this.doneEventCalled);

            // We should have received one progress event for every value of percentage
            Assert.IsEmpty(this.progressPercentages.Keys);
        }
예제 #5
0
        public void TestFetchCancelling2()
        {
            // This test isn't very reliable since it relies on timing.
            // It is supposed to test that cancelling a fetch during a progress event does in fact cancel the fetch.
            // But progress events are triggered asynchronously, so the fetching may actually finish successfully
            // before the progress events are processed.
            // We can "hide" this by making sure we fetch "enough" songs so that the progress events have a chance
            // to cancel the fetching. On my current machine, 200 is usually enough.
            // JPP 2008/01/14

            SongLibrary db = this.GetLibrary();

            db.ProgessEvent += new EventHandler <ProgressEventArgs>(db_LoadingProgessEvent2);
            db.DoneEvent    += new EventHandler <ProgressEventArgs>(db_LoadingDoneEvent2);

            this.doneEventCalled = false;

            db.MaxSongsToFetch = Math.Max(200, MAX_SONGS_TO_FETCH);
            db.LoadSongs();
            db.WaitLoad();

            Assert.IsTrue(doneEventCalled);
        }