PostDownloadScanJob can now be passed a path

pull/6/head
Mark McDowall 12 years ago
parent b21bf01bf0
commit cb0f1fe513

@ -0,0 +1,72 @@
using System.Linq;
using System;
using System.Diagnostics;
using System.IO;
using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Jobs;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.JobTests
{
[TestFixture]
internal class PostDownloadScanJobFixture : CoreTest
{
[SetUp]
public void Setup()
{
Mocker.GetMock<DiskProvider>().Setup(s => s.FolderExists(It.IsAny<string>())).Returns(true);
}
[Test]
public void should_use_options_Path_when_provided()
{
var path = @"C:\Test\Unsorted TV";
Mocker.GetMock<PostDownloadProvider>().Setup(s => s.ProcessDropFolder(path));
Mocker.Resolve<PostDownloadScanJob>().Start(MockNotification, new { Path = path });
Mocker.GetMock<PostDownloadProvider>().Verify(s => s.ProcessDropFolder(path), Times.Once());
}
[Test]
public void should_not_get_sabDropDir_when_path_is_supplied()
{
var path = @"C:\Test\Unsorted TV";
Mocker.GetMock<PostDownloadProvider>().Setup(s => s.ProcessDropFolder(path));
Mocker.Resolve<PostDownloadScanJob>().Start(MockNotification, new { Path = path });
Mocker.GetMock<ConfigProvider>().Verify(s => s.SabDropDirectory, Times.Never());
}
[Test]
public void should_get_sabDropDir_when_path_is_not_supplied()
{
var path = @"C:\Test\Unsorted TV";
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.SabDropDirectory).Returns(path);
Mocker.Resolve<PostDownloadScanJob>().Start(MockNotification, null);
Mocker.GetMock<ConfigProvider>().Verify(s => s.SabDropDirectory, Times.Once());
}
[Test]
public void should_use_sabDropDir_when_options_Path_is_not_provided()
{
var path = @"C:\Test\Unsorted TV";
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.SabDropDirectory).Returns(path);
Mocker.Resolve<PostDownloadScanJob>().Start(MockNotification, null);
Mocker.GetMock<PostDownloadProvider>().Verify(s => s.ProcessDropFolder(path), Times.Once());
}
}
}

@ -143,6 +143,7 @@
<Compile Include="Integeration\ServiceIntegerationFixture.cs" />
<Compile Include="JobTests\BacklogSearchJobTest.cs" />
<Compile Include="JobTests\BannerDownloadJobTest.cs" />
<Compile Include="JobTests\PostDownloadScanJobFixture.cs" />
<Compile Include="JobTests\RecentBacklogSearchJobTest.cs" />
<Compile Include="ProviderTests\ConfigProviderTests\ConfigCachingFixture.cs" />
<Compile Include="ProviderTests\BannerProviderTest.cs" />

@ -41,7 +41,13 @@ namespace NzbDrone.Core.Jobs
public virtual void Start(ProgressNotification notification, dynamic options)
{
var dropFolder = _configProvider.SabDropDirectory;
string dropFolder;
if (options != null && !String.IsNullOrWhiteSpace(options.Path))
dropFolder = options.Path;
else
dropFolder = _configProvider.SabDropDirectory;
if (String.IsNullOrWhiteSpace(dropFolder))
{

Loading…
Cancel
Save