public void TestLyricLyrdbStrategy() { Dictionary <Song, string> songs = this.CreateLyrdbSongs(); LyricsSourceLyrdb strategy = new LyricsSourceLyrdb(); foreach (Song s in songs.Keys) { AssertEqualIgnoringLineEndings(songs[s], strategy.GetLyrics(s)); } }
static void TestSecondTry() { // Is it actually worthwhile doing the second or subsequent attempt? ITunesLibrary lib = new ITunesLibrary(); //lib.MaxSongsToFetch = 1000; lib.LoadSongs(); lib.WaitLoad(); List <Song> songs = lib.Songs.FindAll( delegate(Song s) { LyricsStatus status = s.LyricsStatus; return(status == LyricsStatus.Untried || status == LyricsStatus.Failed || status == LyricsStatus.Success); } ); ILyricsSource source2 = new LyricsSourceLyricsPlugin(); ILyricsSource source1 = new LyricsSourceLyrdb(); ILyricsSource source3 = new LyricsSourceLyricsFly(); Stopwatch sw1 = new Stopwatch(); Stopwatch sw2 = new Stopwatch(); Stopwatch sw3 = new Stopwatch(); int failures = 0; int success1 = 0; int success2 = 0; int success3 = 0; foreach (Song song in songs) { sw1.Start(); string lyrics = source1.GetLyrics(song); sw1.Stop(); if (lyrics == string.Empty) { sw2.Start(); lyrics = source2.GetLyrics(song); sw2.Stop(); if (lyrics == string.Empty) { sw3.Start(); lyrics = source3.GetLyrics(song); sw3.Stop(); if (lyrics == string.Empty) { failures++; } else { success3++; } } else { success2++; } } else { success1++; } } Console.WriteLine("1st try: successes: {0} ({1}%), time: {2} ({3} each)", success1, (success1 * 100 / songs.Count), sw1.Elapsed, sw1.ElapsedMilliseconds / songs.Count); Console.WriteLine("2st try: successes: {0} ({1}%), time: {2} ({3} each)", success2, (success2 * 100 / songs.Count), sw2.Elapsed, sw2.ElapsedMilliseconds / (songs.Count - success1)); Console.WriteLine("3st try: successes: {0} ({1}%), time: {2} ({3} each)", success3, (success3 * 100 / songs.Count), sw3.Elapsed, sw3.ElapsedMilliseconds / (songs.Count - success1 - success2)); Console.WriteLine("failures: {0} ({1}%)", failures, (failures * 100 / songs.Count)); }
public void TestLyricLyrdbStrategy() { Dictionary<Song, string> songs = this.CreateLyrdbSongs(); LyricsSourceLyrdb strategy = new LyricsSourceLyrdb(); foreach (Song s in songs.Keys) { AssertEqualIgnoringLineEndings(songs[s], strategy.GetLyrics(s)); } }