|
|
@ -88,6 +88,69 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
|
|
|
|
var currentFilename = Path.Combine(@"C:\Test\TV\30 Rock\Season 01\", "30.Rock.S01E01.Test.WED-DL.mkv");
|
|
|
|
var currentFilename = Path.Combine(@"C:\Test\TV\30 Rock\Season 01\", "30.Rock.S01E01.Test.WED-DL.mkv");
|
|
|
|
const string message = "30 Rock - 1x01 - [WEBDL]";
|
|
|
|
const string message = "30 Rock - 1x01 - [WEBDL]";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var file = Builder<EpisodeFile>.CreateNew()
|
|
|
|
|
|
|
|
.With(f => f.SeriesId = fakeSeries.SeriesId)
|
|
|
|
|
|
|
|
.With(f => f.Path = currentFilename)
|
|
|
|
|
|
|
|
.With(f => f.Quality = QualityTypes.WEBDL720p)
|
|
|
|
|
|
|
|
.With(f => f.Proper = false)
|
|
|
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<SeriesProvider>()
|
|
|
|
|
|
|
|
.Setup(e => e.GetSeries(fakeSeries.SeriesId))
|
|
|
|
|
|
|
|
.Returns(fakeSeries);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<EpisodeProvider>()
|
|
|
|
|
|
|
|
.Setup(e => e.GetEpisodesByFileId(file.EpisodeFileId))
|
|
|
|
|
|
|
|
.Returns(fakeEpisode);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<MediaFileProvider>()
|
|
|
|
|
|
|
|
.Setup(e => e.GetNewFilename(fakeEpisode, fakeSeries, It.IsAny<QualityTypes>(), It.IsAny<bool>(), It.IsAny<EpisodeFile>()))
|
|
|
|
|
|
|
|
.Returns(filename);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<MediaFileProvider>()
|
|
|
|
|
|
|
|
.Setup(e => e.CalculateFilePath(It.IsAny<Series>(), fakeEpisode.First().SeasonNumber, filename, ".mkv"))
|
|
|
|
|
|
|
|
.Returns(fi);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<DownloadProvider>()
|
|
|
|
|
|
|
|
.Setup(s => s.GetDownloadTitle(It.Is<EpisodeParseResult>(e => e.Quality == new QualityModel { Quality = QualityTypes.WEBDL720p, Proper = false })))
|
|
|
|
|
|
|
|
.Returns(message);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<DiskProvider>()
|
|
|
|
|
|
|
|
.Setup(s => s.FileExists(currentFilename))
|
|
|
|
|
|
|
|
.Returns(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<ExternalNotificationProvider>()
|
|
|
|
|
|
|
|
.Setup(e => e.OnDownload("30 Rock - 1x01 - [WEBDL]", It.IsAny<Series>()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
|
|
|
var result = Mocker.Resolve<DiskScanProvider>().MoveEpisodeFile(file, true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
|
|
|
result.Should().NotBeNull();
|
|
|
|
|
|
|
|
Mocker.GetMock<ExternalNotificationProvider>()
|
|
|
|
|
|
|
|
.Verify(e => e.OnDownload("30 Rock - 1x01 - [WEBDL]", It.IsAny<Series>()), Times.Once());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
|
|
public void should_log_error_and_return_null_when_source_file_does_not_exists()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew()
|
|
|
|
|
|
|
|
.With(s => s.SeriesId = 5)
|
|
|
|
|
|
|
|
.With(s => s.Title = "30 Rock")
|
|
|
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var fakeEpisode = Builder<Episode>.CreateListOfSize(1)
|
|
|
|
|
|
|
|
.All()
|
|
|
|
|
|
|
|
.With(e => e.SeriesId = fakeSeries.SeriesId)
|
|
|
|
|
|
|
|
.With(e => e.SeasonNumber = 1)
|
|
|
|
|
|
|
|
.With(e => e.EpisodeNumber = 1)
|
|
|
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const string filename = @"30 Rock - S01E01 - TBD";
|
|
|
|
|
|
|
|
var fi = new FileInfo(Path.Combine(@"C:\Test\TV\30 Rock\Season 01\", filename + ".mkv"));
|
|
|
|
|
|
|
|
var currentFilename = Path.Combine(@"C:\Test\TV\30 Rock\Season 01\", "30.Rock.S01E01.Test.WED-DL.mkv");
|
|
|
|
|
|
|
|
const string message = "30 Rock - 1x01 - [WEBDL]";
|
|
|
|
|
|
|
|
|
|
|
|
var file = Builder<EpisodeFile>.CreateNew()
|
|
|
|
var file = Builder<EpisodeFile>.CreateNew()
|
|
|
|
.With(f => f.SeriesId = fakeSeries.SeriesId)
|
|
|
|
.With(f => f.SeriesId = fakeSeries.SeriesId)
|
|
|
|
.With(f => f.Path = currentFilename)
|
|
|
|
.With(f => f.Path = currentFilename)
|
|
|
@ -112,7 +175,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
|
|
|
|
.Returns(fi);
|
|
|
|
.Returns(fi);
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<DownloadProvider>()
|
|
|
|
Mocker.GetMock<DownloadProvider>()
|
|
|
|
.Setup(s => s.GetDownloadTitle(It.Is<EpisodeParseResult>(e => e.Quality == new QualityModel{ Quality = QualityTypes.WEBDL720p, Proper = false })))
|
|
|
|
.Setup(s => s.GetDownloadTitle(It.Is<EpisodeParseResult>(e => e.Quality == new QualityModel { Quality = QualityTypes.WEBDL720p, Proper = false })))
|
|
|
|
.Returns(message);
|
|
|
|
.Returns(message);
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<ExternalNotificationProvider>()
|
|
|
|
Mocker.GetMock<ExternalNotificationProvider>()
|
|
|
@ -122,9 +185,8 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
|
|
|
|
var result = Mocker.Resolve<DiskScanProvider>().MoveEpisodeFile(file, true);
|
|
|
|
var result = Mocker.Resolve<DiskScanProvider>().MoveEpisodeFile(file, true);
|
|
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
//Assert
|
|
|
|
result.Should().NotBeNull();
|
|
|
|
result.Should().BeNull();
|
|
|
|
Mocker.GetMock<ExternalNotificationProvider>()
|
|
|
|
ExceptionVerification.ExpectedErrors(1);
|
|
|
|
.Verify(e => e.OnDownload("30 Rock - 1x01 - [WEBDL]", It.IsAny<Series>()), Times.Once());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|