diff --git a/NzbDrone.Api/RootFolders/RootFolderModule.cs b/NzbDrone.Api/RootFolders/RootFolderModule.cs index 87033936d..1227ec68a 100644 --- a/NzbDrone.Api/RootFolders/RootFolderModule.cs +++ b/NzbDrone.Api/RootFolders/RootFolderModule.cs @@ -2,7 +2,7 @@ using Nancy; using NzbDrone.Api.Extensions; using NzbDrone.Core.Providers; -using NzbDrone.Core.Repository; + using NzbDrone.Core.RootFolders; namespace NzbDrone.Api.RootFolders diff --git a/NzbDrone.Core.Test/DecisionEngineTests/AcceptableSizeSpecificationFixture.cs b/NzbDrone.Core.Test/DecisionEngineTests/AcceptableSizeSpecificationFixture.cs index 9ea99b486..c0f3fc3fb 100644 --- a/NzbDrone.Core.Test/DecisionEngineTests/AcceptableSizeSpecificationFixture.cs +++ b/NzbDrone.Core.Test/DecisionEngineTests/AcceptableSizeSpecificationFixture.cs @@ -13,7 +13,6 @@ using NzbDrone.Core.Tv; using NzbDrone.Core.Model; using NzbDrone.Core.Providers; using NzbDrone.Core.DecisionEngine; -using NzbDrone.Core.Repository; using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.DecisionEngineTests diff --git a/NzbDrone.Core.Test/DecisionEngineTests/AllowedDownloadSpecificationFixture.cs b/NzbDrone.Core.Test/DecisionEngineTests/AllowedDownloadSpecificationFixture.cs index 8cfa6a87f..d5cd64537 100644 --- a/NzbDrone.Core.Test/DecisionEngineTests/AllowedDownloadSpecificationFixture.cs +++ b/NzbDrone.Core.Test/DecisionEngineTests/AllowedDownloadSpecificationFixture.cs @@ -1,181 +1,53 @@ -// ReSharper disable RedundantUsingDirective - -using System.Linq; -using System; -using System.Collections.Generic; -using FizzWare.NBuilder; -using FluentAssertions; +using System.ComponentModel; using Moq; using NUnit.Framework; -using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.Model; -using NzbDrone.Core.Providers; using NzbDrone.Core.DecisionEngine; -using NzbDrone.Core.Repository; using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.DecisionEngineTests { [TestFixture] - // ReSharper disable InconsistentNaming public class AllowedDownloadSpecificationFixture : CoreTest { - private AllowedDownloadSpecification spec; private EpisodeParseResult parseResult; + private Mock pass1; + private Mock pass2; + private Mock pass3; + + private Mock fail1; + private Mock fail2; + private Mock fail3; + [SetUp] public void Setup() { - spec = Mocker.Resolve(); + pass1 = new Mock(); + pass2 = new Mock(); + pass3 = new Mock(); + + fail1 = new Mock(); + fail2 = new Mock(); + fail3 = new Mock(); + + pass1.Setup(c => c.IsSatisfiedBy(It.IsAny())).Returns(true); + pass2.Setup(c => c.IsSatisfiedBy(It.IsAny())).Returns(true); + pass3.Setup(c => c.IsSatisfiedBy(It.IsAny())).Returns(true); + + fail1.Setup(c => c.IsSatisfiedBy(It.IsAny())).Returns(false); + fail2.Setup(c => c.IsSatisfiedBy(It.IsAny())).Returns(false); + fail3.Setup(c => c.IsSatisfiedBy(It.IsAny())).Returns(false); + parseResult = new EpisodeParseResult(); - Mocker.GetMock() - .Setup(c => c.IsSatisfiedBy(It.IsAny())) - .Returns(true); - - Mocker.GetMock() - .Setup(c => c.IsSatisfiedBy(It.IsAny())) - .Returns(true); - - Mocker.GetMock() - .Setup(c => c.IsSatisfiedBy(It.IsAny())) - .Returns(true); - - Mocker.GetMock() - .Setup(c => c.IsSatisfiedBy(It.IsAny())) - .Returns(false); - - Mocker.GetMock() - .Setup(c => c.IsSatisfiedBy(It.IsAny())) - .Returns(true); - - Mocker.GetMock() - .Setup(c => c.IsSatisfiedBy(It.IsAny())) - .Returns(true); - - Mocker.GetMock() - .Setup(c => c.IsSatisfiedBy(It.IsAny())) - .Returns(true); - - Mocker.GetMock() - .Setup(c => c.IsSatisfiedBy(It.IsAny())) - .Returns(true); - } - - private void WithProfileNotAllowed() - { - Mocker.GetMock() - .Setup(c => c.IsSatisfiedBy(It.IsAny())) - .Returns(false); - } - - private void WithNotAcceptableSize() - { - Mocker.GetMock() - .Setup(c => c.IsSatisfiedBy(It.IsAny())) - .Returns(false); - } - - private void WithNoDiskUpgrade() - { - Mocker.GetMock() - .Setup(c => c.IsSatisfiedBy(It.IsAny())) - .Returns(false); - } - - private void WithEpisodeAlreadyInQueue() - { - Mocker.GetMock() - .Setup(c => c.IsSatisfiedBy(It.IsAny())) - .Returns(true); - } - - private void WithOverRetention() - { - Mocker.GetMock() - .Setup(c => c.IsSatisfiedBy(It.IsAny())) - .Returns(false); - } - - private void WithAiredBeforeCustomStartDateCutoff() - { - Mocker.GetMock() - .Setup(c => c.IsSatisfiedBy(It.IsAny())) - .Returns(false); - } - - private void WithLanguageNotWanted() - { - Mocker.GetMock() - .Setup(c => c.IsSatisfiedBy(It.IsAny())) - .Returns(false); } [Test] - public void should_be_allowed_if_all_conditions_are_met() + public void should_call_all_specifications() { - spec.IsSatisfiedBy(parseResult).Should().Be(ReportRejectionReasons.None); + throw new InvalidAsynchronousStateException(); } - [Test] - public void should_not_be_allowed_if_profile_is_not_allowed() - { - WithProfileNotAllowed(); - spec.IsSatisfiedBy(parseResult).Should().Be(ReportRejectionReasons.QualityNotWanted); - } - - [Test] - public void should_not_be_allowed_if_size_is_not_allowed() - { - WithNotAcceptableSize(); - spec.IsSatisfiedBy(parseResult).Should().Be(ReportRejectionReasons.Size); - } - - [Test] - public void should_not_be_allowed_if_disk_is_not_upgrade() - { - WithNoDiskUpgrade(); - spec.IsSatisfiedBy(parseResult).Should().Be(ReportRejectionReasons.ExistingQualityIsEqualOrBetter); - } - - [Test] - public void should_not_be_allowed_if_episode_is_already_in_queue() - { - WithEpisodeAlreadyInQueue(); - spec.IsSatisfiedBy(parseResult).Should().Be(ReportRejectionReasons.AlreadyInQueue); - } - - [Test] - public void should_not_be_allowed_if_report_is_over_retention() - { - WithOverRetention(); - spec.IsSatisfiedBy(parseResult).Should().Be(ReportRejectionReasons.Retention); - } - - [Test] - public void should_not_be_allowed_if_episode_aired_before_cutoff() - { - WithAiredBeforeCustomStartDateCutoff(); - spec.IsSatisfiedBy(parseResult).Should().Be(ReportRejectionReasons.AiredAfterCustomStartDate); - } - - [Test] - public void should_not_be_allowed_if_none_of_conditions_are_met() - { - WithNoDiskUpgrade(); - WithNotAcceptableSize(); - WithProfileNotAllowed(); - WithOverRetention(); - - spec.IsSatisfiedBy(parseResult).Should().Be(ReportRejectionReasons.QualityNotWanted); - } - - [Test] - public void should_not_be_allowed_if_language_is_not_wanted() - { - WithLanguageNotWanted(); - - spec.IsSatisfiedBy(parseResult).Should().Be(ReportRejectionReasons.LanguageNotWanted); - } } } \ No newline at end of file diff --git a/NzbDrone.Core.Test/DecisionEngineTests/AllowedReleaseGroupSpecificationFixture.cs b/NzbDrone.Core.Test/DecisionEngineTests/AllowedReleaseGroupSpecificationFixture.cs index 2ff13388d..fc90d27d9 100644 --- a/NzbDrone.Core.Test/DecisionEngineTests/AllowedReleaseGroupSpecificationFixture.cs +++ b/NzbDrone.Core.Test/DecisionEngineTests/AllowedReleaseGroupSpecificationFixture.cs @@ -14,7 +14,7 @@ using NzbDrone.Core.Tv; using NzbDrone.Core.Model; using NzbDrone.Core.Providers; using NzbDrone.Core.DecisionEngine; -using NzbDrone.Core.Repository; + using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.DecisionEngineTests diff --git a/NzbDrone.Core.Test/DecisionEngineTests/CustomStartDateSpecificationFixture.cs b/NzbDrone.Core.Test/DecisionEngineTests/CustomStartDateSpecificationFixture.cs index b22c74d39..23f8b4bb7 100644 --- a/NzbDrone.Core.Test/DecisionEngineTests/CustomStartDateSpecificationFixture.cs +++ b/NzbDrone.Core.Test/DecisionEngineTests/CustomStartDateSpecificationFixture.cs @@ -12,7 +12,7 @@ using NzbDrone.Core.Tv; using NzbDrone.Core.Model; using NzbDrone.Core.Providers; using NzbDrone.Core.DecisionEngine; -using NzbDrone.Core.Repository; + using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.DecisionEngineTests diff --git a/NzbDrone.Core.Test/DecisionEngineTests/LanguageSpecificationFixture.cs b/NzbDrone.Core.Test/DecisionEngineTests/LanguageSpecificationFixture.cs index fc904005d..1c9222856 100644 --- a/NzbDrone.Core.Test/DecisionEngineTests/LanguageSpecificationFixture.cs +++ b/NzbDrone.Core.Test/DecisionEngineTests/LanguageSpecificationFixture.cs @@ -11,7 +11,7 @@ using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.Model; using NzbDrone.Core.Providers; using NzbDrone.Core.DecisionEngine; -using NzbDrone.Core.Repository; + using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.DecisionEngineTests diff --git a/NzbDrone.Core.Test/DecisionEngineTests/MonitoredEpisodeSpecificationFixture.cs b/NzbDrone.Core.Test/DecisionEngineTests/MonitoredEpisodeSpecificationFixture.cs index a36fb4cf6..dc7a32fe5 100644 --- a/NzbDrone.Core.Test/DecisionEngineTests/MonitoredEpisodeSpecificationFixture.cs +++ b/NzbDrone.Core.Test/DecisionEngineTests/MonitoredEpisodeSpecificationFixture.cs @@ -12,7 +12,7 @@ using NzbDrone.Core.Tv; using NzbDrone.Core.Model; using NzbDrone.Core.Providers; using NzbDrone.Core.DecisionEngine; -using NzbDrone.Core.Repository; + using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.DecisionEngineTests diff --git a/NzbDrone.Core.Test/DecisionEngineTests/QualityAllowedByProfileSpecificationFixture.cs b/NzbDrone.Core.Test/DecisionEngineTests/QualityAllowedByProfileSpecificationFixture.cs index 1d9087d02..4ee9ff65a 100644 --- a/NzbDrone.Core.Test/DecisionEngineTests/QualityAllowedByProfileSpecificationFixture.cs +++ b/NzbDrone.Core.Test/DecisionEngineTests/QualityAllowedByProfileSpecificationFixture.cs @@ -10,7 +10,7 @@ using NzbDrone.Core.Qualities; using NzbDrone.Core.Tv; using NzbDrone.Core.Model; using NzbDrone.Core.DecisionEngine; -using NzbDrone.Core.Repository; + using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.DecisionEngineTests diff --git a/NzbDrone.Core.Test/DecisionEngineTests/RetentionSpecificationFixture.cs b/NzbDrone.Core.Test/DecisionEngineTests/RetentionSpecificationFixture.cs index a57e74d1b..056e8142b 100644 --- a/NzbDrone.Core.Test/DecisionEngineTests/RetentionSpecificationFixture.cs +++ b/NzbDrone.Core.Test/DecisionEngineTests/RetentionSpecificationFixture.cs @@ -12,7 +12,7 @@ using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.Model; using NzbDrone.Core.Providers; using NzbDrone.Core.DecisionEngine; -using NzbDrone.Core.Repository; + using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.DecisionEngineTests diff --git a/NzbDrone.Core.Test/DecisionEngineTests/UpgradeDiskSpecificationFixture.cs b/NzbDrone.Core.Test/DecisionEngineTests/UpgradeDiskSpecificationFixture.cs index 893cbba96..fe574abe1 100644 --- a/NzbDrone.Core.Test/DecisionEngineTests/UpgradeDiskSpecificationFixture.cs +++ b/NzbDrone.Core.Test/DecisionEngineTests/UpgradeDiskSpecificationFixture.cs @@ -13,7 +13,7 @@ using NzbDrone.Core.Tv; using NzbDrone.Core.Model; using NzbDrone.Core.Providers; using NzbDrone.Core.DecisionEngine; -using NzbDrone.Core.Repository; + using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.DecisionEngineTests diff --git a/NzbDrone.Core.Test/DecisionEngineTests/UpgradeHistorySpecificationFixture.cs b/NzbDrone.Core.Test/DecisionEngineTests/UpgradeHistorySpecificationFixture.cs index e08f051b4..dd0c416f4 100644 --- a/NzbDrone.Core.Test/DecisionEngineTests/UpgradeHistorySpecificationFixture.cs +++ b/NzbDrone.Core.Test/DecisionEngineTests/UpgradeHistorySpecificationFixture.cs @@ -12,7 +12,7 @@ using NzbDrone.Core.Tv; using NzbDrone.Core.Model; using NzbDrone.Core.Providers; using NzbDrone.Core.DecisionEngine; -using NzbDrone.Core.Repository; + using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.DecisionEngineTests diff --git a/NzbDrone.Core.Test/EpisodeStatusTest.cs b/NzbDrone.Core.Test/EpisodeStatusTest.cs index 8f43afbee..7f30d1520 100644 --- a/NzbDrone.Core.Test/EpisodeStatusTest.cs +++ b/NzbDrone.Core.Test/EpisodeStatusTest.cs @@ -5,7 +5,7 @@ using NUnit.Framework; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Tv; using NzbDrone.Core.Model; -using NzbDrone.Core.Repository; + using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test diff --git a/NzbDrone.Core.Test/Framework/TestDbHelper.cs b/NzbDrone.Core.Test/Framework/TestDbHelper.cs index ff96696ff..b5bfa6bbe 100644 --- a/NzbDrone.Core.Test/Framework/TestDbHelper.cs +++ b/NzbDrone.Core.Test/Framework/TestDbHelper.cs @@ -7,7 +7,7 @@ using FluentAssertions; using Moq; using NzbDrone.Common; using NzbDrone.Core.Datastore; -using NzbDrone.Core.Repository; + namespace NzbDrone.Core.Test.Framework diff --git a/NzbDrone.Core.Test/HelperTests/SortHelperFixture.cs b/NzbDrone.Core.Test/HelperTests/SortHelperFixture.cs index 19f6d028a..468a00582 100644 --- a/NzbDrone.Core.Test/HelperTests/SortHelperFixture.cs +++ b/NzbDrone.Core.Test/HelperTests/SortHelperFixture.cs @@ -9,7 +9,7 @@ using NUnit.Framework; using NzbDrone.Core.Helpers; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; -using NzbDrone.Core.Repository; + using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.HelperTests diff --git a/NzbDrone.Core.Test/HelperTests/XElementHelperTests/ConvertToTFixture.cs b/NzbDrone.Core.Test/HelperTests/XElementHelperTests/ConvertToTFixture.cs index 71256c40d..b9c0168d9 100644 --- a/NzbDrone.Core.Test/HelperTests/XElementHelperTests/ConvertToTFixture.cs +++ b/NzbDrone.Core.Test/HelperTests/XElementHelperTests/ConvertToTFixture.cs @@ -9,7 +9,7 @@ using NUnit.Framework; using NzbDrone.Core.Helpers; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; -using NzbDrone.Core.Repository; + using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.HelperTests.XElementHelperTests diff --git a/NzbDrone.Core.Test/IndexerTests/IndexerFixture.cs b/NzbDrone.Core.Test/IndexerTests/IndexerFixture.cs index d66db7263..1fbde8c7b 100644 --- a/NzbDrone.Core.Test/IndexerTests/IndexerFixture.cs +++ b/NzbDrone.Core.Test/IndexerTests/IndexerFixture.cs @@ -15,7 +15,7 @@ using NzbDrone.Core.Indexers; using NzbDrone.Core.Model; using NzbDrone.Core.Providers; using NzbDrone.Core.Qualities; -using NzbDrone.Core.Repository; + using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Test.Indexers; using NzbDrone.Core.Test.ProviderTests; diff --git a/NzbDrone.Core.Test/IndexerTests/NzbxFixture.cs b/NzbDrone.Core.Test/IndexerTests/NzbxFixture.cs index f62b9c282..f108b9f5b 100644 --- a/NzbDrone.Core.Test/IndexerTests/NzbxFixture.cs +++ b/NzbDrone.Core.Test/IndexerTests/NzbxFixture.cs @@ -13,7 +13,7 @@ using NzbDrone.Common; using NzbDrone.Core.Indexers; using NzbDrone.Core.Model; using NzbDrone.Core.Providers; -using NzbDrone.Core.Repository; + using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Test.ProviderTests; using NzbDrone.Test.Common; diff --git a/NzbDrone.Core.Test/JobTests/BacklogSearchJobTest.cs b/NzbDrone.Core.Test/JobTests/BacklogSearchJobTest.cs index bbdccefab..c77733fe5 100644 --- a/NzbDrone.Core.Test/JobTests/BacklogSearchJobTest.cs +++ b/NzbDrone.Core.Test/JobTests/BacklogSearchJobTest.cs @@ -11,7 +11,7 @@ using NzbDrone.Core.Jobs; using NzbDrone.Core.Model; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; -using NzbDrone.Core.Repository; + using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; diff --git a/NzbDrone.Core.Test/JobTests/DiskScanJobTest.cs b/NzbDrone.Core.Test/JobTests/DiskScanJobTest.cs index 60bb0ff39..31a3f2abc 100644 --- a/NzbDrone.Core.Test/JobTests/DiskScanJobTest.cs +++ b/NzbDrone.Core.Test/JobTests/DiskScanJobTest.cs @@ -12,7 +12,7 @@ using NzbDrone.Core.Tv; using NzbDrone.Core.Jobs; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; -using NzbDrone.Core.Repository; + using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; using NzbDrone.Test.Common.AutoMoq; diff --git a/NzbDrone.Core.Test/JobTests/ImportNewSeriesJobTest.cs b/NzbDrone.Core.Test/JobTests/ImportNewSeriesJobTest.cs index b1844ff90..392889815 100644 --- a/NzbDrone.Core.Test/JobTests/ImportNewSeriesJobTest.cs +++ b/NzbDrone.Core.Test/JobTests/ImportNewSeriesJobTest.cs @@ -12,7 +12,7 @@ using NzbDrone.Core.Tv; using NzbDrone.Core.Jobs; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; -using NzbDrone.Core.Repository; + using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; using NzbDrone.Test.Common.AutoMoq; diff --git a/NzbDrone.Core.Test/JobTests/JobRepositoryFixture.cs b/NzbDrone.Core.Test/JobTests/JobRepositoryFixture.cs index 7d0685c66..66a070e5c 100644 --- a/NzbDrone.Core.Test/JobTests/JobRepositoryFixture.cs +++ b/NzbDrone.Core.Test/JobTests/JobRepositoryFixture.cs @@ -11,7 +11,7 @@ using NUnit.Framework; using NzbDrone.Common; using NzbDrone.Core.Jobs; using NzbDrone.Core.Model; -using NzbDrone.Core.Repository; + using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; diff --git a/NzbDrone.Core.Test/JobTests/RecentBacklogSearchJobTest.cs b/NzbDrone.Core.Test/JobTests/RecentBacklogSearchJobTest.cs index 0fac43d3f..3fc864f77 100644 --- a/NzbDrone.Core.Test/JobTests/RecentBacklogSearchJobTest.cs +++ b/NzbDrone.Core.Test/JobTests/RecentBacklogSearchJobTest.cs @@ -13,7 +13,7 @@ using NzbDrone.Core.Jobs; using NzbDrone.Core.Model; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; -using NzbDrone.Core.Repository; + using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; using NzbDrone.Test.Common.AutoMoq; diff --git a/NzbDrone.Core.Test/JobTests/RenameSeasonJobFixture.cs b/NzbDrone.Core.Test/JobTests/RenameSeasonJobFixture.cs index 7133d4705..90daf432e 100644 --- a/NzbDrone.Core.Test/JobTests/RenameSeasonJobFixture.cs +++ b/NzbDrone.Core.Test/JobTests/RenameSeasonJobFixture.cs @@ -11,7 +11,7 @@ using NzbDrone.Core.Tv; using NzbDrone.Core.Jobs; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; -using NzbDrone.Core.Repository; + using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.JobTests diff --git a/NzbDrone.Core.Test/JobTests/SeasonSearchJobTest.cs b/NzbDrone.Core.Test/JobTests/SeasonSearchJobTest.cs index 787e36dda..f6aa16d40 100644 --- a/NzbDrone.Core.Test/JobTests/SeasonSearchJobTest.cs +++ b/NzbDrone.Core.Test/JobTests/SeasonSearchJobTest.cs @@ -8,15 +8,10 @@ using NUnit.Framework; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Jobs.Implementations; using NzbDrone.Core.Tv; -using NzbDrone.Core.Jobs; -using NzbDrone.Core.Model; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; -using NzbDrone.Core.Repository; -using NzbDrone.Core.Repository.Search; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; -using NzbDrone.Test.Common.AutoMoq; namespace NzbDrone.Core.Test.JobTests { @@ -48,12 +43,6 @@ namespace NzbDrone.Core.Test.JobTests [Test] public void SeasonSearch_partial_season_success() { - var resultItems = Builder.CreateListOfSize(5) - .All() - .With(e => e.SearchError = ReportRejectionReasons.None) - .With(e => e.Success = true) - .Build(); - Mocker.GetMock() .Setup(c => c.PartialSeasonSearch(notification, 1, 1)) .Returns(_episodes.Select(e => e.EpisodeNumber).ToList()); diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.ncrunchproject b/NzbDrone.Core.Test/NzbDrone.Core.Test.ncrunchproject index 61dc909a2..0d7e988a0 100644 --- a/NzbDrone.Core.Test/NzbDrone.Core.Test.ncrunchproject +++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.ncrunchproject @@ -276,39 +276,6 @@ NzbDrone\.Core\.Test\.Datastore\.BasicRepositoryFixture\..* - - NzbDrone\.Core\.Test\.DecisionEngineTests\.AcceptableSizeSpecificationFixture\..* - - - NzbDrone\.Core\.Test\.DecisionEngineTests\.AllowedDownloadSpecificationFixture\..* - - - NzbDrone\.Core\.Test\.DecisionEngineTests\.AllowedReleaseGroupSpecificationFixture\..* - - - NzbDrone\.Core\.Test\.DecisionEngineTests\.CustomStartDateSpecificationFixture\..* - - - NzbDrone\.Core\.Test\.DecisionEngineTests\.LanguageSpecificationFixture\..* - - - NzbDrone\.Core\.Test\.DecisionEngineTests\.MonitoredEpisodeSpecificationFixture\..* - - - NzbDrone\.Core\.Test\.DecisionEngineTests\.QualityAllowedByProfileSpecificationFixture\..* - - - NzbDrone\.Core\.Test\.DecisionEngineTests\.QualityUpgradeSpecificationFixture\..* - - - NzbDrone\.Core\.Test\.DecisionEngineTests\.RetentionSpecificationFixture\..* - - - NzbDrone\.Core\.Test\.DecisionEngineTests\.UpgradeDiskSpecificationFixture\..* - - - NzbDrone\.Core\.Test\.DecisionEngineTests\.UpgradeHistorySpecificationFixture\..* - NzbDrone\.Core\.Test\.DecisionEngineTests\.UpgradePossibleSpecificationFixture\..* diff --git a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/CleanUpDropFolderFixture.cs b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/CleanUpDropFolderFixture.cs index 01413dc33..c36af0a5f 100644 --- a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/CleanUpDropFolderFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/CleanUpDropFolderFixture.cs @@ -14,7 +14,7 @@ using NzbDrone.Core.Qualities; using NzbDrone.Core.Tv; using NzbDrone.Core.Model; using NzbDrone.Core.Providers; -using NzbDrone.Core.Repository; + using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; using NzbDrone.Test.Common.AutoMoq; diff --git a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/CleanUpFixture.cs b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/CleanUpFixture.cs index fc344e9c0..c9bdca91d 100644 --- a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/CleanUpFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/CleanUpFixture.cs @@ -13,7 +13,7 @@ using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Tv; using NzbDrone.Core.Model; using NzbDrone.Core.Providers; -using NzbDrone.Core.Repository; + using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; using NzbDrone.Test.Common.AutoMoq; diff --git a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/GetVideoFilesFixture.cs b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/GetVideoFilesFixture.cs index 746078ab5..8319476e2 100644 --- a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/GetVideoFilesFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/GetVideoFilesFixture.cs @@ -10,7 +10,7 @@ using NUnit.Framework; using NzbDrone.Common; using NzbDrone.Core.Model; using NzbDrone.Core.Providers; -using NzbDrone.Core.Repository; + using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; using NzbDrone.Test.Common.AutoMoq; diff --git a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/ImportFileFixture.cs b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/ImportFileFixture.cs index 499797271..8de8dd989 100644 --- a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/ImportFileFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/ImportFileFixture.cs @@ -11,7 +11,7 @@ using NzbDrone.Core.Qualities; using NzbDrone.Core.Tv; using NzbDrone.Core.Model; using NzbDrone.Core.Providers; -using NzbDrone.Core.Repository; + using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; using NzbDrone.Test.Common.AutoMoq; diff --git a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/MoveEpisodeFileFixture.cs b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/MoveEpisodeFileFixture.cs index b65bbd6bb..6094e0c12 100644 --- a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/MoveEpisodeFileFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/MoveEpisodeFileFixture.cs @@ -16,7 +16,7 @@ using NzbDrone.Core.Qualities; using NzbDrone.Core.Tv; using NzbDrone.Core.Model; using NzbDrone.Core.Providers; -using NzbDrone.Core.Repository; + using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; using NzbDrone.Test.Common.AutoMoq; diff --git a/NzbDrone.Core.Test/ProviderTests/DownloadClientTests/SabProviderTests/QueueFixture.cs b/NzbDrone.Core.Test/ProviderTests/DownloadClientTests/SabProviderTests/QueueFixture.cs index d38ae0bf0..94c5cedd3 100644 --- a/NzbDrone.Core.Test/ProviderTests/DownloadClientTests/SabProviderTests/QueueFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/DownloadClientTests/SabProviderTests/QueueFixture.cs @@ -14,7 +14,7 @@ using NzbDrone.Core.Qualities; using NzbDrone.Core.Tv; using NzbDrone.Core.Model; using NzbDrone.Core.Download.Clients.Sabnzbd; -using NzbDrone.Core.Repository; + using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; diff --git a/NzbDrone.Core.Test/ProviderTests/DownloadClientTests/SabProviderTests/SabProviderFixture.cs b/NzbDrone.Core.Test/ProviderTests/DownloadClientTests/SabProviderTests/SabProviderFixture.cs index cb7762a97..9fa947edb 100644 --- a/NzbDrone.Core.Test/ProviderTests/DownloadClientTests/SabProviderTests/SabProviderFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/DownloadClientTests/SabProviderTests/SabProviderFixture.cs @@ -14,7 +14,7 @@ using NzbDrone.Core.Configuration; using NzbDrone.Core.Download.Clients; using NzbDrone.Core.Model; using NzbDrone.Core.Download.Clients.Sabnzbd; -using NzbDrone.Core.Repository; + using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; diff --git a/NzbDrone.Core.Test/ProviderTests/GrowlProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/GrowlProviderTest.cs index d1fe4e3ec..2061b4b68 100644 --- a/NzbDrone.Core.Test/ProviderTests/GrowlProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/GrowlProviderTest.cs @@ -7,7 +7,7 @@ using NUnit.Framework; using NzbDrone.Core.ExternalNotification; using NzbDrone.Core.Model; using NzbDrone.Core.Providers; -using NzbDrone.Core.Repository; + using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common.AutoMoq; diff --git a/NzbDrone.Core.Test/ProviderTests/MisnamedProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/MisnamedProviderTest.cs index 47de8f176..8061e4be4 100644 --- a/NzbDrone.Core.Test/ProviderTests/MisnamedProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/MisnamedProviderTest.cs @@ -9,7 +9,7 @@ using NzbDrone.Core.Organizer; using NzbDrone.Core.Qualities; using NzbDrone.Core.Tv; using NzbDrone.Core.Providers; -using NzbDrone.Core.Repository; + using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common.AutoMoq; diff --git a/NzbDrone.Core.Test/ProviderTests/PlexProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/PlexProviderTest.cs index b1ab91a1b..746a0165d 100644 --- a/NzbDrone.Core.Test/ProviderTests/PlexProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/PlexProviderTest.cs @@ -15,7 +15,7 @@ using NzbDrone.Core.ExternalNotification; using NzbDrone.Core.Model.Xbmc; using NzbDrone.Core.Providers; using NzbDrone.Core.Providers.Xbmc; -using NzbDrone.Core.Repository; + using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common.AutoMoq; diff --git a/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDownloadFixture.cs b/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDownloadFixture.cs index 20edfd049..9aec10123 100644 --- a/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDownloadFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDownloadFixture.cs @@ -12,7 +12,7 @@ using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Tv; using NzbDrone.Core.Model; using NzbDrone.Core.Providers; -using NzbDrone.Core.Repository; + using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; using NzbDrone.Test.Common.AutoMoq; diff --git a/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDropDirectoryFixture.cs b/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDropDirectoryFixture.cs index c78ef0863..4b74214e1 100644 --- a/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDropDirectoryFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDropDirectoryFixture.cs @@ -12,7 +12,7 @@ using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Tv; using NzbDrone.Core.Model; using NzbDrone.Core.Providers; -using NzbDrone.Core.Repository; + using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; using NzbDrone.Test.Common.AutoMoq; diff --git a/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessVideoFileFixture.cs b/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessVideoFileFixture.cs index 0119a8454..5145753e9 100644 --- a/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessVideoFileFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessVideoFileFixture.cs @@ -12,7 +12,7 @@ using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Tv; using NzbDrone.Core.Model; using NzbDrone.Core.Providers; -using NzbDrone.Core.Repository; + using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; using NzbDrone.Test.Common.AutoMoq; diff --git a/NzbDrone.Core.Test/ProviderTests/ProwlProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/ProwlProviderTest.cs index ee2981739..e5f21d137 100644 --- a/NzbDrone.Core.Test/ProviderTests/ProwlProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/ProwlProviderTest.cs @@ -6,7 +6,7 @@ using Moq; using NUnit.Framework; using NzbDrone.Core.Model; using NzbDrone.Core.Providers; -using NzbDrone.Core.Repository; + using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common; using NzbDrone.Test.Common.AutoMoq; diff --git a/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/CleanupFixture.cs b/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/CleanupFixture.cs index e48f6b215..268ee332e 100644 --- a/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/CleanupFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/CleanupFixture.cs @@ -13,7 +13,7 @@ using NzbDrone.Common; using NzbDrone.Core.Configuration; using NzbDrone.Core.Model; using NzbDrone.Core.Providers; -using NzbDrone.Core.Repository; + using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common.AutoMoq; diff --git a/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/DeleteDirectoryFixture.cs b/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/DeleteDirectoryFixture.cs index d7ec5de82..b314119de 100644 --- a/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/DeleteDirectoryFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/DeleteDirectoryFixture.cs @@ -13,7 +13,7 @@ using NzbDrone.Common; using NzbDrone.Core.Configuration; using NzbDrone.Core.Model; using NzbDrone.Core.Providers; -using NzbDrone.Core.Repository; + using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common.AutoMoq; diff --git a/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/DeleteFileFixture.cs b/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/DeleteFileFixture.cs index 0be28f3fb..47dfae565 100644 --- a/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/DeleteFileFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/DeleteFileFixture.cs @@ -13,7 +13,7 @@ using NzbDrone.Common; using NzbDrone.Core.Configuration; using NzbDrone.Core.Model; using NzbDrone.Core.Providers; -using NzbDrone.Core.Repository; + using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common.AutoMoq; diff --git a/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/EmptyFixture.cs b/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/EmptyFixture.cs index 624517b4c..3509788bd 100644 --- a/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/EmptyFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/EmptyFixture.cs @@ -13,7 +13,7 @@ using NzbDrone.Common; using NzbDrone.Core.Configuration; using NzbDrone.Core.Model; using NzbDrone.Core.Providers; -using NzbDrone.Core.Repository; + using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common.AutoMoq; diff --git a/NzbDrone.Core.Test/ProviderTests/SearchTests/DailyEpisodeSearchTests/CheckReportFixture.cs b/NzbDrone.Core.Test/ProviderTests/SearchTests/DailyEpisodeSearchTests/CheckReportFixture.cs index dc6110bc2..98a2e9fec 100644 --- a/NzbDrone.Core.Test/ProviderTests/SearchTests/DailyEpisodeSearchTests/CheckReportFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/SearchTests/DailyEpisodeSearchTests/CheckReportFixture.cs @@ -1,18 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Linq; +using System.Collections.Generic; using FizzWare.NBuilder; using FluentAssertions; -using Moq; using NUnit.Framework; -using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Tv; using NzbDrone.Core.Model; -using NzbDrone.Core.Model.Notification; -using NzbDrone.Core.Providers; using NzbDrone.Core.Providers.Search; -using NzbDrone.Core.Repository; -using NzbDrone.Core.Repository.Search; + using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.ProviderTests.SearchTests.DailyEpisodeSearchTests @@ -23,8 +16,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests.DailyEpisodeSearchTests private Series _series; private Episode _episode; private EpisodeParseResult _episodeParseResult; - private SearchHistoryItem _searchHistoryItem; - + [SetUp] public void Setup() { @@ -44,8 +36,6 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests.DailyEpisodeSearchTests .With(p => p.Episodes = new List { _episode }) .With(p => p.Series = _series) .Build(); - - _searchHistoryItem = new SearchHistoryItem(); } [Test] @@ -54,10 +44,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests.DailyEpisodeSearchTests _episodeParseResult.AirDate = null; Mocker.Resolve() - .CheckReport(_series, new {Episode = _episode}, _episodeParseResult, _searchHistoryItem) - .SearchError - .Should() - .Be(ReportRejectionReasons.WrongEpisode); + .IsEpisodeMatch(_series, new { Episode = _episode }, _episodeParseResult).Should().BeFalse(); } [Test] @@ -66,20 +53,17 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests.DailyEpisodeSearchTests _episodeParseResult.AirDate = _episode.AirDate.Value.AddDays(-10); Mocker.Resolve() - .CheckReport(_series, new { Episode = _episode }, _episodeParseResult, _searchHistoryItem) - .SearchError + .IsEpisodeMatch(_series, new { Episode = _episode }, _episodeParseResult) .Should() - .Be(ReportRejectionReasons.WrongEpisode); + .BeFalse(); } [Test] public void should_not_return_error_when_airDates_match() { Mocker.Resolve() - .CheckReport(_series, new { Episode = _episode }, _episodeParseResult, _searchHistoryItem) - .SearchError - .Should() - .Be(ReportRejectionReasons.None); + .IsEpisodeMatch(_series, new { Episode = _episode }, _episodeParseResult) + .Should().BeFalse(); } } } diff --git a/NzbDrone.Core.Test/ProviderTests/SearchTests/DailyEpisodeSearchTests/PerformSearchFixture.cs b/NzbDrone.Core.Test/ProviderTests/SearchTests/DailyEpisodeSearchTests/PerformSearchFixture.cs index 049f170f2..a363047e9 100644 --- a/NzbDrone.Core.Test/ProviderTests/SearchTests/DailyEpisodeSearchTests/PerformSearchFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/SearchTests/DailyEpisodeSearchTests/PerformSearchFixture.cs @@ -10,7 +10,7 @@ using NzbDrone.Core.Model; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; using NzbDrone.Core.Providers.Search; -using NzbDrone.Core.Repository; + using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.ProviderTests.SearchTests.DailyEpisodeSearchTests diff --git a/NzbDrone.Core.Test/ProviderTests/SearchTests/EpisodeSearchTests/CheckReportFixture.cs b/NzbDrone.Core.Test/ProviderTests/SearchTests/EpisodeSearchTests/CheckReportFixture.cs index 0b7ab0e42..37cad8601 100644 --- a/NzbDrone.Core.Test/ProviderTests/SearchTests/EpisodeSearchTests/CheckReportFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/SearchTests/EpisodeSearchTests/CheckReportFixture.cs @@ -1,18 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Linq; +using System.Collections.Generic; using FizzWare.NBuilder; using FluentAssertions; -using Moq; using NUnit.Framework; -using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Tv; using NzbDrone.Core.Model; -using NzbDrone.Core.Model.Notification; -using NzbDrone.Core.Providers; using NzbDrone.Core.Providers.Search; -using NzbDrone.Core.Repository; -using NzbDrone.Core.Repository.Search; using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.ProviderTests.SearchTests.EpisodeSearchTests @@ -23,7 +15,6 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests.EpisodeSearchTests private Series _series; private Episode _episode; private EpisodeParseResult _episodeParseResult; - private SearchHistoryItem _searchHistoryItem; [SetUp] public void Setup() @@ -46,7 +37,6 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests.EpisodeSearchTests .With(p => p.Series = _series) .Build(); - _searchHistoryItem = new SearchHistoryItem(); } [Test] @@ -55,10 +45,9 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests.EpisodeSearchTests _episode.SeasonNumber = 10; Mocker.Resolve() - .CheckReport(_series, new {Episode = _episode}, _episodeParseResult, _searchHistoryItem) - .SearchError + .IsEpisodeMatch(_series, new {Episode = _episode}, _episodeParseResult) .Should() - .Be(ReportRejectionReasons.WrongSeason); + .BeFalse(); } [Test] @@ -67,20 +56,18 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests.EpisodeSearchTests _episode.EpisodeNumber = 10; Mocker.Resolve() - .CheckReport(_series, new { Episode = _episode }, _episodeParseResult, _searchHistoryItem) - .SearchError + .IsEpisodeMatch(_series, new { Episode = _episode }, _episodeParseResult) .Should() - .Be(ReportRejectionReasons.WrongEpisode); + .BeFalse(); } [Test] public void should_not_return_error_when_season_and_episode_match() { Mocker.Resolve() - .CheckReport(_series, new { Episode = _episode }, _episodeParseResult, _searchHistoryItem) - .SearchError + .IsEpisodeMatch(_series, new { Episode = _episode }, _episodeParseResult) .Should() - .Be(ReportRejectionReasons.None); + .BeFalse(); } [Test] @@ -92,10 +79,9 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests.EpisodeSearchTests _episode.EpisodeNumber = 10; Mocker.Resolve() - .CheckReport(_series, new { Episode = _episode }, _episodeParseResult, _searchHistoryItem) - .SearchError - .Should() - .Be(ReportRejectionReasons.WrongSeason); + .IsEpisodeMatch(_series, new { Episode = _episode }, _episodeParseResult) + .Should() + .BeFalse(); } [Test] @@ -107,10 +93,9 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests.EpisodeSearchTests _episode.EpisodeNumber = 10; Mocker.Resolve() - .CheckReport(_series, new { Episode = _episode }, _episodeParseResult, _searchHistoryItem) - .SearchError - .Should() - .Be(ReportRejectionReasons.WrongEpisode); + .IsEpisodeMatch(_series, new { Episode = _episode }, _episodeParseResult) + .Should() + .BeFalse(); } [Test] @@ -123,10 +108,9 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests.EpisodeSearchTests _episode.EpisodeNumber = 10; Mocker.Resolve() - .CheckReport(_series, new { Episode = _episode }, _episodeParseResult, _searchHistoryItem) - .SearchError + .IsEpisodeMatch(_series, new { Episode = _episode }, _episodeParseResult) .Should() - .Be(ReportRejectionReasons.None); + .BeTrue(); } } } diff --git a/NzbDrone.Core.Test/ProviderTests/SearchTests/EpisodeSearchTests/PerformSearchFixture.cs b/NzbDrone.Core.Test/ProviderTests/SearchTests/EpisodeSearchTests/PerformSearchFixture.cs index 7a78cf37c..3414ce238 100644 --- a/NzbDrone.Core.Test/ProviderTests/SearchTests/EpisodeSearchTests/PerformSearchFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/SearchTests/EpisodeSearchTests/PerformSearchFixture.cs @@ -10,7 +10,7 @@ using NzbDrone.Core.Model; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; using NzbDrone.Core.Providers.Search; -using NzbDrone.Core.Repository; + using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.ProviderTests.SearchTests.EpisodeSearchTests diff --git a/NzbDrone.Core.Test/ProviderTests/SearchTests/GetSearchTitleFixture.cs b/NzbDrone.Core.Test/ProviderTests/SearchTests/GetSearchTitleFixture.cs index 1cdde80d1..d47459c84 100644 --- a/NzbDrone.Core.Test/ProviderTests/SearchTests/GetSearchTitleFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/SearchTests/GetSearchTitleFixture.cs @@ -9,7 +9,7 @@ using NzbDrone.Core.ReferenceData; using NzbDrone.Core.Tv; using NzbDrone.Core.Providers; using NzbDrone.Core.Providers.Search; -using NzbDrone.Core.Repository; + using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.ProviderTests.SearchTests diff --git a/NzbDrone.Core.Test/ProviderTests/SearchTests/PartialSeasonSearchTests/CheckReportFixture.cs b/NzbDrone.Core.Test/ProviderTests/SearchTests/PartialSeasonSearchTests/CheckReportFixture.cs index 0ecf6b0d8..9b6fb5217 100644 --- a/NzbDrone.Core.Test/ProviderTests/SearchTests/PartialSeasonSearchTests/CheckReportFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/SearchTests/PartialSeasonSearchTests/CheckReportFixture.cs @@ -1,18 +1,12 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using FizzWare.NBuilder; using FluentAssertions; -using Moq; using NUnit.Framework; -using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Tv; using NzbDrone.Core.Model; -using NzbDrone.Core.Model.Notification; -using NzbDrone.Core.Providers; using NzbDrone.Core.Providers.Search; -using NzbDrone.Core.Repository; -using NzbDrone.Core.Repository.Search; + using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.ProviderTests.SearchTests.PartialSeasonSearchTests @@ -23,8 +17,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests.PartialSeasonSearchTests private Series _series; private List _episodes; private EpisodeParseResult _episodeParseResult; - private SearchHistoryItem _searchHistoryItem; - + [SetUp] public void Setup() { @@ -45,23 +38,22 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests.PartialSeasonSearchTests .With(p => p.SeasonNumber = 1) .Build(); - _searchHistoryItem = new SearchHistoryItem(); } [Test] public void should_return_wrongSeason_when_season_does_not_match() { Mocker.Resolve() - .CheckReport(_series, new { SeasonNumber = 2, Episodes = _episodes }, _episodeParseResult, _searchHistoryItem) - .SearchError.Should().Be(ReportRejectionReasons.WrongSeason); + .IsEpisodeMatch(_series, new { SeasonNumber = 2, Episodes = _episodes }, _episodeParseResult) + .Should().BeFalse(); } [Test] public void should_not_return_error_when_season_matches() { Mocker.Resolve() - .CheckReport(_series, new { SeasonNumber = 1, Episodes = _episodes }, _episodeParseResult, _searchHistoryItem) - .SearchError.Should().Be(ReportRejectionReasons.None); + .IsEpisodeMatch(_series, new { SeasonNumber = 1, Episodes = _episodes }, _episodeParseResult) + .Should().BeFalse(); } } } diff --git a/NzbDrone.Core.Test/ProviderTests/SearchTests/PartialSeasonSearchTests/PerformSearchFixture.cs b/NzbDrone.Core.Test/ProviderTests/SearchTests/PartialSeasonSearchTests/PerformSearchFixture.cs index 99f9987fb..41f4d45c0 100644 --- a/NzbDrone.Core.Test/ProviderTests/SearchTests/PartialSeasonSearchTests/PerformSearchFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/SearchTests/PartialSeasonSearchTests/PerformSearchFixture.cs @@ -10,7 +10,7 @@ using NzbDrone.Core.Model; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; using NzbDrone.Core.Providers.Search; -using NzbDrone.Core.Repository; + using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.ProviderTests.SearchTests.PartialSeasonSearchTests diff --git a/NzbDrone.Core.Test/ProviderTests/SearchTests/PerformSearchTestBase.cs b/NzbDrone.Core.Test/ProviderTests/SearchTests/PerformSearchTestBase.cs index 1fe52a262..cdca2fb20 100644 --- a/NzbDrone.Core.Test/ProviderTests/SearchTests/PerformSearchTestBase.cs +++ b/NzbDrone.Core.Test/ProviderTests/SearchTests/PerformSearchTestBase.cs @@ -10,7 +10,7 @@ using NzbDrone.Core.Tv; using NzbDrone.Core.Model; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; -using NzbDrone.Core.Repository; + using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.ProviderTests.SearchTests diff --git a/NzbDrone.Core.Test/ProviderTests/SearchTests/ProcessResultsFixture.cs b/NzbDrone.Core.Test/ProviderTests/SearchTests/ProcessResultsFixture.cs index 4507e6dc2..613ca9087 100644 --- a/NzbDrone.Core.Test/ProviderTests/SearchTests/ProcessResultsFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/SearchTests/ProcessResultsFixture.cs @@ -1,38 +1,33 @@ -using System; +/* using System.Collections.Generic; using System.Linq; -using System.Text; using FizzWare.NBuilder; -using FluentAssertions; using Moq; using NUnit.Framework; -using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.Download; using NzbDrone.Core.Qualities; +using NzbDrone.Core.Test.Framework; using NzbDrone.Core.Tv; using NzbDrone.Core.Model; using NzbDrone.Core.Model.Notification; -using NzbDrone.Core.Providers; using NzbDrone.Core.DecisionEngine; -using NzbDrone.Core.Providers.Search; -using NzbDrone.Core.Repository; using NzbDrone.Core.Repository.Search; using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.ProviderTests.SearchTests { [TestFixture] - public class ProcessResultsFixture : TestBase + public class ProcessResultsFixture : CoreTest { private Series _matchingSeries; private Series _mismatchedSeries; private Series _nullSeries = null; - private SearchHistory _searchHistory; + private EpisodeSearchResult _episodeSearchResult; private ProgressNotification _notification; private List _episodes; - + [SetUp] public void Setup() { @@ -46,7 +41,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests .With(s => s.Title = "Not 30 Rock") .Build(); - _searchHistory = new SearchHistory(); + _episodeSearchResult = new EpisodeSearchResult(); _notification = new ProgressNotification("Test"); _episodes = Builder @@ -90,132 +85,26 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests .Returns(false); } - private void WithQualityNeeded() + private void WithApprovedDecisions() { - Mocker.GetMock() - .Setup(s => s.IsSatisfiedBy(It.IsAny())) - .Returns(ReportRejectionReasons.None); + Mocker.GetMock() + .Setup(s => s.GetDownloadDecision(It.IsAny())) + .Returns(new DownloadDecision(new string[0])); } - private void WithQualityNotNeeded() + private void WithDeclinedDecisions() { - Mocker.GetMock() - .Setup(s => s.IsSatisfiedBy(It.IsAny())) - .Returns(ReportRejectionReasons.ExistingQualityIsEqualOrBetter); + Mocker.GetMock() + .Setup(s => s.GetDownloadDecision(It.IsAny())) + .Returns(new DownloadDecision(new[] { "Rejection reason" })); } - [Test] - public void should_process_higher_quality_results_first() - { - WithMatchingSeries(); - WithSuccessfulDownload(); - - var parseResults = Builder.CreateListOfSize(5) - .All() - .With(e => e.SeasonNumber = 1) - .With(e => e.EpisodeNumbers = new List { 1 }) - .With(c => c.Quality = new QualityModel(Quality.DVD, true)) - .With(c => c.Age = 10) - .Random(1) - .With(c => c.Quality = new QualityModel(Quality.Bluray1080p, true)) - .With(c => c.Age = 100) - .Build() - .ToList(); - - - Mocker.GetMock() - .Setup(s => s.IsSatisfiedBy(It.Is(d => d.Quality.Quality == Quality.Bluray1080p))) - .Returns(ReportRejectionReasons.None); - - var result = Mocker.Resolve().ProcessReports(_matchingSeries, new { }, parseResults, _searchHistory, _notification); - - result.SearchHistoryItems.Should().HaveCount(parseResults.Count); - result.SearchHistoryItems.Should().Contain(s => s.Success); - - Mocker.GetMock().Verify(c => c.IsSatisfiedBy(It.IsAny()), - Times.Once()); - Mocker.GetMock().Verify(c => c.DownloadReport(It.IsAny()), - Times.Once()); + Times.Once()); } - [Test] - public void should_process_newer_reports_first() - { - WithMatchingSeries(); - WithSuccessfulDownload(); + - var parseResults = Builder.CreateListOfSize(5) - .All() - .With(e => e.SeasonNumber = 1) - .With(e => e.EpisodeNumbers = new List { 1 }) - .With(c => c.Quality = new QualityModel(Quality.Bluray1080p, true)) - .With(c => c.Age = 300) - .Build() - .ToList(); - - parseResults[2].Age = 100; - - Mocker.GetMock() - .Setup(s => s.IsSatisfiedBy(It.IsAny())).Returns(ReportRejectionReasons.None); - - var result = Mocker.Resolve().ProcessReports(_matchingSeries, new { }, parseResults, _searchHistory, _notification); - - result.SearchHistoryItems.Should().HaveCount(parseResults.Count); - result.SearchHistoryItems.Should().Contain(s => s.Success); - - - Mocker.GetMock().Verify(c => c.DownloadReport(It.Is(d => d.Age != 100)), Times.Never()); - Mocker.GetMock().Verify(c => c.DownloadReport(It.Is(d => d.Age == 100)), Times.Once()); - } - - [Test] - public void should_check_other_reports_when_quality_is_not_wanted() - { - WithMatchingSeries(); - WithQualityNotNeeded(); - - var parseResults = Builder.CreateListOfSize(5) - .All() - .With(e => e.SeasonNumber = 1) - .With(e => e.EpisodeNumbers = new List { 1 }) - .With(c => c.Quality = new QualityModel(Quality.DVD, true)) - .Build() - .ToList(); - - var result = Mocker.Resolve().ProcessReports(_matchingSeries, new { }, parseResults, _searchHistory, _notification); - - result.SearchHistoryItems.Should().HaveCount(parseResults.Count); - result.SearchHistoryItems.Should().NotContain(s => s.Success); - - Mocker.GetMock().Verify(c => c.IsSatisfiedBy(It.IsAny()), - Times.Exactly(5)); - Mocker.GetMock().Verify(c => c.DownloadReport(It.IsAny()), - Times.Never()); - } - - [Test] - public void should_should_skip_if_series_is_not_watched() - { - var parseResults = Builder.CreateListOfSize(5) - .All() - .With(e => e.SeasonNumber = 1) - .With(e => e.EpisodeNumbers = new List { 1 }) - .With(e => e.Quality = new QualityModel(Quality.HDTV720p, false)) - .Build() - .ToList(); - - WithNullSeries(); - - //Act - var result = Mocker.Resolve().ProcessReports(_matchingSeries, new { }, parseResults, _searchHistory, _notification); - - //Assert - result.SearchHistoryItems.Should().HaveCount(parseResults.Count); - result.SearchHistoryItems.Should().NotContain(s => s.Success); - - Mocker.GetMock().Verify(c => c.DownloadReport(It.IsAny()), - Times.Never()); - } + [Test] public void should_skip_if_series_does_not_match_searched_series() @@ -231,7 +120,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests WithMisMatchedSeries(); //Act - var result = Mocker.Resolve().ProcessReports(_matchingSeries, new { }, parseResults, _searchHistory, _notification); + var result = Subject.ProcessReports(_matchingSeries, new { }, parseResults, _episodeSearchResult, _notification); //Assert result.SearchHistoryItems.Should().HaveCount(parseResults.Count); @@ -259,7 +148,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests WithSuccessfulDownload(); //Act - var result = Mocker.Resolve().ProcessReports(_matchingSeries, new { }, parseResults, _searchHistory, _notification); + var result = Subject.ProcessReports(_matchingSeries, new { }, parseResults, _episodeSearchResult, _notification); //Assert result.SearchHistoryItems.Should().HaveCount(parseResults.Count); @@ -294,7 +183,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests .Returns(true); //Act - var result = Mocker.Resolve().ProcessReports(_matchingSeries, new { }, parseResults, _searchHistory, _notification); + var result = Subject.ProcessReports(_matchingSeries, new { }, parseResults, _episodeSearchResult, _notification); //Assert result.SearchHistoryItems.Should().HaveCount(parseResults.Count); @@ -322,21 +211,22 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests WithMatchingSeries(); WithSuccessfulDownload(); - Mocker.GetMock() - .Setup(s => s.IsSatisfiedBy(It.Is(d => d.Quality.Quality == Quality.Bluray1080p))) + Mocker.GetMock() + .Setup(s => s.IsDownloadPermitted(It.Is(d => d.Quality.Quality == Quality.Bluray1080p))) .Returns(ReportRejectionReasons.None); //Act - var result = Mocker.Resolve().ProcessReports(_matchingSeries, new { }, parseResults, _searchHistory, _notification); + var result = Subject.ProcessReports(_matchingSeries, new { }, parseResults, _episodeSearchResult, _notification); //Assert result.Successes.Should().NotBeNull(); result.Successes.Should().NotBeEmpty(); - Mocker.GetMock().Verify(c => c.IsSatisfiedBy(It.IsAny()), + Mocker.GetMock().Verify(c => c.IsDownloadPermitted(It.IsAny()), Times.Once()); Mocker.GetMock().Verify(c => c.DownloadReport(It.IsAny()), Times.Once()); } } } +*/ diff --git a/NzbDrone.Core.Test/ProviderTests/SearchTests/TestSearch.cs b/NzbDrone.Core.Test/ProviderTests/SearchTests/TestSearch.cs index f99d922a2..7319df2fb 100644 --- a/NzbDrone.Core.Test/ProviderTests/SearchTests/TestSearch.cs +++ b/NzbDrone.Core.Test/ProviderTests/SearchTests/TestSearch.cs @@ -1,19 +1,14 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Threading.Tasks; using NLog; -using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.Download; using NzbDrone.Core.Indexers; using NzbDrone.Core.ReferenceData; using NzbDrone.Core.Tv; using NzbDrone.Core.Model; -using NzbDrone.Core.Providers; using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Providers.Search; -using NzbDrone.Core.Repository.Search; namespace NzbDrone.Core.Test.ProviderTests.SearchTests { @@ -21,11 +16,11 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests { private static readonly Logger logger = LogManager.GetCurrentClassLogger(); - public TestSearch(ISeriesService seriesService, IEpisodeService episodeService, DownloadProvider downloadProvider, + public TestSearch(ISeriesService seriesService, IEpisodeService episodeService, DownloadProvider downloadProvider, IIndexerService indexerService, SceneMappingService sceneMappingService, - AllowedDownloadSpecification allowedDownloadSpecification, ISeriesRepository seriesRepository) - : base(seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingService, - allowedDownloadSpecification) + DownloadDirector downloadDirector, ISeriesRepository seriesRepository) + : base(seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingService, + downloadDirector) { } @@ -59,14 +54,10 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests return reports; } - public override SearchHistoryItem CheckReport(Series series, dynamic options, EpisodeParseResult episodeParseResult, Repository.Search.SearchHistoryItem item) + public override bool IsEpisodeMatch(Series series, dynamic options, EpisodeParseResult episodeParseResult) { - return item; + return true; } - protected override void FinalizeSearch(Series series, dynamic options, bool reportsFound, Model.Notification.ProgressNotification notification) - { - logger.Warn("Unable to find {0} in any of indexers.", series.Title); - } } } diff --git a/NzbDrone.Core.Test/ProviderTests/TvRageMappingProviderTests/FindMatchingTvRageSeriesFixture.cs b/NzbDrone.Core.Test/ProviderTests/TvRageMappingProviderTests/FindMatchingTvRageSeriesFixture.cs index 4e2ad360a..8d93dcdc6 100644 --- a/NzbDrone.Core.Test/ProviderTests/TvRageMappingProviderTests/FindMatchingTvRageSeriesFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/TvRageMappingProviderTests/FindMatchingTvRageSeriesFixture.cs @@ -10,7 +10,7 @@ using NzbDrone.Core.ReferenceData; using NzbDrone.Core.Tv; using NzbDrone.Core.Model.TvRage; using NzbDrone.Core.Providers; -using NzbDrone.Core.Repository; + using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.ProviderTests.TvRageMappingProviderTests diff --git a/NzbDrone.Core.Test/ProviderTests/TvRageMappingProviderTests/ProcessResultsFixture.cs b/NzbDrone.Core.Test/ProviderTests/TvRageMappingProviderTests/ProcessResultsFixture.cs index bc3c9e4b9..b3e5c9fdd 100644 --- a/NzbDrone.Core.Test/ProviderTests/TvRageMappingProviderTests/ProcessResultsFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/TvRageMappingProviderTests/ProcessResultsFixture.cs @@ -9,7 +9,7 @@ using NzbDrone.Core.MetadataSource; using NzbDrone.Core.Tv; using NzbDrone.Core.Model.TvRage; using NzbDrone.Core.Providers; -using NzbDrone.Core.Repository; + using NzbDrone.Test.Common; namespace NzbDrone.Core.Test.ProviderTests.TvRageMappingProviderTests diff --git a/NzbDrone.Core.Test/ProviderTests/XbmcProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/XbmcProviderTest.cs index 22f45a1ee..46746bc54 100644 --- a/NzbDrone.Core.Test/ProviderTests/XbmcProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/XbmcProviderTest.cs @@ -12,7 +12,7 @@ using NzbDrone.Core.Tv; using NzbDrone.Core.Model.Xbmc; using NzbDrone.Core.Providers; using NzbDrone.Core.Providers.Xbmc; -using NzbDrone.Core.Repository; + using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common.AutoMoq; diff --git a/NzbDrone.Core.Test/ProviderTests/XemCommunicationProviderTests/GetSceneTvdbMappingsFixture.cs b/NzbDrone.Core.Test/ProviderTests/XemCommunicationProviderTests/GetSceneTvdbMappingsFixture.cs index 5d544f2ff..1f4848677 100644 --- a/NzbDrone.Core.Test/ProviderTests/XemCommunicationProviderTests/GetSceneTvdbMappingsFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/XemCommunicationProviderTests/GetSceneTvdbMappingsFixture.cs @@ -9,7 +9,7 @@ using NUnit.Framework; using NzbDrone.Common; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; -using NzbDrone.Core.Repository; + using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common.AutoMoq; using NzbDrone.Test.Common; diff --git a/NzbDrone.Core.Test/ProviderTests/XemCommunicationProviderTests/GetXemSeriesIdsFixture.cs b/NzbDrone.Core.Test/ProviderTests/XemCommunicationProviderTests/GetXemSeriesIdsFixture.cs index 141a044de..aeb5ef4f5 100644 --- a/NzbDrone.Core.Test/ProviderTests/XemCommunicationProviderTests/GetXemSeriesIdsFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/XemCommunicationProviderTests/GetXemSeriesIdsFixture.cs @@ -9,7 +9,7 @@ using NUnit.Framework; using NzbDrone.Common; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; -using NzbDrone.Core.Repository; + using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common.AutoMoq; using NzbDrone.Test.Common; diff --git a/NzbDrone.Core/DecisionEngine/AllowedDownloadSpecification.cs b/NzbDrone.Core/DecisionEngine/AllowedDownloadSpecification.cs deleted file mode 100644 index 5c6d76620..000000000 --- a/NzbDrone.Core/DecisionEngine/AllowedDownloadSpecification.cs +++ /dev/null @@ -1,54 +0,0 @@ -using NLog; -using NzbDrone.Core.DecisionEngine.Specifications; -using NzbDrone.Core.Model; - -namespace NzbDrone.Core.DecisionEngine -{ - public class AllowedDownloadSpecification - { - private readonly QualityAllowedByProfileSpecification _qualityAllowedByProfileSpecification; - private readonly UpgradeDiskSpecification _upgradeDiskSpecification; - private readonly AcceptableSizeSpecification _acceptableSizeSpecification; - private readonly NotInQueueSpecification _notInQueueSpecification; - private readonly RetentionSpecification _retentionSpecification; - private readonly AllowedReleaseGroupSpecification _allowedReleaseGroupSpecification; - private readonly CustomStartDateSpecification _customStartDateSpecification; - private readonly LanguageSpecification _languageSpecification; - private static readonly Logger logger = LogManager.GetCurrentClassLogger(); - - public AllowedDownloadSpecification(QualityAllowedByProfileSpecification qualityAllowedByProfileSpecification, - UpgradeDiskSpecification upgradeDiskSpecification, AcceptableSizeSpecification acceptableSizeSpecification, - NotInQueueSpecification notInQueueSpecification, RetentionSpecification retentionSpecification, - AllowedReleaseGroupSpecification allowedReleaseGroupSpecification, CustomStartDateSpecification customStartDateSpecification, - LanguageSpecification languageSpecification) - { - _qualityAllowedByProfileSpecification = qualityAllowedByProfileSpecification; - _upgradeDiskSpecification = upgradeDiskSpecification; - _acceptableSizeSpecification = acceptableSizeSpecification; - _notInQueueSpecification = notInQueueSpecification; - _retentionSpecification = retentionSpecification; - _allowedReleaseGroupSpecification = allowedReleaseGroupSpecification; - _customStartDateSpecification = customStartDateSpecification; - _languageSpecification = languageSpecification; - } - - public AllowedDownloadSpecification() - { - } - - public virtual ReportRejectionReasons IsSatisfiedBy(EpisodeParseResult subject) - { - if (!_qualityAllowedByProfileSpecification.IsSatisfiedBy(subject)) return ReportRejectionReasons.QualityNotWanted; - if (!_customStartDateSpecification.IsSatisfiedBy(subject)) return ReportRejectionReasons.AiredAfterCustomStartDate; - if (!_upgradeDiskSpecification.IsSatisfiedBy(subject)) return ReportRejectionReasons.ExistingQualityIsEqualOrBetter; - if (!_languageSpecification.IsSatisfiedBy(subject)) return ReportRejectionReasons.LanguageNotWanted; - if (!_retentionSpecification.IsSatisfiedBy(subject)) return ReportRejectionReasons.Retention; - if (!_acceptableSizeSpecification.IsSatisfiedBy(subject)) return ReportRejectionReasons.Size; - if (!_allowedReleaseGroupSpecification.IsSatisfiedBy(subject)) return ReportRejectionReasons.ReleaseGroupNotWanted; - if (!_notInQueueSpecification.IsSatisfiedBy(subject)) return ReportRejectionReasons.AlreadyInQueue; - - logger.Debug("Episode {0} is needed", subject); - return ReportRejectionReasons.None; - } - } -} \ No newline at end of file diff --git a/NzbDrone.Core/DecisionEngine/DownloadDecision.cs b/NzbDrone.Core/DecisionEngine/DownloadDecision.cs new file mode 100644 index 000000000..cd2295207 --- /dev/null +++ b/NzbDrone.Core/DecisionEngine/DownloadDecision.cs @@ -0,0 +1,22 @@ +using System.Collections.Generic; +using System.Linq; + +namespace NzbDrone.Core.DecisionEngine +{ + public class DownloadDecision + { + public IEnumerable Rejections { get; private set; } + public bool Approved + { + get + { + return !Rejections.Any(); + } + } + + public DownloadDecision(params string[] rejections) + { + Rejections = rejections.ToList(); + } + } +} \ No newline at end of file diff --git a/NzbDrone.Core/DecisionEngine/DownloadDirector.cs b/NzbDrone.Core/DecisionEngine/DownloadDirector.cs new file mode 100644 index 000000000..cb94a00fa --- /dev/null +++ b/NzbDrone.Core/DecisionEngine/DownloadDirector.cs @@ -0,0 +1,32 @@ +using System.Collections.Generic; +using System.Linq; +using NzbDrone.Core.Model; + +namespace NzbDrone.Core.DecisionEngine +{ + public interface IDownloadDirector + { + DownloadDecision GetDownloadDecision(EpisodeParseResult episodeParseResult); + } + + public class DownloadDirector : IDownloadDirector + { + private readonly IEnumerable _specifications; + + public DownloadDirector(IEnumerable specifications) + { + _specifications = specifications; + } + + public DownloadDecision GetDownloadDecision(EpisodeParseResult episodeParseResult) + { + var rejections = _specifications + .Where(spec => !spec.IsSatisfiedBy(episodeParseResult)) + .Select(spec => spec.RejectionReason).ToArray(); + + episodeParseResult.Decision = new DownloadDecision(rejections); + + return episodeParseResult.Decision; + } + } +} \ No newline at end of file diff --git a/NzbDrone.Core/DecisionEngine/ReportRejectionReasons.cs b/NzbDrone.Core/DecisionEngine/ReportRejectionReasons.cs deleted file mode 100644 index 469028342..000000000 --- a/NzbDrone.Core/DecisionEngine/ReportRejectionReasons.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace NzbDrone.Core.DecisionEngine -{ - public enum ReportRejectionReasons - { - None = 0, - WrongSeries = 1, - QualityNotWanted = 2, - WrongSeason = 3, - WrongEpisode = 4, - Size = 5, - Retention = 6, - ExistingQualityIsEqualOrBetter = 7, - Cutoff = 8, - AlreadyInQueue = 9, - DownloadClientFailure = 10, - Skipped = 11, - Failure = 12, - ReleaseGroupNotWanted = 13, - AiredAfterCustomStartDate = 14, - LanguageNotWanted = 15 - } -} diff --git a/NzbDrone.Core/Jobs/Implementations/RssSyncJob.cs b/NzbDrone.Core/Jobs/Implementations/RssSyncJob.cs index 2619ad801..6e8db02da 100644 --- a/NzbDrone.Core/Jobs/Implementations/RssSyncJob.cs +++ b/NzbDrone.Core/Jobs/Implementations/RssSyncJob.cs @@ -1,11 +1,9 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Threading.Tasks; using NLog; using NzbDrone.Core.Configuration; using NzbDrone.Core.DecisionEngine; -using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.Download; using NzbDrone.Core.Indexers; using NzbDrone.Core.Model; @@ -17,23 +15,17 @@ namespace NzbDrone.Core.Jobs.Implementations { private readonly DownloadProvider _downloadProvider; private readonly IIndexerService _indexerService; - private readonly MonitoredEpisodeSpecification _isMonitoredEpisodeSpecification; - private readonly AllowedDownloadSpecification _allowedDownloadSpecification; - private readonly UpgradeHistorySpecification _upgradeHistorySpecification; + private readonly IDownloadDirector DownloadDirector; private readonly IConfigService _configService; private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - public RssSyncJob(DownloadProvider downloadProvider, IIndexerService indexerService, - MonitoredEpisodeSpecification isMonitoredEpisodeSpecification, AllowedDownloadSpecification allowedDownloadSpecification, - UpgradeHistorySpecification upgradeHistorySpecification, IConfigService configService) + public RssSyncJob(DownloadProvider downloadProvider, IIndexerService indexerService, IDownloadDirector downloadDirector, IConfigService configService) { _downloadProvider = downloadProvider; _indexerService = indexerService; - _isMonitoredEpisodeSpecification = isMonitoredEpisodeSpecification; - _allowedDownloadSpecification = allowedDownloadSpecification; - _upgradeHistorySpecification = upgradeHistorySpecification; + DownloadDirector = downloadDirector; _configService = configService; } @@ -77,9 +69,7 @@ namespace NzbDrone.Core.Jobs.Implementations { try { - if (_isMonitoredEpisodeSpecification.IsSatisfiedBy(episodeParseResult) && - _allowedDownloadSpecification.IsSatisfiedBy(episodeParseResult) == ReportRejectionReasons.None && - _upgradeHistorySpecification.IsSatisfiedBy(episodeParseResult)) + if (DownloadDirector.GetDownloadDecision(episodeParseResult).Approved) { _downloadProvider.DownloadReport(episodeParseResult); } diff --git a/NzbDrone.Core/Model/EpisodeParseResult.cs b/NzbDrone.Core/Model/EpisodeParseResult.cs index 827be127c..57cab5d40 100644 --- a/NzbDrone.Core/Model/EpisodeParseResult.cs +++ b/NzbDrone.Core/Model/EpisodeParseResult.cs @@ -1,11 +1,9 @@ using System; using System.Linq; using System.Collections.Generic; -using NzbDrone.Core.MediaFiles; +using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.Organizer; -using NzbDrone.Core.Providers; using NzbDrone.Core.Tv; -using NzbDrone.Core.Repository; namespace NzbDrone.Core.Model { @@ -21,6 +19,8 @@ namespace NzbDrone.Core.Model } } + public DownloadDecision Decision { get; set; } + public string EpisodeTitle { get; set; } public int SeasonNumber { get; set; } diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index 6ab5aa832..b15f62fd2 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -188,9 +188,10 @@ + - + @@ -336,9 +337,6 @@ - - - Code diff --git a/NzbDrone.Core/Providers/Converting/AtomicParsleyProvider.cs b/NzbDrone.Core/Providers/Converting/AtomicParsleyProvider.cs index 5da57687d..38d9bad57 100644 --- a/NzbDrone.Core/Providers/Converting/AtomicParsleyProvider.cs +++ b/NzbDrone.Core/Providers/Converting/AtomicParsleyProvider.cs @@ -5,7 +5,7 @@ using NLog; using NzbDrone.Core.Configuration; using NzbDrone.Core.Tv; using NzbDrone.Core.Model; -using NzbDrone.Core.Repository; + namespace NzbDrone.Core.Providers.Converting { diff --git a/NzbDrone.Core/Providers/Converting/HandbrakeProvider.cs b/NzbDrone.Core/Providers/Converting/HandbrakeProvider.cs index 50278e521..d2209c324 100644 --- a/NzbDrone.Core/Providers/Converting/HandbrakeProvider.cs +++ b/NzbDrone.Core/Providers/Converting/HandbrakeProvider.cs @@ -5,7 +5,7 @@ using NLog; using NzbDrone.Core.Configuration; using NzbDrone.Core.Tv; using NzbDrone.Core.Model.Notification; -using NzbDrone.Core.Repository; + namespace NzbDrone.Core.Providers.Converting { diff --git a/NzbDrone.Core/Providers/MisnamedProvider.cs b/NzbDrone.Core/Providers/MisnamedProvider.cs index cba9378c1..2e956ba6c 100644 --- a/NzbDrone.Core/Providers/MisnamedProvider.cs +++ b/NzbDrone.Core/Providers/MisnamedProvider.cs @@ -8,7 +8,7 @@ using NLog; using NzbDrone.Core.Organizer; using NzbDrone.Core.Tv; using NzbDrone.Core.Model; -using NzbDrone.Core.Repository; + namespace NzbDrone.Core.Providers { diff --git a/NzbDrone.Core/Providers/Search/DailyEpisodeSearch.cs b/NzbDrone.Core/Providers/Search/DailyEpisodeSearch.cs index d374247f7..e56e67c5c 100644 --- a/NzbDrone.Core/Providers/Search/DailyEpisodeSearch.cs +++ b/NzbDrone.Core/Providers/Search/DailyEpisodeSearch.cs @@ -1,10 +1,7 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Threading.Tasks; using NLog; -using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.Download; using NzbDrone.Core.Indexers; using NzbDrone.Core.ReferenceData; @@ -12,8 +9,6 @@ using NzbDrone.Core.Tv; using NzbDrone.Core.Model; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.DecisionEngine; -using NzbDrone.Core.Repository; -using NzbDrone.Core.Repository.Search; namespace NzbDrone.Core.Providers.Search { @@ -22,10 +17,10 @@ namespace NzbDrone.Core.Providers.Search private static readonly Logger logger = LogManager.GetCurrentClassLogger(); public DailyEpisodeSearch(IEpisodeService episodeService, DownloadProvider downloadProvider, IIndexerService indexerService, - SceneMappingService sceneMappingService, AllowedDownloadSpecification allowedDownloadSpecification, + SceneMappingService sceneMappingService, DownloadDirector downloadDirector, ISeriesRepository seriesRepository) : base(seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingService, - allowedDownloadSpecification) + downloadDirector) { } @@ -60,28 +55,18 @@ namespace NzbDrone.Core.Providers.Search return reports; } - public override SearchHistoryItem CheckReport(Series series, dynamic options, EpisodeParseResult episodeParseResult, - SearchHistoryItem item) + public override bool IsEpisodeMatch(Series series, dynamic options, EpisodeParseResult episodeParseResult) { Episode episode = options.Episode; if (!episodeParseResult.AirDate.HasValue || episodeParseResult.AirDate.Value != episode.AirDate.Value) { logger.Trace("Episode AirDate does not match searched episode number, skipping."); - item.SearchError = ReportRejectionReasons.WrongEpisode; - - return item; + return false; } - return item; + return true; } - protected override void FinalizeSearch(Series series, dynamic options, Boolean reportsFound, ProgressNotification notification) - { - logger.Warn("Unable to find {0} in any of indexers.", options.Episode); - - notification.CurrentMessage = reportsFound ? String.Format("Sorry, couldn't find {0}, that matches your preferences.", options.Episode.AirDate) - : String.Format("Sorry, couldn't find {0} in any of indexers.", options.Episode); - } } } \ No newline at end of file diff --git a/NzbDrone.Core/Providers/Search/EpisodeSearch.cs b/NzbDrone.Core/Providers/Search/EpisodeSearch.cs index c0eac694f..1faa67b64 100644 --- a/NzbDrone.Core/Providers/Search/EpisodeSearch.cs +++ b/NzbDrone.Core/Providers/Search/EpisodeSearch.cs @@ -1,10 +1,7 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Threading.Tasks; using NLog; -using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.Download; using NzbDrone.Core.Indexers; using NzbDrone.Core.ReferenceData; @@ -12,8 +9,6 @@ using NzbDrone.Core.Tv; using NzbDrone.Core.Model; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.DecisionEngine; -using NzbDrone.Core.Repository; -using NzbDrone.Core.Repository.Search; namespace NzbDrone.Core.Providers.Search { @@ -22,11 +17,11 @@ namespace NzbDrone.Core.Providers.Search private static readonly Logger logger = LogManager.GetCurrentClassLogger(); public EpisodeSearch(IEpisodeService episodeService, DownloadProvider downloadProvider, IIndexerService indexerService, - SceneMappingService sceneMappingService, AllowedDownloadSpecification allowedDownloadSpecification, + SceneMappingService sceneMappingService, DownloadDirector downloadDirector, ISeriesRepository seriesRepository) - : base(seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingService, - allowedDownloadSpecification) - { + : base(seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingService, + downloadDirector) + { } public EpisodeSearch() @@ -51,7 +46,7 @@ namespace NzbDrone.Core.Providers.Search if (series.UseSceneNumbering) { - if(options.Episode.SceneSeasonNumber > 0 && options.Episode.SceneEpisodeNumber > 0) + if (options.Episode.SceneSeasonNumber > 0 && options.Episode.SceneEpisodeNumber > 0) { logger.Trace("Using Scene Numbering for: {0}", options.Episode); seasonNumber = options.Episode.SceneSeasonNumber; @@ -76,55 +71,39 @@ namespace NzbDrone.Core.Providers.Search return reports; } - public override SearchHistoryItem CheckReport(Series series, dynamic options, EpisodeParseResult episodeParseResult, - SearchHistoryItem item) + public override bool IsEpisodeMatch(Series series, dynamic options, EpisodeParseResult episodeParseResult) { - if(series.UseSceneNumbering && options.Episode.SeasonNumber > 0 && options.Episode.EpisodeNumber > 0) + if (series.UseSceneNumbering && options.Episode.SeasonNumber > 0 && options.Episode.EpisodeNumber > 0) { if (options.Episode.SceneSeasonNumber != episodeParseResult.SeasonNumber) { logger.Trace("Season number does not match searched season number, skipping."); - item.SearchError = ReportRejectionReasons.WrongSeason; - - return item; + return false; } if (!episodeParseResult.EpisodeNumbers.Contains(options.Episode.SceneEpisodeNumber)) { logger.Trace("Episode number does not match searched episode number, skipping."); - item.SearchError = ReportRejectionReasons.WrongEpisode; - - return item; + return false; } - return item; + return true; } - if(options.Episode.SeasonNumber != episodeParseResult.SeasonNumber) + if (options.Episode.SeasonNumber != episodeParseResult.SeasonNumber) { logger.Trace("Season number does not match searched season number, skipping."); - item.SearchError = ReportRejectionReasons.WrongSeason; - - return item; + return false; } if (!episodeParseResult.EpisodeNumbers.Contains(options.Episode.EpisodeNumber)) { logger.Trace("Episode number does not match searched episode number, skipping."); - item.SearchError = ReportRejectionReasons.WrongEpisode; - - return item; + return false; } - return item; + return true; } - protected override void FinalizeSearch(Series series, dynamic options, Boolean reportsFound, ProgressNotification notification) - { - logger.Warn("Unable to find {0} in any of indexers.", options.Episode); - - notification.CurrentMessage = reportsFound ? String.Format("Sorry, couldn't find {0}, that matches your preferences.", options.Episode) - : String.Format("Sorry, couldn't find {0} in any of indexers.", options.Episode); - } } } diff --git a/NzbDrone.Core/Providers/Search/PartialSeasonSearch.cs b/NzbDrone.Core/Providers/Search/PartialSeasonSearch.cs index 8c1718f77..462302312 100644 --- a/NzbDrone.Core/Providers/Search/PartialSeasonSearch.cs +++ b/NzbDrone.Core/Providers/Search/PartialSeasonSearch.cs @@ -12,8 +12,6 @@ using NzbDrone.Core.Tv; using NzbDrone.Core.Model; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.DecisionEngine; -using NzbDrone.Core.Repository; -using NzbDrone.Core.Repository.Search; namespace NzbDrone.Core.Providers.Search { @@ -22,11 +20,11 @@ namespace NzbDrone.Core.Providers.Search private static readonly Logger logger = LogManager.GetCurrentClassLogger(); public PartialSeasonSearch(IEpisodeService episodeService, DownloadProvider downloadProvider, IIndexerService indexerService, - SceneMappingService sceneMappingService, AllowedDownloadSpecification allowedDownloadSpecification, + SceneMappingService sceneMappingService, DownloadDirector downloadDirector, ISeriesRepository seriesRepository) - : base(seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingService, - allowedDownloadSpecification) - { + : base(seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingService, + downloadDirector) + { } public PartialSeasonSearch() @@ -54,7 +52,7 @@ namespace NzbDrone.Core.Providers.Search var title = GetSearchTitle(series); var prefixes = GetEpisodeNumberPrefixes(episodes.Select(e => e.EpisodeNumber)); - foreach(var p in prefixes) + foreach (var p in prefixes) { var prefix = p; @@ -62,13 +60,13 @@ namespace NzbDrone.Core.Providers.Search { try { - lock(reportsLock) + lock (reportsLock) { reports.AddRange(indexer.FetchPartialSeason(title, options.SeasonNumber, prefix)); } } - catch(Exception e) + catch (Exception e) { logger.ErrorException( String.Format( @@ -82,27 +80,17 @@ namespace NzbDrone.Core.Providers.Search return reports; } - public override SearchHistoryItem CheckReport(Series series, dynamic options, EpisodeParseResult episodeParseResult, - SearchHistoryItem item) + public override bool IsEpisodeMatch(Series series, dynamic options, EpisodeParseResult episodeParseResult) { - if(options.SeasonNumber != episodeParseResult.SeasonNumber) + if (options.SeasonNumber != episodeParseResult.SeasonNumber) { logger.Trace("Season number does not match searched season number, skipping."); - item.SearchError = ReportRejectionReasons.WrongSeason; - - return item; + return false; } - return item; + return true; } - protected override void FinalizeSearch(Series series, dynamic options, Boolean reportsFound, ProgressNotification notification) - { - logger.Warn("Unable to find {0} - Season {1} in any of indexers.", series.Title, options.SeasonNumber); - - notification.CurrentMessage = reportsFound ? String.Format("Sorry, couldn't find {0} Season {1:00}, that matches your preferences.", series.Title, options.SeasonNumber) - : String.Format("Sorry, couldn't find {0} Season {1:00} in any of indexers.", series.Title, options.SeasonNumber); - } private List GetEpisodeNumberPrefixes(IEnumerable episodeNumbers) { diff --git a/NzbDrone.Core/Providers/Search/SearchBase.cs b/NzbDrone.Core/Providers/Search/SearchBase.cs index 93c3349ea..14b508c73 100644 --- a/NzbDrone.Core/Providers/Search/SearchBase.cs +++ b/NzbDrone.Core/Providers/Search/SearchBase.cs @@ -3,8 +3,6 @@ using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using NLog; -using NzbDrone.Core.Datastore; -using NzbDrone.Core.DecisionEngine.Specifications; using NzbDrone.Core.Download; using NzbDrone.Core.Indexers; using NzbDrone.Core.ReferenceData; @@ -12,7 +10,6 @@ using NzbDrone.Core.Tv; using NzbDrone.Core.Model; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.DecisionEngine; -using NzbDrone.Core.Repository.Search; namespace NzbDrone.Core.Providers.Search { @@ -23,20 +20,20 @@ namespace NzbDrone.Core.Providers.Search protected readonly DownloadProvider _downloadProvider; protected readonly IIndexerService _indexerService; protected readonly SceneMappingService _sceneMappingService; - protected readonly AllowedDownloadSpecification _allowedDownloadSpecification; + protected readonly DownloadDirector DownloadDirector; private static readonly Logger logger = LogManager.GetCurrentClassLogger(); protected SearchBase(ISeriesRepository seriesRepository, IEpisodeService episodeService, DownloadProvider downloadProvider, IIndexerService indexerService, SceneMappingService sceneMappingService, - AllowedDownloadSpecification allowedDownloadSpecification) + DownloadDirector downloadDirector) { _seriesRepository = seriesRepository; _episodeService = episodeService; _downloadProvider = downloadProvider; _indexerService = indexerService; _sceneMappingService = sceneMappingService; - _allowedDownloadSpecification = allowedDownloadSpecification; + DownloadDirector = downloadDirector; } protected SearchBase() @@ -44,123 +41,88 @@ namespace NzbDrone.Core.Providers.Search } public abstract List PerformSearch(Series series, dynamic options, ProgressNotification notification); - public abstract SearchHistoryItem CheckReport(Series series, dynamic options, EpisodeParseResult episodeParseResult, - SearchHistoryItem item); - - protected abstract void FinalizeSearch(Series series, dynamic options, Boolean reportsFound, ProgressNotification notification); + public abstract bool IsEpisodeMatch(Series series, dynamic options, EpisodeParseResult episodeParseResult); public virtual List Search(Series series, dynamic options, ProgressNotification notification) { if (options == null) throw new ArgumentNullException(options); - var searchResult = new SearchHistory - { - SearchTime = DateTime.Now, - SeriesId = series.Id, - EpisodeId = options.GetType().GetProperty("Episode") != null ? options.Episode.EpisodeId : null, - SeasonNumber = options.GetType().GetProperty("SeasonNumber") != null ? options.SeasonNumber : null - }; List reports = PerformSearch(series, options, notification); - + logger.Debug("Finished searching all indexers. Total {0}", reports.Count); notification.CurrentMessage = "Processing search results"; - - ProcessReports(series, options, reports, searchResult, notification); - if(searchResult.Successes.Any()) - return searchResult.Successes; + var result = ProcessReports(series, options, reports); - FinalizeSearch(series, options, reports.Any(), notification); - return new List(); + if (!result.Grabbed.Any()) + { + logger.Warn("Unable to find {0} in any of indexers.", options.Episode); + + notification.CurrentMessage = reports.Any() ? String.Format("Sorry, couldn't find {0}, that matches your preferences.", options.Episode) + : String.Format("Sorry, couldn't find {0} in any of indexers.", options.Episode); + } + + return result.Grabbed; } - public virtual SearchHistory ProcessReports(Series series, dynamic options, List episodeParseResults, - SearchHistory searchResult, ProgressNotification notification) + public void ProcessReports(Series series, dynamic options, List episodeParseResults) { - var items = new List(); - searchResult.Successes = new List(); - foreach(var episodeParseResult in episodeParseResults - .OrderByDescending(c => c.Quality) - .ThenBy(c => c.EpisodeNumbers.MinOrDefault()) - .ThenBy(c => c.Age)) + var sortedResults = episodeParseResults.OrderByDescending(c => c.Quality) + .ThenBy(c => c.EpisodeNumbers.MinOrDefault()) + .ThenBy(c => c.Age); + + foreach (var episodeParseResult in sortedResults) { try { - var item = new SearchHistoryItem - { - ReportTitle = episodeParseResult.OriginalString, - NzbUrl = episodeParseResult.NzbUrl, - Indexer = episodeParseResult.Indexer, - Quality = episodeParseResult.Quality.Quality, - Proper = episodeParseResult.Quality.Proper, - Size = episodeParseResult.Size, - Age = episodeParseResult.Age, - Language = episodeParseResult.Language - }; - items.Add(item); - - logger.Trace("Analysing report " + episodeParseResult); + logger.Trace("Analyzing report " + episodeParseResult); episodeParseResult.Series = _seriesRepository.GetByTitle(episodeParseResult.CleanTitle); - if(episodeParseResult.Series == null || ((ModelBase)episodeParseResult.Series).Id != series.Id) + if (episodeParseResult.Series == null || episodeParseResult.Series.Id != series.Id) { - item.SearchError = ReportRejectionReasons.WrongSeries; + episodeParseResult.Decision = new DownloadDecision("Invalid Series"); continue; } episodeParseResult.Episodes = _episodeService.GetEpisodesByParseResult(episodeParseResult); - if (searchResult.Successes.Intersect(episodeParseResult.Episodes.Select(e => e.Id)).Any()) + + if (!IsEpisodeMatch(series, options, episodeParseResult)) { - item.SearchError = ReportRejectionReasons.Skipped; - continue; + episodeParseResult.Decision = new DownloadDecision("Incorrect Episode/Season"); } - CheckReport(series, options, episodeParseResult, item); - if (item.SearchError != ReportRejectionReasons.None) - continue; + var downloadDecision = DownloadDirector.GetDownloadDecision(episodeParseResult); - item.SearchError = _allowedDownloadSpecification.IsSatisfiedBy(episodeParseResult); - - if(item.SearchError == ReportRejectionReasons.None) + if (downloadDecision.Approved) { - if(DownloadReport(notification, episodeParseResult, item)) - searchResult.Successes.AddRange(episodeParseResult.Episodes.Select(e => e.Id)); + DownloadReport(episodeParseResult); } } - catch(Exception e) + catch (Exception e) { logger.ErrorException("An error has occurred while processing parse result items from " + episodeParseResult, e); } } - - searchResult.SearchHistoryItems = items; - return searchResult; } - public virtual Boolean DownloadReport(ProgressNotification notification, EpisodeParseResult episodeParseResult, SearchHistoryItem item) + public virtual Boolean DownloadReport(EpisodeParseResult episodeParseResult) { logger.Debug("Found '{0}'. Adding to download queue.", episodeParseResult); try { if (_downloadProvider.DownloadReport(episodeParseResult)) { - notification.CurrentMessage = String.Format("{0} Added to download queue", episodeParseResult); - item.Success = true; return true; } - - item.SearchError = ReportRejectionReasons.DownloadClientFailure; } catch (Exception e) { logger.ErrorException("Unable to add report to download queue." + episodeParseResult, e); - notification.CurrentMessage = String.Format("Unable to add report to download queue. {0}", episodeParseResult); - item.SearchError = ReportRejectionReasons.DownloadClientFailure; } return false; @@ -170,7 +132,7 @@ namespace NzbDrone.Core.Providers.Search { var seasonTitle = _sceneMappingService.GetSceneName(series.Id, seasonNumber); - if(!String.IsNullOrWhiteSpace(seasonTitle)) + if (!String.IsNullOrWhiteSpace(seasonTitle)) return seasonTitle; var title = _sceneMappingService.GetSceneName(series.Id); diff --git a/NzbDrone.Core/Providers/XbmcProvider.cs b/NzbDrone.Core/Providers/XbmcProvider.cs index b1c1b7648..7b12a1086 100644 --- a/NzbDrone.Core/Providers/XbmcProvider.cs +++ b/NzbDrone.Core/Providers/XbmcProvider.cs @@ -12,7 +12,6 @@ using NzbDrone.Core.Configuration; using NzbDrone.Core.Tv; using NzbDrone.Core.Model.Xbmc; using NzbDrone.Core.Providers.Xbmc; -using NzbDrone.Core.Repository; namespace NzbDrone.Core.Providers { diff --git a/NzbDrone.Core/Repository/Search/SearchHistory.cs b/NzbDrone.Core/Repository/Search/SearchHistory.cs deleted file mode 100644 index db67e30b1..000000000 --- a/NzbDrone.Core/Repository/Search/SearchHistory.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.Collections.Generic; - - -namespace NzbDrone.Core.Repository.Search -{ - public class SearchHistory - { - public int Id { get; set; } - public int SeriesId { get; set; } - public int? SeasonNumber { get; set; } - public int? EpisodeId { get; set; } - public DateTime SearchTime { get; set; } - public bool SuccessfulDownload { get; set; } - - public List SearchHistoryItems { get; set; } - - public List Successes { get; set; } - - public string SeriesTitle { get; set; } - - public bool IsDaily { get; set; } - - public int? EpisodeNumber { get; set; } - - public string EpisodeTitle { get; set; } - - public DateTime AirDate { get; set; } - - public int TotalItems { get; set; } - - public int SuccessfulCount { get; set; } - } -} \ No newline at end of file diff --git a/NzbDrone.Core/Repository/Search/SearchHistoryItem.cs b/NzbDrone.Core/Repository/Search/SearchHistoryItem.cs deleted file mode 100644 index d721f0350..000000000 --- a/NzbDrone.Core/Repository/Search/SearchHistoryItem.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using NzbDrone.Core.DecisionEngine; -using NzbDrone.Core.Model; -using NzbDrone.Core.Qualities; - - -namespace NzbDrone.Core.Repository.Search -{ - public class SearchHistoryItem - { - public int Id { get; set; } - public int SearchHistoryId { get; set; } - public string ReportTitle { get; set; } - public string Indexer { get; set; } - public string NzbUrl { get; set; } - public string NzbInfoUrl { get; set; } - public bool Success { get; set; } - public ReportRejectionReasons SearchError { get; set; } - public Quality Quality { get; set; } - public bool Proper { get; set; } - public int Age { get; set; } - public LanguageType Language { get; set; } - public long Size { get; set; } - - public override string ToString() - { - return String.Format("{0} - {1} - {2}", ReportTitle, Quality, SearchError); - } - } -} \ No newline at end of file