mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-14 10:47:08 -07:00
fixed some tests, cleaned up root folders.
This commit is contained in:
parent
e44d262a1a
commit
a0d0e4715e
18 changed files with 110 additions and 133 deletions
109
NzbDrone.Core.Test/RootFolderTests/FreeSpaceOnDrivesFixture.cs
Normal file
109
NzbDrone.Core.Test/RootFolderTests/FreeSpaceOnDrivesFixture.cs
Normal file
|
@ -0,0 +1,109 @@
|
|||
// ReSharper disable RedundantUsingDirective
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.RootFolders;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.RootFolderTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class FreeSpaceOnDrivesFixture : CoreTest<RootFolderService>
|
||||
{
|
||||
[Test]
|
||||
public void should_return_one_drive_when_only_one_root_dir_exists()
|
||||
{
|
||||
Mocker.GetMock<IRootFolderRepository>()
|
||||
.Setup(s => s.All())
|
||||
.Returns(new List<RootFolder> { new RootFolder { OID = 1, Path = @"C:\Test\TV" } });
|
||||
|
||||
Mocker.GetMock<DiskProvider>()
|
||||
.Setup(s => s.GetPathRoot(@"C:\Test\TV"))
|
||||
.Returns(@"C:\");
|
||||
|
||||
Mocker.GetMock<DiskProvider>()
|
||||
.Setup(s => s.FreeDiskSpace(@"C:\"))
|
||||
.Returns(123456);
|
||||
|
||||
var result = Subject.FreeSpaceOnDrives();
|
||||
|
||||
result.Should().HaveCount(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_one_drive_when_two_rootDirs_on_the_same_drive_exist()
|
||||
{
|
||||
Mocker.GetMock<IRootFolderRepository>()
|
||||
.Setup(s => s.All())
|
||||
.Returns(new List<RootFolder> { new RootFolder { OID = 1, Path = @"C:\Test\TV" },
|
||||
new RootFolder { OID = 2, Path = @"C:\Test\TV2" }});
|
||||
|
||||
Mocker.GetMock<DiskProvider>()
|
||||
.Setup(s => s.GetPathRoot(It.IsAny<String>()))
|
||||
.Returns(@"C:\");
|
||||
|
||||
Mocker.GetMock<DiskProvider>()
|
||||
.Setup(s => s.FreeDiskSpace(@"C:\"))
|
||||
.Returns(123456);
|
||||
|
||||
var result = Subject.FreeSpaceOnDrives();
|
||||
|
||||
result.Should().HaveCount(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_two_drives_when_two_rootDirs_on_the_different_drive_exist()
|
||||
{
|
||||
Mocker.GetMock<IRootFolderRepository>()
|
||||
.Setup(s => s.All())
|
||||
.Returns(new List<RootFolder> { new RootFolder { OID = 1, Path = @"C:\Test\TV" },
|
||||
new RootFolder { OID = 2, Path = @"D:\Test\TV" }});
|
||||
|
||||
Mocker.GetMock<DiskProvider>()
|
||||
.Setup(s => s.GetPathRoot(@"C:\Test\TV"))
|
||||
.Returns(@"C:\");
|
||||
|
||||
Mocker.GetMock<DiskProvider>()
|
||||
.Setup(s => s.GetPathRoot(@"D:\Test\TV"))
|
||||
.Returns(@"D:\");
|
||||
|
||||
Mocker.GetMock<DiskProvider>()
|
||||
.Setup(s => s.FreeDiskSpace(It.IsAny<string>()))
|
||||
.Returns(123456);
|
||||
|
||||
var result = Subject.FreeSpaceOnDrives();
|
||||
|
||||
result.Should().HaveCount(2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_skip_rootDir_if_not_found_on_disk()
|
||||
{
|
||||
Mocker.GetMock<IRootFolderRepository>()
|
||||
.Setup(s => s.All())
|
||||
.Returns(new List<RootFolder> { new RootFolder { OID = 1, Path = @"C:\Test\TV" } });
|
||||
|
||||
Mocker.GetMock<DiskProvider>()
|
||||
.Setup(s => s.GetPathRoot(@"C:\Test\TV"))
|
||||
.Returns(@"C:\");
|
||||
|
||||
Mocker.GetMock<DiskProvider>()
|
||||
.Setup(s => s.FreeDiskSpace(It.IsAny<string>()))
|
||||
.Throws(new DirectoryNotFoundException());
|
||||
|
||||
var result = Subject.FreeSpaceOnDrives();
|
||||
|
||||
result.Should().HaveCount(0);
|
||||
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue