Ejemplo n.º 1
0
        public void ProcessFile_CannotParseName_ReturnsTrue(
            string fileName,
            string[] ignored,
            TvReleaseIdentity tvRelease,
            [Frozen] IEpisodeParser episodeParser,
            FileProcessor sut)
        {
            var emptyEpisode = new TvReleaseIdentity();
            A.CallTo(() => episodeParser.ParseEpisodeInfo(fileName)).Returns(emptyEpisode);

            bool result = sut.ProcessFile(fileName, ignored);

            Assert.That(result, Is.True);
        }
Ejemplo n.º 2
0
        public void ProcessFile_CannotParseName_IsNotDownloaded(
            string fileName,
            string[] ignored,
            TvReleaseIdentity tvRelease,
            [Frozen] IEpisodeParser episodeParser,
            [Frozen] ISubtitleDownloadService subtitleService,
            FileProcessor sut)
        {
            var emptyEpisode = new TvReleaseIdentity();
            A.CallTo(() => episodeParser.ParseEpisodeInfo(fileName)).Returns(emptyEpisode);

            sut.ProcessFile(fileName, ignored);

            A.CallTo(() => subtitleService.DownloadSubtitle(A<string>._, A<TvReleaseIdentity>._, A<IEnumerable<Language>>._)).MustNotHaveHappened();
        }
Ejemplo n.º 3
0
        public void ProcessFile_AllLanguagesAlreadyDownloaded_ReturnsTrue( 
            Language[] languages,
            string fileName,
            TvReleaseIdentity tvRelease,
            ILogger logger,
            IEpisodeParser episodeParser,
            ISubtitleDownloadService subtitleService,
            [Frozen]IFileOperations fileOperations,
            FileProcessor sut)
        {
            var settings = new LanguageSettings(languages);
            A.CallTo(() => fileOperations.GetDowloadedSubtitleLanguages(A<string>._, languages)).Returns(languages);
            A.CallTo(() => subtitleService.DownloadSubtitle(A<string>._, A<TvReleaseIdentity>._, A<IEnumerable<Language>>._))
                .Returns(false);
            A.CallTo(() => episodeParser.ParseEpisodeInfo(A<string>._)).Returns(tvRelease);
            var processor = new FileProcessor(episodeParser, logger, subtitleService, fileOperations, settings);

            bool result = processor.ProcessFile(fileName, new string[0]);

            Assert.That(result, Is.True);
        }
Ejemplo n.º 4
0
        public void ProcessFile_DownloadsSuccesfully_ReturnsTrue(
            string fileName,
            string[] ignored,
            TvReleaseIdentity tvRelease,
            [Frozen] IEpisodeParser episodeParser,
            [Frozen] ISubtitleDownloadService subtitleService,
            FileProcessor sut)
        {
            A.CallTo(() => subtitleService.DownloadSubtitle(A<string>._, A<TvReleaseIdentity>._, A<IEnumerable<Language>>._))
                .Returns(true);
            A.CallTo(() => episodeParser.ParseEpisodeInfo(A<string>._)).Returns(tvRelease);

            var result = sut.ProcessFile(fileName, ignored);

            Assert.That(result, Is.True);
        }
Ejemplo n.º 5
0
        public void ProcessFile_SomeLanguagesAlreadyDownloaded_TriesToDownloadOnlyNotDownloaded(
            string fileName,
            TvReleaseIdentity tvRelease,
            [Frozen]LanguageSettings languageSettings,
            [Frozen]IEpisodeParser episodeParser,
            [Frozen]ISubtitleDownloadService subtitleService,
            [Frozen]IFileOperations fileOperations,
            FileProcessor sut)
        {
            var languages = languageSettings.Languages.ToArray();
            var alreadyDownloadedLanguages = languages.Skip(1);
            var expected = languages.Take(1);
            A.CallTo(() => fileOperations.GetDowloadedSubtitleLanguages(fileName,
                A<IEnumerable<Language>>.That.IsSameSequenceAs(languages)))
               .Returns(alreadyDownloadedLanguages);
            A.CallTo(() => episodeParser.ParseEpisodeInfo(A<string>._)).Returns(tvRelease);

            sut.ProcessFile(fileName, new string[0]);

            A.CallTo(() => subtitleService.DownloadSubtitle(A<string>._, A<TvReleaseIdentity>._, A<Language[]>
                .That.IsSameSequenceAs(expected))).MustHaveHappened();
        }
Ejemplo n.º 6
0
        public void ProcessFile_ShowIsIgnored_ReturnsTrue(
            string fileName,
            [Frozen]string[] ignored,
            TvReleaseIdentity tvRelease,
            [Frozen] IEpisodeParser episodeParser,
            FileProcessor sut)
        {
            tvRelease.SeriesName = ignored.First();
            A.CallTo(() => episodeParser.ParseEpisodeInfo(fileName)).Returns(tvRelease);

            bool result = sut.ProcessFile(fileName, ignored);

            Assert.That(result, Is.True);
        }
Ejemplo n.º 7
0
        public void ProcessFile_ShowIsIgnored_DoesNotDownload(
            string fileName,
            string[] ignored,
            TvReleaseIdentity tvRelease,
            [Frozen] IEpisodeParser episodeParser,
            [Frozen] ISubtitleDownloadService subtitleService,
            FileProcessor sut)
        {
            tvRelease.SeriesName = ignored.First();
            A.CallTo(() => episodeParser.ParseEpisodeInfo(fileName)).Returns(tvRelease);

            sut.ProcessFile(fileName, ignored);

            A.CallTo(() => subtitleService.DownloadSubtitle(A<string>._, A<TvReleaseIdentity>._, A<IEnumerable<Language>>._)).MustNotHaveHappened();
        }