/// <summary> /// Return a textual description of the status of the fetch request /// </summary> /// <param name="song"></param> /// <returns></returns> public string GetStatusString(Song song) { LyricsFetchStatus status = this.GetStatus(song); switch (status) { case LyricsFetchStatus.NotFound: return("Not found"); case LyricsFetchStatus.Fetching: FetchRequestData data = this.GetFetchRequestData(song); if (data != null) { ILyricsSource source = data.Source; if (source != null) { return(String.Format("Trying {0}...", source.Name)); } } return("Trying ..."); default: return(status.ToString()); } }
void HandleStatusEvent(object sender, LyricsFetchStatusEventArgs args) { this.statusEventCount += 1; // SourceDone events count as Fetching status if (args.Status == LyricsFetchStatus.SourceDone) { Assert.AreEqual(LyricsFetchStatus.Fetching, this.lfm.GetStatus(args.Song)); } else { Assert.AreEqual(args.Status, this.lfm.GetStatus(args.Song)); } this.lastStatus = args.Status; }
void HandleStatusEvent(object sender, LyricsFetchStatusEventArgs args) { this.statusEventCount += 1; // SourceDone events count as Fetching status if (args.Status == LyricsFetchStatus.SourceDone) Assert.AreEqual(LyricsFetchStatus.Fetching, this.lfm.GetStatus(args.Song)); else Assert.AreEqual(args.Status, this.lfm.GetStatus(args.Song)); this.lastStatus = args.Status; }
public void TestStatusEvents() { this.lfm = new LyricsFetchManager(); this.lfm.RegisterSource(new AlwaysFailLyricsSource()); this.lfm.RegisterSource(new AlwaysSuccessLyricsSource()); this.lfm.StatusEvent += new EventHandler<LyricsFetchStatusEventArgs>(this.HandleStatusEvent); this.statusEventCount = 0; this.lastStatus = LyricsFetchStatus.Undefined; this.lfm.Queue(s1); this.lfm.Queue(s2); this.lfm.Start(); this.lfm.WaitUntilFinished(); // Each song should trigger: Waiting, (Fetching, SourceDone) x 2, Done Assert.AreEqual(12, this.statusEventCount); Assert.AreEqual(LyricsFetchStatus.Done, this.lastStatus); }