Ejemplo n.º 1
0
        public void IsUpgradeTestLanguage(Quality current, int currentVersion, Language currentLanguage, Quality newQuality, int newVersion, Language newLanguage, Quality cutoff, Language languageCutoff, bool expected)
        {
            GivenAutoDownloadPropers(ProperDownloadTypes.PreferAndUpgrade);

            var profile = new QualityProfile
            {
                UpgradeAllowed = true,
                Items          = Qualities.QualityFixture.GetDefaultQualities(),
                Cutoff         = cutoff.Id,
            };

            var langProfile = new LanguageProfile
            {
                UpgradeAllowed = true,
                Languages      = LanguageFixture.GetDefaultLanguages(),
                Cutoff         = languageCutoff
            };

            Subject.IsUpgradable(
                profile,
                langProfile,
                new QualityModel(current, new Revision(version: currentVersion)),
                currentLanguage,
                NoPreferredWordScore,
                new QualityModel(newQuality, new Revision(version: newVersion)),
                newLanguage,
                NoPreferredWordScore)
            .Should().Be(expected);
        }
Ejemplo n.º 2
0
        public void should_return_false_if_proper_and_autoDownloadPropers_is_do_not_prefer()
        {
            GivenAutoDownloadPropers(ProperDownloadTypes.DoNotPrefer);

            var profile = new QualityProfile
            {
                Items = Qualities.QualityFixture.GetDefaultQualities(),
            };

            var langProfile = new LanguageProfile
            {
                Languages = LanguageFixture.GetDefaultLanguages(),
                Cutoff    = Language.English
            };


            Subject.IsUpgradable(
                profile,
                langProfile,
                new QualityModel(Quality.DVD, new Revision(version: 1)),
                Language.English,
                NoPreferredWordScore,
                new QualityModel(Quality.DVD, new Revision(version: 2)),
                Language.English,
                NoPreferredWordScore)
            .Should().BeFalse();
        }
        public void should_return_false_if_quality_profile_does_not_allow_upgrades_but_cutoff_is_set_to_highest_quality_and_language_cutoff_is_met()
        {
            QualityProfile _profile = new QualityProfile
            {
                Cutoff         = Quality.WEBDL1080p.Id,
                Items          = Qualities.QualityFixture.GetDefaultQualities(),
                UpgradeAllowed = false
            };

            LanguageProfile _langProfile = new LanguageProfile
            {
                Cutoff         = Language.English,
                Languages      = LanguageFixture.GetDefaultLanguages(Language.Spanish, Language.English, Language.Arabic),
                UpgradeAllowed = true
            };

            Subject.CutoffNotMet(
                _profile,
                _langProfile,
                new QualityModel(Quality.WEBDL1080p),
                Language.English,
                NoPreferredWordScore,
                new QualityModel(Quality.Bluray1080p),
                NoPreferredWordScore).Should().BeFalse();
        }
        public void should_return_true_if_cutoffs_are_met_and_score_is_higher()
        {
            QualityProfile _profile = new QualityProfile
            {
                Cutoff         = Quality.HDTV720p.Id,
                Items          = Qualities.QualityFixture.GetDefaultQualities(),
                UpgradeAllowed = true
            };

            LanguageProfile _langProfile = new LanguageProfile
            {
                Cutoff         = Language.Spanish,
                Languages      = LanguageFixture.GetDefaultLanguages(),
                UpgradeAllowed = true
            };

            Subject.CutoffNotMet(
                _profile,
                _langProfile,
                new QualityModel(Quality.HDTV720p, new Revision(version: 2)),
                Language.Spanish,
                NoPreferredWordScore,
                new QualityModel(Quality.Bluray1080p, new Revision(version: 2)),
                10).Should().BeTrue();
        }
        public void should_return_true_if_cutoffs_are_met_but_is_a_revision_upgrade()
        {
            QualityProfile _profile = new QualityProfile
            {
                Cutoff         = Quality.HDTV1080p.Id,
                Items          = Qualities.QualityFixture.GetDefaultQualities(),
                UpgradeAllowed = true
            };

            LanguageProfile _langProfile = new LanguageProfile
            {
                Cutoff         = Language.English,
                Languages      = LanguageFixture.GetDefaultLanguages(),
                UpgradeAllowed = true
            };

            Subject.CutoffNotMet(
                _profile,
                _langProfile,
                new QualityModel(Quality.WEBDL1080p, new Revision(version: 1)),
                Language.English,
                NoPreferredWordScore,
                new QualityModel(Quality.WEBDL1080p, new Revision(version: 2)),
                NoPreferredWordScore).Should().BeTrue();
        }
        private RemoteEpisode GivenRemoteEpisode(List <Episode> episodes, QualityModel quality, Language language, int age = 0, long size = 0, DownloadProtocol downloadProtocol = DownloadProtocol.Usenet)
        {
            var remoteEpisode = new RemoteEpisode();

            remoteEpisode.ParsedEpisodeInfo          = new ParsedEpisodeInfo();
            remoteEpisode.ParsedEpisodeInfo.Quality  = quality;
            remoteEpisode.ParsedEpisodeInfo.Language = language;

            remoteEpisode.Episodes = new List <Episode>();
            remoteEpisode.Episodes.AddRange(episodes);

            remoteEpisode.Release                  = new ReleaseInfo();
            remoteEpisode.Release.PublishDate      = DateTime.Now.AddDays(-age);
            remoteEpisode.Release.Size             = size;
            remoteEpisode.Release.DownloadProtocol = downloadProtocol;

            remoteEpisode.Series = Builder <Series> .CreateNew()
                                   .With(e => e.QualityProfile = new QualityProfile
            {
                Items = Qualities.QualityFixture.GetDefaultQualities()
            })
                                   .With(l => l.LanguageProfile = new LanguageProfile
            {
                Languages = LanguageFixture.GetDefaultLanguages(),
                Cutoff    = Language.Spanish
            })
                                   .Build();

            return(remoteEpisode);
        }
Ejemplo n.º 7
0
 public void should_return_false_if_current_episode_is_greater_than_cutoff()
 {
     Subject.CutoffNotMet(
         new QualityProfile
     {
         Cutoff = Quality.HDTV720p.Id,
         Items  = Qualities.QualityFixture.GetDefaultQualities()
     },
         new LanguageProfile
     {
         Languages = LanguageFixture.GetDefaultLanguages(Language.English),
         Cutoff    = Language.English
     },
         new QualityModel(Quality.Bluray1080p, new Revision(version: 2)),
         Language.English,
         NoPreferredWordScore).Should().BeFalse();
 }
Ejemplo n.º 8
0
        public void Setup()
        {
            var profile = new QualityProfile
            {
                Name   = "Test",
                Cutoff = Quality.WEBDL720p.Id,
                Items  = Qualities.QualityFixture.GetDefaultQualities(),
            };

            var languageProfile = new LanguageProfile
            {
                Name      = "Test",
                Languages = LanguageFixture.GetDefaultLanguages(Language.English),
                Cutoff    = Language.English
            };

            profile         = Db.Insert(profile);
            languageProfile = Db.Insert(languageProfile);

            var series = Builder <Series> .CreateListOfSize(1)
                         .All()
                         .With(v => v.QualityProfileId  = profile.Id)
                         .With(v => v.LanguageProfileId = languageProfile.Id)
                         .BuildListOfNew();

            Db.InsertMany(series);

            var episodeFiles = Builder <EpisodeFile> .CreateListOfSize(1)
                               .All()
                               .With(v => v.SeriesId = series[0].Id)
                               .With(v => v.Quality  = new QualityModel())
                               .BuildListOfNew();

            Db.InsertMany(episodeFiles);

            var episodes = Builder <Episode> .CreateListOfSize(10)
                           .All()
                           .With(v => v.Monitored     = true)
                           .With(v => v.EpisodeFileId = episodeFiles[0].Id)
                           .With(v => v.SeriesId      = series[0].Id)
                           .BuildListOfNew();

            Db.InsertMany(episodes);
        }
 public void should_return_true_if_current_episode_is_less_than_cutoff()
 {
     Subject.CutoffNotMet(
         new QualityProfile
     {
         Cutoff         = Quality.Bluray1080p.Id,
         Items          = Qualities.QualityFixture.GetDefaultQualities(),
         UpgradeAllowed = true
     },
         new LanguageProfile
     {
         Languages      = LanguageFixture.GetDefaultLanguages(Language.English),
         Cutoff         = Language.English,
         UpgradeAllowed = true
     },
         new QualityModel(Quality.DVD, new Revision(version: 2)),
         Language.English,
         NoPreferredWordScore).Should().BeTrue();
 }
Ejemplo n.º 10
0
 public void should_return_true_when_new_episode_is_proper_but_existing_is_not()
 {
     Subject.CutoffNotMet(
         new QualityProfile
     {
         Cutoff = Quality.HDTV720p.Id,
         Items  = Qualities.QualityFixture.GetDefaultQualities()
     },
         new LanguageProfile
     {
         Languages = LanguageFixture.GetDefaultLanguages(Language.English),
         Cutoff    = Language.English
     },
         new QualityModel(Quality.HDTV720p, new Revision(version: 1)),
         Language.English,
         NoPreferredWordScore,
         new QualityModel(Quality.HDTV720p, new Revision(version: 2)),
         NoPreferredWordScore).Should().BeTrue();
 }
Ejemplo n.º 11
0
        public void Setup()
        {
            LanguageProfile _profile = new LazyLoaded <LanguageProfile> (new LanguageProfile
            {
                Languages = LanguageFixture.GetDefaultLanguages(Language.English, Language.Spanish),
                Cutoff    = Language.Spanish
            });

            _remoteEpisode = new RemoteEpisode
            {
                ParsedEpisodeInfo = new ParsedEpisodeInfo
                {
                    Language = Language.English
                },
                Series = new Series
                {
                    LanguageProfile = _profile
                }
            };
        }
 public void should_return_false_if_cutoff_is_met_and_quality_is_higher()
 {
     Subject.CutoffNotMet(
         new QualityProfile
     {
         Cutoff         = Quality.HDTV720p.Id,
         Items          = Qualities.QualityFixture.GetDefaultQualities(),
         UpgradeAllowed = true
     },
         new LanguageProfile
     {
         Languages      = LanguageFixture.GetDefaultLanguages(Language.English),
         Cutoff         = Language.English,
         UpgradeAllowed = true
     },
         new QualityModel(Quality.HDTV720p, new Revision(version: 2)),
         Language.English,
         NoPreferredWordScore,
         new QualityModel(Quality.Bluray1080p, new Revision(version: 2)),
         NoPreferredWordScore).Should().BeFalse();
 }
Ejemplo n.º 13
0
 public void should_return_true_for_same_language_when_upgrading_is_allowed()
 {
     Subject.IsUpgradeAllowed(
         new QualityProfile
     {
         Cutoff         = Quality.Bluray1080p.Id,
         Items          = Qualities.QualityFixture.GetDefaultQualities(),
         UpgradeAllowed = true
     },
         new LanguageProfile
     {
         Languages      = LanguageFixture.GetDefaultLanguages(Language.English, Language.French),
         Cutoff         = Language.French,
         UpgradeAllowed = true
     },
         new QualityModel(Quality.DVD),
         Language.English,
         new QualityModel(Quality.DVD),
         Language.English
         ).Should().BeTrue();
 }
Ejemplo n.º 14
0
        public void should_return_true_if_cutoff_is_not_met_and_language_is_higher()
        {
            QualityProfile _profile = new QualityProfile
            {
                Cutoff = Quality.HDTV720p.Id,
                Items  = Qualities.QualityFixture.GetDefaultQualities(),
            };

            LanguageProfile _langProfile = new LanguageProfile
            {
                Cutoff    = Language.Spanish,
                Languages = LanguageFixture.GetDefaultLanguages()
            };

            Subject.CutoffNotMet(
                _profile,
                _langProfile,
                new QualityModel(Quality.SDTV, new Revision(version: 2)),
                Language.French,
                NoPreferredWordScore).Should().BeTrue();
        }
Ejemplo n.º 15
0
 public void should_return_false_when_quality_is_better_languages_are_the_same_and_upgrade_allowed_is_false_for_quality_profile()
 {
     Subject.IsUpgradeAllowed(
         new QualityProfile
     {
         Cutoff         = Quality.Bluray1080p.Id,
         Items          = Qualities.QualityFixture.GetDefaultQualities(),
         UpgradeAllowed = false
     },
         new LanguageProfile
     {
         Languages      = LanguageFixture.GetDefaultLanguages(Language.English),
         Cutoff         = Language.English,
         UpgradeAllowed = true
     },
         new QualityModel(Quality.DVD),
         Language.English,
         new QualityModel(Quality.Bluray1080p),
         Language.English
         ).Should().BeFalse();
 }
Ejemplo n.º 16
0
        public void should_return_false_if_release_and_existing_file_are_the_same()
        {
            var profile = new QualityProfile
            {
                Items = Qualities.QualityFixture.GetDefaultQualities(),
            };

            var langProfile = new LanguageProfile
            {
                Languages = LanguageFixture.GetDefaultLanguages(),
                Cutoff    = Language.English
            };

            Subject.IsUpgradable(
                profile,
                langProfile,
                new QualityModel(Quality.HDTV720p, new Revision(version: 1)),
                Language.English,
                NoPreferredWordScore,
                new QualityModel(Quality.HDTV720p, new Revision(version: 1)),
                Language.English,
                NoPreferredWordScore)
            .Should().BeFalse();
        }
Ejemplo n.º 17
0
        public void Setup()
        {
            Mocker.Resolve <UpgradableSpecification>();
            _upgradeHistory = Mocker.Resolve <HistorySpecification>();

            var singleEpisodeList = new List <Episode> {
                new Episode {
                    Id = FIRST_EPISODE_ID, SeasonNumber = 12, EpisodeNumber = 3
                }
            };
            var doubleEpisodeList = new List <Episode> {
                new Episode {
                    Id = FIRST_EPISODE_ID, SeasonNumber = 12, EpisodeNumber = 3
                },
                new Episode {
                    Id = SECOND_EPISODE_ID, SeasonNumber = 12, EpisodeNumber = 4
                },
                new Episode {
                    Id = 3, SeasonNumber = 12, EpisodeNumber = 5
                }
            };

            _fakeSeries = Builder <Series> .CreateNew()
                          .With(c => c.QualityProfile = new QualityProfile
            {
                UpgradeAllowed = true,
                Cutoff         = Quality.Bluray1080p.Id,
                Items          = Qualities.QualityFixture.GetDefaultQualities()
            })
                          .With(l => l.LanguageProfile = new LanguageProfile
            {
                UpgradeAllowed = true,
                Cutoff         = Language.Spanish,
                Languages      = LanguageFixture.GetDefaultLanguages()
            })
                          .Build();

            _parseResultMulti = new RemoteEpisode
            {
                Series            = _fakeSeries,
                ParsedEpisodeInfo = new ParsedEpisodeInfo {
                    Quality = new QualityModel(Quality.DVD, new Revision(version: 2)), Language = Language.English
                },
                Episodes = doubleEpisodeList
            };

            _parseResultSingle = new RemoteEpisode
            {
                Series            = _fakeSeries,
                ParsedEpisodeInfo = new ParsedEpisodeInfo {
                    Quality = new QualityModel(Quality.DVD, new Revision(version: 2)), Language = Language.English
                },
                Episodes = singleEpisodeList
            };

            _upgradableQuality = new Tuple <QualityModel, Language> (new QualityModel(Quality.SDTV, new Revision(version: 1)), Language.English);

            _notupgradableQuality = new Tuple <QualityModel, Language> (new QualityModel(Quality.HDTV1080p, new Revision(version: 2)), Language.English);

            Mocker.GetMock <IConfigService>()
            .SetupGet(s => s.EnableCompletedDownloadHandling)
            .Returns(true);
        }