mirror of
https://github.com/lidarr/Lidarr
synced 2025-02-26 07:42:49 +00:00
Update RootFolderCheckFixture and RootFolderServceFixture
This commit is contained in:
parent
c5325f3630
commit
bba52cdbc8
2 changed files with 25 additions and 25 deletions
|
@ -1,4 +1,4 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using FizzWare.NBuilder;
|
using FizzWare.NBuilder;
|
||||||
using Moq;
|
using Moq;
|
||||||
|
@ -6,7 +6,7 @@
|
||||||
using NzbDrone.Common.Disk;
|
using NzbDrone.Common.Disk;
|
||||||
using NzbDrone.Core.HealthCheck.Checks;
|
using NzbDrone.Core.HealthCheck.Checks;
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Music;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.HealthCheck.Checks
|
namespace NzbDrone.Core.Test.HealthCheck.Checks
|
||||||
{
|
{
|
||||||
|
@ -15,17 +15,17 @@ public class RootFolderCheckFixture : CoreTest<RootFolderCheck>
|
||||||
{
|
{
|
||||||
private void GivenMissingRootFolder()
|
private void GivenMissingRootFolder()
|
||||||
{
|
{
|
||||||
var series = Builder<Series>.CreateListOfSize(1)
|
var artist = Builder<Artist>.CreateListOfSize(1)
|
||||||
.Build()
|
.Build()
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
Mocker.GetMock<ISeriesService>()
|
Mocker.GetMock<IArtistService>()
|
||||||
.Setup(s => s.GetAllSeries())
|
.Setup(s => s.GetAllArtists())
|
||||||
.Returns(series);
|
.Returns(artist);
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
.Setup(s => s.GetParentFolder(series.First().Path))
|
.Setup(s => s.GetParentFolder(artist.First().Path))
|
||||||
.Returns(@"C:\TV");
|
.Returns(@"C:\Music");
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
.Setup(s => s.FolderExists(It.IsAny<string>()))
|
.Setup(s => s.FolderExists(It.IsAny<string>()))
|
||||||
|
@ -33,17 +33,17 @@ private void GivenMissingRootFolder()
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_not_return_error_when_no_series()
|
public void should_not_return_error_when_no_artist()
|
||||||
{
|
{
|
||||||
Mocker.GetMock<ISeriesService>()
|
Mocker.GetMock<IArtistService>()
|
||||||
.Setup(s => s.GetAllSeries())
|
.Setup(s => s.GetAllArtists())
|
||||||
.Returns(new List<Series>());
|
.Returns(new List<Artist>());
|
||||||
|
|
||||||
Subject.Check().ShouldBeOk();
|
Subject.Check().ShouldBeOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_return_error_if_series_parent_is_missing()
|
public void should_return_error_if_artist_parent_is_missing()
|
||||||
{
|
{
|
||||||
GivenMissingRootFolder();
|
GivenMissingRootFolder();
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
using NzbDrone.Core.Configuration;
|
using NzbDrone.Core.Configuration;
|
||||||
using NzbDrone.Core.RootFolders;
|
using NzbDrone.Core.RootFolders;
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Music;
|
||||||
using NzbDrone.Test.Common;
|
using NzbDrone.Test.Common;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Test.RootFolderTests
|
namespace NzbDrone.Core.Test.RootFolderTests
|
||||||
|
@ -42,7 +42,7 @@ private void WithNonExistingFolder()
|
||||||
.Returns(false);
|
.Returns(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase("D:\\TV Shows\\")]
|
[TestCase("D:\\Music\\")]
|
||||||
[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)
|
||||||
{
|
{
|
||||||
|
@ -81,9 +81,9 @@ public void invalid_folder_path_throws_on_add(string 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<RootFolder> { new RootFolder { Path = "C:\\TV".AsOsAgnostic() } });
|
Mocker.GetMock<IRootFolderRepository>().Setup(c => c.All()).Returns(new List<RootFolder> { new RootFolder { Path = "C:\\Music".AsOsAgnostic() } });
|
||||||
|
|
||||||
Assert.Throws<InvalidOperationException>(() => Subject.Add(new RootFolder { Path = @"C:\TV".AsOsAgnostic() }));
|
Assert.Throws<InvalidOperationException>(() => Subject.Add(new RootFolder { Path = @"C:\Music".AsOsAgnostic() }));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -93,7 +93,7 @@ public void should_throw_when_adding_not_writable_folder()
|
||||||
.Setup(m => m.FolderWritable(It.IsAny<string>()))
|
.Setup(m => m.FolderWritable(It.IsAny<string>()))
|
||||||
.Returns(false);
|
.Returns(false);
|
||||||
|
|
||||||
Assert.Throws<UnauthorizedAccessException>(() => Subject.Add(new RootFolder { Path = @"C:\TV".AsOsAgnostic() }));
|
Assert.Throws<UnauthorizedAccessException>(() => Subject.Add(new RootFolder { Path = @"C:\Music".AsOsAgnostic() }));
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase("$recycle.bin")]
|
[TestCase("$recycle.bin")]
|
||||||
|
@ -107,16 +107,16 @@ public void should_throw_when_adding_not_writable_folder()
|
||||||
[TestCase(".grab")]
|
[TestCase(".grab")]
|
||||||
public void should_get_root_folder_with_subfolders_excluding_special_sub_folders(string subFolder)
|
public void should_get_root_folder_with_subfolders_excluding_special_sub_folders(string subFolder)
|
||||||
{
|
{
|
||||||
var rootFolderPath = @"C:\Test\TV".AsOsAgnostic();
|
var rootFolderPath = @"C:\Test\Music".AsOsAgnostic();
|
||||||
var rootFolder = Builder<RootFolder>.CreateNew()
|
var rootFolder = Builder<RootFolder>.CreateNew()
|
||||||
.With(r => r.Path = rootFolderPath)
|
.With(r => r.Path = rootFolderPath)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
var subFolders = new[]
|
var subFolders = new[]
|
||||||
{
|
{
|
||||||
"Series1",
|
"Artist1",
|
||||||
"Series2",
|
"Artist2",
|
||||||
"Series3",
|
"Artist3",
|
||||||
subFolder
|
subFolder
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -126,9 +126,9 @@ public void should_get_root_folder_with_subfolders_excluding_special_sub_folders
|
||||||
.Setup(s => s.Get(It.IsAny<int>()))
|
.Setup(s => s.Get(It.IsAny<int>()))
|
||||||
.Returns(rootFolder);
|
.Returns(rootFolder);
|
||||||
|
|
||||||
Mocker.GetMock<ISeriesService>()
|
Mocker.GetMock<IArtistService>()
|
||||||
.Setup(s => s.GetAllSeries())
|
.Setup(s => s.GetAllArtists())
|
||||||
.Returns(new List<Series>());
|
.Returns(new List<Artist>());
|
||||||
|
|
||||||
Mocker.GetMock<IDiskProvider>()
|
Mocker.GetMock<IDiskProvider>()
|
||||||
.Setup(s => s.GetDirectories(rootFolder.Path))
|
.Setup(s => s.GetDirectories(rootFolder.Path))
|
||||||
|
|
Loading…
Reference in a new issue