2013-02-19 06:56:02 +00:00
|
|
|
|
using System.Collections.Generic;
|
2012-08-29 15:34:51 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using FizzWare.NBuilder;
|
|
|
|
|
using Moq;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using NzbDrone.Common;
|
2013-02-19 06:01:03 +00:00
|
|
|
|
using NzbDrone.Core.Tv;
|
2012-08-29 15:34:51 +00:00
|
|
|
|
using NzbDrone.Core.Providers;
|
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
|
using NzbDrone.Test.Common;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
|
|
|
|
|
{
|
|
|
|
|
// ReSharper disable InconsistentNaming
|
2013-02-17 05:44:06 +00:00
|
|
|
|
public class ScanFixture : CoreTest
|
2012-08-29 15:34:51 +00:00
|
|
|
|
{
|
|
|
|
|
[Test]
|
|
|
|
|
public void series_should_update_the_last_scan_date()
|
|
|
|
|
{
|
|
|
|
|
|
2013-02-19 06:56:02 +00:00
|
|
|
|
|
|
|
|
|
Mocker.GetMock<ISeriesRepository>()
|
|
|
|
|
.Setup(c => c.Update(It.Is<Series>(s => s.LastDiskSync != null))).Verifiable();
|
2012-08-29 15:34:51 +00:00
|
|
|
|
|
2013-02-22 00:47:09 +00:00
|
|
|
|
Mocker.GetMock<IEpisodeService>()
|
2013-02-20 02:05:15 +00:00
|
|
|
|
.Setup(c => c.GetEpisodeBySeries(It.IsAny<int>()))
|
2012-08-29 15:34:51 +00:00
|
|
|
|
.Returns(new List<Episode> { new Episode() });
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<DiskProvider>()
|
|
|
|
|
.Setup(c => c.FolderExists(It.IsAny<string>()))
|
|
|
|
|
.Returns(true);
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<MediaFileProvider>()
|
|
|
|
|
.Setup(c => c.GetSeriesFiles(It.IsAny<int>()))
|
|
|
|
|
.Returns(new List<EpisodeFile>());
|
|
|
|
|
|
|
|
|
|
Mocker.Resolve<DiskScanProvider>().Scan(new Series());
|
|
|
|
|
|
|
|
|
|
Mocker.VerifyAllMocks();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void series_should_log_warning_if_path_doesnt_exist_on_disk()
|
|
|
|
|
{
|
|
|
|
|
//Setup
|
|
|
|
|
WithStrictMocker();
|
|
|
|
|
|
|
|
|
|
var series = Builder<Series>.CreateNew()
|
|
|
|
|
.With(s => s.Path = @"C:\Test\TV\SeriesName\")
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<MediaFileProvider>()
|
|
|
|
|
.Setup(c => c.CleanUpDatabase());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<DiskProvider>()
|
|
|
|
|
.Setup(c => c.FolderExists(series.Path))
|
|
|
|
|
.Returns(false);
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
Mocker.Resolve<DiskScanProvider>().Scan(series, series.Path);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
Mocker.VerifyAllMocks();
|
|
|
|
|
ExceptionVerification.ExpectedWarns(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|