diff --git a/NzbDrone.Core.Test/ProviderTests/SeriesProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/SeriesProviderTest.cs index 17d2a2c12..379421e06 100644 --- a/NzbDrone.Core.Test/ProviderTests/SeriesProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/SeriesProviderTest.cs @@ -46,6 +46,15 @@ public void Add_new_series(bool useSeasonFolder) series.First().SeasonFolder.Should().Be(useSeasonFolder); } + + [TestCase(0)] + [TestCase(-1)] + public void add_series_should_fail_if_series_is_less_than_zero(int seriesId) + { + WithRealDb(); + Assert.Throws(() => Mocker.Resolve().AddSeries("C:\\Test", seriesId, 1)); + } + [Test] public void find_series_empty_repo() { diff --git a/NzbDrone.Core/Jobs/UpdateInfoJob.cs b/NzbDrone.Core/Jobs/UpdateInfoJob.cs index bd63cf978..4217e11cd 100644 --- a/NzbDrone.Core/Jobs/UpdateInfoJob.cs +++ b/NzbDrone.Core/Jobs/UpdateInfoJob.cs @@ -50,7 +50,7 @@ public virtual void Start(ProgressNotification notification, int targetId, int s } else { - seriesToUpdate = new List() { _seriesProvider.GetSeries(targetId) }; + seriesToUpdate = new List { _seriesProvider.GetSeries(targetId) }; } //Update any Daily Series in the DB with the IsDaily flag diff --git a/NzbDrone.Core/Providers/SeriesProvider.cs b/NzbDrone.Core/Providers/SeriesProvider.cs index 07f6a637e..69a029755 100644 --- a/NzbDrone.Core/Providers/SeriesProvider.cs +++ b/NzbDrone.Core/Providers/SeriesProvider.cs @@ -104,6 +104,11 @@ public virtual void AddSeries(string path, int tvDbSeriesId, int qualityProfileI { Logger.Info("Adding Series [{0}] Path: [{1}]", tvDbSeriesId, path); + if (tvDbSeriesId <=0) + { + throw new ArgumentOutOfRangeException("tvDbSeriesId", tvDbSeriesId.ToString()); + } + var repoSeries = new Series(); repoSeries.SeriesId = tvDbSeriesId; repoSeries.Path = path;