|
|
|
@ -67,7 +67,7 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
|
{
|
|
|
|
|
Series = new Series(),
|
|
|
|
|
Episodes = new List<Episode> { new Episode { Id = 1 } }
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -77,11 +77,11 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
|
.Setup(s => s.MostRecentForDownloadId(_trackedDownload.DownloadItem.DownloadId))
|
|
|
|
|
.Returns((History.History)null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void GivenSuccessfulImport()
|
|
|
|
|
{
|
|
|
|
|
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
|
|
|
|
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
|
|
|
|
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
|
|
|
|
.Returns(new List<ImportResult>
|
|
|
|
|
{
|
|
|
|
|
new ImportResult(new ImportDecision(new LocalEpisode() { Path = @"C:\TestPath\Droned.S01E01.mkv" }))
|
|
|
|
@ -145,7 +145,7 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
|
GivenNoGrabbedHistory();
|
|
|
|
|
GivenSeriesMatch();
|
|
|
|
|
GivenSuccessfulImport();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Subject.Process(_trackedDownload);
|
|
|
|
|
|
|
|
|
|
AssertCompletedDownload();
|
|
|
|
@ -179,13 +179,13 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
|
public void should_mark_as_imported_if_all_episodes_were_imported()
|
|
|
|
|
{
|
|
|
|
|
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
|
|
|
|
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
|
|
|
|
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
|
|
|
|
.Returns(new List<ImportResult>
|
|
|
|
|
{
|
|
|
|
|
new ImportResult(
|
|
|
|
|
new ImportDecision(
|
|
|
|
|
new LocalEpisode {Path = @"C:\TestPath\Droned.S01E01.mkv"})),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
new ImportResult(
|
|
|
|
|
new ImportDecision(
|
|
|
|
|
new LocalEpisode {Path = @"C:\TestPath\Droned.S01E02.mkv"}))
|
|
|
|
@ -200,13 +200,13 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
|
public void should_not_mark_as_imported_if_all_files_were_rejected()
|
|
|
|
|
{
|
|
|
|
|
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
|
|
|
|
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
|
|
|
|
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
|
|
|
|
.Returns(new List<ImportResult>
|
|
|
|
|
{
|
|
|
|
|
new ImportResult(
|
|
|
|
|
new ImportDecision(
|
|
|
|
|
new LocalEpisode {Path = @"C:\TestPath\Droned.S01E01.mkv"}, new Rejection("Rejected!")), "Test Failure"),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
new ImportResult(
|
|
|
|
|
new ImportDecision(
|
|
|
|
|
new LocalEpisode {Path = @"C:\TestPath\Droned.S01E02.mkv"},new Rejection("Rejected!")), "Test Failure")
|
|
|
|
@ -224,13 +224,13 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
|
public void should_not_mark_as_imported_if_no_episodes_were_parsed()
|
|
|
|
|
{
|
|
|
|
|
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
|
|
|
|
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
|
|
|
|
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
|
|
|
|
.Returns(new List<ImportResult>
|
|
|
|
|
{
|
|
|
|
|
new ImportResult(
|
|
|
|
|
new ImportDecision(
|
|
|
|
|
new LocalEpisode {Path = @"C:\TestPath\Droned.S01E01.mkv"}, new Rejection("Rejected!")), "Test Failure"),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
new ImportResult(
|
|
|
|
|
new ImportDecision(
|
|
|
|
|
new LocalEpisode {Path = @"C:\TestPath\Droned.S01E02.mkv"},new Rejection("Rejected!")), "Test Failure")
|
|
|
|
@ -247,7 +247,7 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
|
public void should_not_mark_as_imported_if_all_files_were_skipped()
|
|
|
|
|
{
|
|
|
|
|
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
|
|
|
|
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
|
|
|
|
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
|
|
|
|
.Returns(new List<ImportResult>
|
|
|
|
|
{
|
|
|
|
|
new ImportResult(new ImportDecision(new LocalEpisode {Path = @"C:\TestPath\Droned.S01E01.mkv"}),"Test Failure"),
|
|
|
|
@ -271,7 +271,7 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
|
|
|
|
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
|
|
|
|
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
|
|
|
|
.Returns(new List<ImportResult>
|
|
|
|
|
{
|
|
|
|
|
new ImportResult(new ImportDecision(new LocalEpisode {Path = @"C:\TestPath\Droned.S01E01.mkv"})),
|
|
|
|
@ -294,7 +294,7 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
|
|
|
|
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
|
|
|
|
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
|
|
|
|
.Returns(new List<ImportResult>
|
|
|
|
|
{
|
|
|
|
|
new ImportResult(new ImportDecision(new LocalEpisode {Path = @"C:\TestPath\Droned.S01E01.mkv"})),
|
|
|
|
@ -314,7 +314,7 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
|
GivenABadlyNamedDownload();
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
|
|
|
|
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
|
|
|
|
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
|
|
|
|
.Returns(new List<ImportResult>
|
|
|
|
|
{
|
|
|
|
|
new ImportResult(new ImportDecision(new LocalEpisode {Path = @"C:\TestPath\Droned.S01E01.mkv"}))
|
|
|
|
@ -323,7 +323,7 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
|
Mocker.GetMock<ISeriesService>()
|
|
|
|
|
.Setup(v => v.GetSeries(It.IsAny<int>()))
|
|
|
|
|
.Returns(BuildRemoteEpisode().Series);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Subject.Process(_trackedDownload);
|
|
|
|
|
|
|
|
|
|
AssertCompletedDownload();
|
|
|
|
@ -335,7 +335,7 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
|
GivenABadlyNamedDownload();
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
|
|
|
|
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
|
|
|
|
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
|
|
|
|
.Returns(new List<ImportResult>
|
|
|
|
|
{
|
|
|
|
|
new ImportResult(new ImportDecision(new LocalEpisode {Path = @"C:\TestPath\Droned.S01E01.mkv"}))
|
|
|
|
@ -370,7 +370,7 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
|
|
|
|
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
|
|
|
|
.Setup(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()))
|
|
|
|
|
.Returns(new List<ImportResult>
|
|
|
|
|
{
|
|
|
|
|
new ImportResult(new ImportDecision(new LocalEpisode {Path = @"C:\TestPath\Droned.S01E01.mkv"}))
|
|
|
|
@ -408,7 +408,7 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
|
private void AssertNoAttemptedImport()
|
|
|
|
|
{
|
|
|
|
|
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
|
|
|
|
.Verify(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()), Times.Never());
|
|
|
|
|
.Verify(v => v.ProcessPath(It.IsAny<string>(), It.IsAny<ImportMode>(), It.IsAny<Series>(), It.IsAny<DownloadClientItem>()), Times.Never());
|
|
|
|
|
|
|
|
|
|
AssertNoCompletedDownload();
|
|
|
|
|
}
|
|
|
|
@ -424,7 +424,7 @@ namespace NzbDrone.Core.Test.Download
|
|
|
|
|
private void AssertCompletedDownload()
|
|
|
|
|
{
|
|
|
|
|
Mocker.GetMock<IDownloadedEpisodesImportService>()
|
|
|
|
|
.Verify(v => v.ProcessPath(_trackedDownload.DownloadItem.OutputPath.FullPath, _trackedDownload.RemoteEpisode.Series, _trackedDownload.DownloadItem), Times.Once());
|
|
|
|
|
.Verify(v => v.ProcessPath(_trackedDownload.DownloadItem.OutputPath.FullPath, ImportMode.Auto, _trackedDownload.RemoteEpisode.Series, _trackedDownload.DownloadItem), Times.Once());
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IEventAggregator>()
|
|
|
|
|
.Verify(v => v.PublishEvent(It.IsAny<DownloadCompletedEvent>()), Times.Once());
|
|
|
|
|