1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2024-12-26 09:49:00 +00:00
Radarr/NzbDrone.Core.Test/RootDirProviderTest.cs

117 lines
3.2 KiB
C#
Raw Normal View History

2011-04-10 02:44:01 +00:00
using System.Linq;
2011-04-09 21:35:13 +00:00
using AutoMoq;
using MbUnit.Framework;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Test.Framework;
2011-04-09 21:35:13 +00:00
using SubSonic.Repository;
namespace NzbDrone.Core.Test
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class RootDirProviderTest : TestBase
2011-04-09 21:35:13 +00:00
{
2011-04-09 21:35:13 +00:00
[Test]
public void GetRootDirs()
{
//Setup
var sonicRepo = MockLib.GetEmptyRepository();
2011-04-10 02:44:01 +00:00
sonicRepo.Add(new RootDir {Path = @"C:\TV"});
sonicRepo.Add(new RootDir {Path = @"C:\TV2"});
2011-04-09 21:35:13 +00:00
var mocker = new AutoMoqer();
mocker.GetMock<IRepository>()
.Setup(f => f.All<RootDir>())
.Returns(sonicRepo.All<RootDir>);
//Act
var result = mocker.Resolve<RootDirProvider>().GetAll();
//Assert
Assert.AreEqual(result.Count, 2);
}
[Test]
public void AddRootDir()
{
//Setup
var mocker = new AutoMoqer();
mocker.SetConstant(MockLib.GetEmptyRepository());
const string path = @"C:\TV\";
2011-04-09 21:35:13 +00:00
//Act
var rootDirProvider = mocker.Resolve<RootDirProvider>();
2011-04-10 02:44:01 +00:00
rootDirProvider.Add(new RootDir {Path = path});
2011-04-09 21:35:13 +00:00
//Assert
var rootDirs = rootDirProvider.GetAll();
Assert.IsNotEmpty(rootDirs);
Assert.Count(1, rootDirs);
Assert.AreEqual(path, rootDirs.First().Path);
}
[Test]
public void UpdateRootDir()
{
//Setup
var mocker = new AutoMoqer();
mocker.SetConstant(MockLib.GetEmptyRepository());
const string path = @"C:\TV2";
2011-04-09 21:35:13 +00:00
//Act
var rootDirProvider = mocker.Resolve<RootDirProvider>();
2011-04-10 02:44:01 +00:00
rootDirProvider.Add(new RootDir {Path = @"C:\TV"});
rootDirProvider.Update(new RootDir {Id = 1, Path = path});
2011-04-09 21:35:13 +00:00
//Assert
var rootDirs = rootDirProvider.GetAll();
Assert.IsNotEmpty(rootDirs);
Assert.Count(1, rootDirs);
Assert.AreEqual(path, rootDirs.First().Path);
}
[Test]
public void RemoveRootDir()
{
//Setup
var mocker = new AutoMoqer();
mocker.SetConstant(MockLib.GetEmptyRepository());
//Act
var rootDirProvider = mocker.Resolve<RootDirProvider>();
2011-04-10 02:44:01 +00:00
rootDirProvider.Add(new RootDir {Path = @"C:\TV"});
2011-04-09 21:35:13 +00:00
rootDirProvider.Remove(1);
//Assert
var rootDirs = rootDirProvider.GetAll();
Assert.Count(0, rootDirs);
}
[Test]
public void GetRootDir()
{
//Setup
var mocker = new AutoMoqer();
mocker.SetConstant(MockLib.GetEmptyRepository());
const int id = 1;
const string path = @"C:\TV";
2011-04-09 21:35:13 +00:00
//Act
var rootDirProvider = mocker.Resolve<RootDirProvider>();
2011-04-10 02:44:01 +00:00
rootDirProvider.Add(new RootDir {Id = id, Path = path});
2011-04-09 21:35:13 +00:00
//Assert
var rootDir = rootDirProvider.GetRootDir(id);
Assert.AreEqual(1, rootDir.Id);
Assert.AreEqual(path, rootDir.Path);
}
}
2011-04-10 02:44:01 +00:00
}