public void ApplyEnhancements_DuplicateEnhancementRequestsMade_OnlyUniqueResultsAddedToIdentity( string filePath, TvReleaseIdentity identity, TvDbEnhancement tvDbEnhancement, SubDbFileHashEnhancement subDbFileHashEnhancement, IEpisodeSubtitleDownloader downloader, IEnhancementProvider enhancementProvider ) { var expectedEnhancements = new IEnhancement[] {tvDbEnhancement, subDbFileHashEnhancement}; var downloaders = new[] {downloader}; var enhancementRequests = new IEnhancementRequest[] { new EnhancementRequest<TvDbEnhancement>(), new EnhancementRequest<TvDbEnhancement>(), new EnhancementRequest<SubDbFileHashEnhancement>() }; A.CallTo(() => downloader.EnhancementRequests).Returns(enhancementRequests); A.CallTo( () => enhancementProvider.GetEnhancement(A<Type>.That.IsEqualTo(typeof (TvDbEnhancement)), filePath, identity)) .Returns(tvDbEnhancement); A.CallTo( () => enhancementProvider.GetEnhancement(A<Type>.That.IsEqualTo(typeof (SubDbFileHashEnhancement)), filePath, identity)) .Returns(subDbFileHashEnhancement); var sut = new EnhancementApplicator(downloaders, enhancementProvider); sut.ApplyEnhancements(filePath, identity); Assert.That(identity.Enhancements, Is.EquivalentTo(expectedEnhancements)); }
public void ApplyEnhancements_EnhancementRequestsMade_ResultsAddedToIdentity( string filePath, TvReleaseIdentity identity, IEnumerable<IEnhancementRequest> enhancementRequests, IEnhancement[] enhancements, IEpisodeSubtitleDownloader downloader, IEnhancementProvider enhancementProvider ) { var downloaders = new[] {downloader}; A.CallTo(() => downloader.EnhancementRequests).Returns(enhancementRequests); A.CallTo(() => enhancementProvider.GetEnhancement(A<Type>._, filePath, identity)) .ReturnsNextFromSequence(enhancements); var sut = new EnhancementApplicator(downloaders, enhancementProvider); sut.ApplyEnhancements(filePath, identity); Assert.That(identity.Enhancements, Is.EquivalentTo(enhancements)); }
public void ApplyEnhancements_MultipleDownloaders_AllDownloadersRequestsAreUsed( string filePath, TvReleaseIdentity identity, IEnumerable<IEnhancementRequest> enhancementRequests, [Frozen]IEnumerable<IEpisodeSubtitleDownloader> downloaders, [Frozen]IEnhancementProvider enhancementProvider, EnhancementApplicator sut ) { var expectedNumberOfCalls = downloaders.Count() * enhancementRequests.Count(); foreach (var downloader in downloaders) { A.CallTo(() => downloader.EnhancementRequests).ReturnsNextFromSequence(enhancementRequests); } sut.ApplyEnhancements(filePath, identity); A.CallTo(() => enhancementProvider.GetEnhancement(A<Type>._, A<string>._, A<TvReleaseIdentity>._)).MustHaveHappened(Repeated.Exactly.Times(expectedNumberOfCalls)); }
private void EnhanceIdentity(IEnumerable<IEpisodeSubtitleDownloader> compatibleDownloaders, TvReleaseIdentity tvReleaseIdentity, string filePath) { var applicator = new EnhancementApplicator(compatibleDownloaders, _enhancementProvider); applicator.ApplyEnhancements(filePath, tvReleaseIdentity); }