protected bool Matched(GuideEnricherProgram guideProgram, TvdbEpisode episode) { if (guideProgram == null) { throw new ArgumentNullException("guideProgram"); } if (episode == null) { throw new ArgumentNullException("episode"); } // this.SuccessfulMatches++; guideProgram.EpisodeNumber = episode.EpisodeNumber; guideProgram.SeriesNumber = episode.SeasonNumber; guideProgram.EpisodeNumberDisplay = Enricher.FormatSeasonAndEpisode(episode.SeasonNumber, episode.EpisodeNumber); if (bool.Parse(Config.Instance.GetProperty("updateSubtitles"))) { guideProgram.SubTitle = episode.EpisodeName; } if (bool.Parse(Config.Instance.GetProperty("episodeInDescription"))) { var descriptionWithNoEpisodeNumber = Regex.Replace(guideProgram.Description, "^S[0-9][0-9]E[0-9][0-9] - ", string.Empty); guideProgram.Description = string.Format("{0} - {1}", guideProgram.EpisodeNumberDisplay, descriptionWithNoEpisodeNumber); } this.log.DebugFormat("[{0}] Correctly matched {1} - {2} as {3}", this.MethodName, guideProgram.Title, guideProgram.SubTitle, guideProgram.EpisodeNumberDisplay); return(true); }
public void should_change_message_payload() { var processor = new Enricher( m => { var p = (Boo)m.Payload; p.B = p.A * 2; }); var payload = new Boo { A = 10 }; var message = new Message <Boo>( "boo".ToMessageLabel(), new Dictionary <string, object> { { "This", "That" } }, payload); var result = processor.Apply(message).ToList(); result.Should().HaveCount(1); result.Single().Label.Name.Should().Be("boo"); result.Single().Payload.Should().Be(payload); result.Single() .Payload.As <Boo>() .B.Should() .Be(20); }
public void OnceCanceledDisposeDoesNotInvokeEnricher() { var enricher = new Enricher(null, null); var logger = new CollectingLogger(); var op = logger.Logger.BeginOperation("Test"); op.EnrichWith(enricher); op.Cancel(); op.Dispose(); Assert.False(enricher.WasCalled); }
public bool EpisodeIsEnriched() { if (!this.guideProgram.EpisodeNumber.HasValue) { return(false); } if (!this.guideProgram.SeriesNumber.HasValue) { return(false); } return(this.EpisodeNumberDisplay.Equals(Enricher.FormatSeasonAndEpisode(this.guideProgram.SeriesNumber.Value, this.guideProgram.EpisodeNumber.Value))); }