|
|
|
@ -10,6 +10,7 @@ using NzbDrone.Common.Disk;
|
|
|
|
|
using NzbDrone.Common.EnvironmentInfo;
|
|
|
|
|
using NzbDrone.Core.Configuration;
|
|
|
|
|
using NzbDrone.Core.Movies;
|
|
|
|
|
using NzbDrone.Core.Organizer;
|
|
|
|
|
using NzbDrone.Core.RootFolders;
|
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
|
using NzbDrone.Test.Common;
|
|
|
|
@ -19,9 +20,13 @@ namespace NzbDrone.Core.Test.RootFolderTests
|
|
|
|
|
[TestFixture]
|
|
|
|
|
public class RootFolderServiceFixture : CoreTest<RootFolderService>
|
|
|
|
|
{
|
|
|
|
|
private NamingConfig _namingConfig;
|
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
|
public void Setup()
|
|
|
|
|
{
|
|
|
|
|
_namingConfig = NamingConfig.Default;
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IDiskProvider>()
|
|
|
|
|
.Setup(m => m.FolderExists(It.IsAny<string>()))
|
|
|
|
|
.Returns(true);
|
|
|
|
@ -33,6 +38,10 @@ namespace NzbDrone.Core.Test.RootFolderTests
|
|
|
|
|
Mocker.GetMock<IRootFolderRepository>()
|
|
|
|
|
.Setup(s => s.All())
|
|
|
|
|
.Returns(new List<RootFolder>());
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<INamingConfigService>()
|
|
|
|
|
.Setup(c => c.GetConfig())
|
|
|
|
|
.Returns(_namingConfig);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void WithNonExistingFolder()
|
|
|
|
@ -254,5 +263,47 @@ namespace NzbDrone.Core.Test.RootFolderTests
|
|
|
|
|
unmappedFolders.Count.Should().Be(3);
|
|
|
|
|
unmappedFolders.Should().NotContain(u => u.Name == "BIN");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_get_unmapped_folders_inside_letter_subfolder()
|
|
|
|
|
{
|
|
|
|
|
_namingConfig.MovieFolderFormat = "{Movie TitleFirstCharacter}\\{Movie Title}".AsOsAgnostic();
|
|
|
|
|
|
|
|
|
|
var rootFolderPath = @"C:\Test\Movies".AsOsAgnostic();
|
|
|
|
|
var rootFolder = Builder<RootFolder>.CreateNew()
|
|
|
|
|
.With(r => r.Path = rootFolderPath)
|
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
|
|
var subFolderPath = Path.Combine(rootFolderPath, "M");
|
|
|
|
|
|
|
|
|
|
var subFolders = new[]
|
|
|
|
|
{
|
|
|
|
|
"Movie1",
|
|
|
|
|
"Movie2",
|
|
|
|
|
"Movie3",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var folders = subFolders.Select(f => Path.Combine(subFolderPath, f)).ToArray();
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IRootFolderRepository>()
|
|
|
|
|
.Setup(s => s.Get(It.IsAny<int>()))
|
|
|
|
|
.Returns(rootFolder);
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IMovieRepository>()
|
|
|
|
|
.Setup(s => s.AllMoviePaths())
|
|
|
|
|
.Returns(new Dictionary<int, string>());
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IDiskProvider>()
|
|
|
|
|
.Setup(s => s.GetDirectories(rootFolder.Path))
|
|
|
|
|
.Returns(new[] { subFolderPath });
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<IDiskProvider>()
|
|
|
|
|
.Setup(s => s.GetDirectories(subFolderPath))
|
|
|
|
|
.Returns(folders);
|
|
|
|
|
|
|
|
|
|
var unmappedFolders = Subject.Get(rootFolder.Id, false).UnmappedFolders;
|
|
|
|
|
|
|
|
|
|
unmappedFolders.Count.Should().Be(3);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|