|
|
@ -4,7 +4,6 @@ using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.IO;
|
|
|
|
using System.IO;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
|
|
using FluentAssertions;
|
|
|
|
using FluentAssertions;
|
|
|
|
using Moq;
|
|
|
|
using Moq;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using NUnit.Framework;
|
|
|
@ -16,11 +15,11 @@ using NzbDrone.Core.RootFolders;
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
using NzbDrone.Test.Common.AutoMoq;
|
|
|
|
using NzbDrone.Test.Common.AutoMoq;
|
|
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test.ProviderTests.RootDirProviderTests
|
|
|
|
namespace NzbDrone.Core.Test.ProviderTests.RootFolderServiceTests
|
|
|
|
{
|
|
|
|
{
|
|
|
|
[TestFixture]
|
|
|
|
[TestFixture]
|
|
|
|
// ReSharper disable InconsistentNaming
|
|
|
|
// ReSharper disable InconsistentNaming
|
|
|
|
public class RootDirProviderFixture : CoreTest<RootFolderService>
|
|
|
|
public class RootFolderServiceFixture : CoreTest<RootFolderService>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
[SetUp]
|
|
|
|
[SetUp]
|
|
|
|
public void Setup()
|
|
|
|
public void Setup()
|
|
|
@ -28,6 +27,10 @@ namespace NzbDrone.Core.Test.ProviderTests.RootDirProviderTests
|
|
|
|
Mocker.GetMock<DiskProvider>()
|
|
|
|
Mocker.GetMock<DiskProvider>()
|
|
|
|
.Setup(m => m.FolderExists(It.IsAny<string>()))
|
|
|
|
.Setup(m => m.FolderExists(It.IsAny<string>()))
|
|
|
|
.Returns(true);
|
|
|
|
.Returns(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IRootFolderRepository>()
|
|
|
|
|
|
|
|
.Setup(s => s.All())
|
|
|
|
|
|
|
|
.Returns(new List<RootFolder>());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void WithNoneExistingFolder()
|
|
|
|
private void WithNoneExistingFolder()
|
|
|
@ -37,12 +40,12 @@ namespace NzbDrone.Core.Test.ProviderTests.RootDirProviderTests
|
|
|
|
.Returns(false);
|
|
|
|
.Returns(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[TestCase("D:\\TV Shows\\")]
|
|
|
|
[TestCase("D:\\TV Shows\\")]
|
|
|
|
[TestCase("//server//folder")]
|
|
|
|
[TestCase("//server//folder")]
|
|
|
|
public void should_be_able_to_add_root_dir(string path)
|
|
|
|
public void should_be_able_to_add_root_dir(string path)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var root = new RootDir { Path = path };
|
|
|
|
var root = new RootFolder { Path = path };
|
|
|
|
|
|
|
|
|
|
|
|
Subject.Add(root);
|
|
|
|
Subject.Add(root);
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IRootFolderRepository>().Verify(c => c.Add(root), Times.Once());
|
|
|
|
Mocker.GetMock<IRootFolderRepository>().Verify(c => c.Add(root), Times.Once());
|
|
|
@ -53,7 +56,7 @@ namespace NzbDrone.Core.Test.ProviderTests.RootDirProviderTests
|
|
|
|
{
|
|
|
|
{
|
|
|
|
WithNoneExistingFolder();
|
|
|
|
WithNoneExistingFolder();
|
|
|
|
|
|
|
|
|
|
|
|
Assert.Throws<DirectoryNotFoundException>(() => Subject.Add(new RootDir { Path = "C:\\TEST" }));
|
|
|
|
Assert.Throws<DirectoryNotFoundException>(() => Subject.Add(new RootFolder { Path = "C:\\TEST" }));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
@ -67,7 +70,7 @@ namespace NzbDrone.Core.Test.ProviderTests.RootDirProviderTests
|
|
|
|
{
|
|
|
|
{
|
|
|
|
WithNoneExistingFolder();
|
|
|
|
WithNoneExistingFolder();
|
|
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IRootFolderRepository>().Setup(c => c.All()).Returns(new List<RootDir>());
|
|
|
|
Mocker.GetMock<IRootFolderRepository>().Setup(c => c.All()).Returns(new List<RootFolder>());
|
|
|
|
|
|
|
|
|
|
|
|
const string path = "d:\\bad folder";
|
|
|
|
const string path = "d:\\bad folder";
|
|
|
|
|
|
|
|
|
|
|
@ -90,17 +93,16 @@ namespace NzbDrone.Core.Test.ProviderTests.RootDirProviderTests
|
|
|
|
public void invalid_folder_path_throws_on_add(string path)
|
|
|
|
public void invalid_folder_path_throws_on_add(string path)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Assert.Throws<ArgumentException>(() =>
|
|
|
|
Assert.Throws<ArgumentException>(() =>
|
|
|
|
Mocker.Resolve<RootFolderService>().Add(new RootDir { Id = 0, Path = path })
|
|
|
|
Mocker.Resolve<RootFolderService>().Add(new RootFolder { Id = 0, Path = path })
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
public void adding_duplicated_root_folder_should_throw()
|
|
|
|
public void adding_duplicated_root_folder_should_throw()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Mocker.GetMock<IRootFolderRepository>().Setup(c => c.All()).Returns(new List<RootDir> { new RootDir { Path = "C:\\TV" } });
|
|
|
|
Mocker.GetMock<IRootFolderRepository>().Setup(c => c.All()).Returns(new List<RootFolder> { new RootFolder { Path = "C:\\TV" } });
|
|
|
|
|
|
|
|
|
|
|
|
Subject.Add(new RootDir { Path = @"C:\TV" });
|
|
|
|
Assert.Throws<InvalidOperationException>(() => Subject.Add(new RootFolder { Path = @"C:\TV" }));
|
|
|
|
Assert.Throws<InvalidOperationException>(() => Subject.Add(new RootDir { Path = @"C:\TV" }));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|