コード例 #1
0
        public void SearchSubtitle_ThrowsException_ReturnEmptyResultSet(
            TvReleaseIdentity tvReleaseIdentity,
            Language[] languages,
            [Frozen]ISubtitleDownloader downloader,
            SubtitleDownloaderWrapper downloaderWrapper)
        {
            A.CallTo(() => downloader.SearchSubtitles(A<SearchQuery>._)).Throws<Exception>();

            var results = downloaderWrapper.SearchSubtitle(tvReleaseIdentity, languages);

            Assert.That(results, Is.Empty);
        }
コード例 #2
0
        public void SearchSubtitle_MultipleValidSubtitlesFound_OrderedByLanguagePriority(
            TvReleaseIdentity tvReleaseIdentity,
            string id,
            string fileName,
            Language[] expectedLanguages,
            Language missingLanguage,
            [Frozen]IEpisodeParser nameParser,
            [Frozen]ISubtitleDownloader downloader,
            SubtitleDownloaderWrapper downloaderWrapper
            )
        {
            var subtitles = expectedLanguages.Select(l => new Subtitle(id, fileName, l));
            A.CallTo(() => downloader.SearchSubtitles(A<SearchQuery>._)).Returns(subtitles);
            A.CallTo(() => nameParser.ExtractReleaseIdentity(A<Subtitle>._)).Returns(tvReleaseIdentity);
            var languages = new [] { expectedLanguages[0], missingLanguage, expectedLanguages[1], expectedLanguages[2] };

            var results = downloaderWrapper.SearchSubtitle(tvReleaseIdentity, languages);

            Assert.That(results.Select(s => s.Language), Is.EquivalentTo(expectedLanguages));
        }
コード例 #3
0
        public void SearchSubtitle_NonEquivalentSubtitlesFound_OnlyIncludesEquivalent(
            TvReleaseIdentity tvReleaseIdentity,
            string id,
            string programName,
            Language[] supportedLanguages,
            string otherShow,
            [Frozen]IEpisodeParser nameParser,
            [Frozen]ISubtitleDownloader downloader,
            SubtitleDownloaderWrapper downloaderWrapper)
        {
            var anyOfTheSupportedLanguages = supportedLanguages.First();
            var subtitles = new List<Subtitle>
                                {
                new Subtitle(id, tvReleaseIdentity.ToString(), anyOfTheSupportedLanguages),
                new Subtitle(id, tvReleaseIdentity.ToString(), anyOfTheSupportedLanguages),
                new Subtitle(id, otherShow, anyOfTheSupportedLanguages)
            };
            A.CallTo(() => downloader.SearchSubtitles(A<SearchQuery>._)).Returns(subtitles);

            var results = downloaderWrapper.SearchSubtitle(tvReleaseIdentity, supportedLanguages);

            Assert.That(results.Select(s => s.FileName), Has.All.StringStarting(tvReleaseIdentity.ToString()));
        }