Fixed most of the broken tests

pull/6/head
Mark McDowall 12 years ago committed by kay.one
parent 34038245eb
commit 7ed148b12c

@ -23,7 +23,7 @@ namespace NzbDrone.Api.RootFolders
private Response AddRootFolder() private Response AddRootFolder()
{ {
var dir = _rootFolderService.Add(Request.Body.FromJson<RootDir>()); var dir = _rootFolderService.Add(Request.Body.FromJson<RootFolder>());
return dir.AsResponse(HttpStatusCode.Created); return dir.AsResponse(HttpStatusCode.Created);
} }

@ -72,9 +72,9 @@
<Reference Include="NLog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL"> <Reference Include="NLog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll</HintPath> <HintPath>..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll</HintPath>
</Reference> </Reference>
<Reference Include="nunit.framework, Version=2.6.0.12051, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL"> <Reference Include="nunit.framework, Version=2.6.2.12296, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\NUnit.2.6.0.12054\lib\nunit.framework.dll</HintPath> <HintPath>..\packages\NUnit.2.6.2\lib\nunit.framework.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />

@ -5,5 +5,5 @@
<package id="Moq" version="4.0.10827" /> <package id="Moq" version="4.0.10827" />
<package id="NBuilder" version="3.0.1.1" /> <package id="NBuilder" version="3.0.1.1" />
<package id="NLog" version="2.0.0.2000" /> <package id="NLog" version="2.0.0.2000" />
<package id="NUnit" version="2.6.0.12054" /> <package id="NUnit" version="2.6.2" targetFramework="net40" />
</packages> </packages>

@ -69,9 +69,9 @@
<Reference Include="NLog"> <Reference Include="NLog">
<HintPath>..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll</HintPath> <HintPath>..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll</HintPath>
</Reference> </Reference>
<Reference Include="nunit.framework, Version=2.6.0.12051, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL"> <Reference Include="nunit.framework, Version=2.6.2.12296, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\NUnit.2.6.0.12054\lib\nunit.framework.dll</HintPath> <HintPath>..\packages\NUnit.2.6.2\lib\nunit.framework.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />

@ -4,5 +4,5 @@
<package id="FluentAssertions" version="2.0.0.1" targetFramework="net40" /> <package id="FluentAssertions" version="2.0.0.1" targetFramework="net40" />
<package id="Moq" version="4.0.10827" /> <package id="Moq" version="4.0.10827" />
<package id="NLog" version="2.0.0.2000" /> <package id="NLog" version="2.0.0.2000" />
<package id="NUnit" version="2.6.0.12054" /> <package id="NUnit" version="2.6.2" targetFramework="net40" />
</packages> </packages>

@ -87,11 +87,11 @@ namespace NzbDrone.Core.Test.Datastore
[Test] [Test]
public void should_be_able_to_read_unknow_type() public void should_be_able_to_read_unknow_type()
{ {
Db.AsQueryable<UnKnowType>().ToList().Should().BeEmpty(); Db.AsQueryable<UnknownType>().ToList().Should().BeEmpty();
} }
} }
public class UnKnowType public class UnknownType
{ {
[ID] [ID]
public string Id; public string Id;

@ -0,0 +1,34 @@
using System;
using NUnit.Framework;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.Framework
{
public abstract class CoreTest : TestBase
{
protected static ProgressNotification MockNotification
{
get
{
return new ProgressNotification("Mock notification");
}
}
protected static void ThrowException()
{
throw new ApplicationException("This is a message for test exception");
}
}
public abstract class CoreTest<TSubject> : CoreTest
{
[SetUp]
public void CoreTestSetup()
{
Subject = Mocker.Resolve<TSubject>();
}
protected TSubject Subject { get; set; }
}
}

@ -1,29 +0,0 @@
namespace NzbDrone.Core.Test.Framework
{
public abstract class SqlCeTest<TSubject> : SqlCeTest where TSubject : class
{
private TSubject _subject;
protected TSubject Subject
{
get
{
if (_subject == null)
{
_subject = Mocker.Resolve<TSubject>();
}
return _subject;
}
}
protected void InitiateSubject()
{
_subject = Mocker.Resolve<TSubject>();
}
}
}

@ -9,52 +9,6 @@ using PetaPoco;
namespace NzbDrone.Core.Test.Framework namespace NzbDrone.Core.Test.Framework
{ {
public abstract class CoreTest : TestBase
{
protected static ProgressNotification MockNotification
{
get
{
return new ProgressNotification("Mock notification");
}
}
protected static void ThrowException()
{
throw new ApplicationException("This is a message for test exception");
}
}
public abstract class CoreTest<TSubject> : CoreTest
{
private TSubject _subject;
protected TSubject Subject
{
get
{
if (_subject == null)
{
_subject = Mocker.Resolve<TSubject>();
}
return _subject;
}
}
protected void InitiateSubject()
{
_subject = Mocker.Resolve<TSubject>();
}
}
public abstract class SqlCeTest : CoreTest public abstract class SqlCeTest : CoreTest
{ {
private string _dbTemplateName; private string _dbTemplateName;
@ -145,4 +99,31 @@ namespace NzbDrone.Core.Test.Framework
} }
} }
} }
public abstract class SqlCeTest<TSubject> : SqlCeTest where TSubject : class
{
private TSubject _subject;
protected TSubject Subject
{
get
{
if (_subject == null)
{
_subject = Mocker.Resolve<TSubject>();
}
return _subject;
}
}
protected void InitiateSubject()
{
_subject = Mocker.Resolve<TSubject>();
}
}
} }

@ -114,9 +114,9 @@
<Reference Include="NLog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL"> <Reference Include="NLog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll</HintPath> <HintPath>..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll</HintPath>
</Reference> </Reference>
<Reference Include="nunit.framework, Version=2.6.0.12051, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL"> <Reference Include="nunit.framework, Version=2.6.2.12296, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\NUnit.2.6.0.12054\lib\nunit.framework.dll</HintPath> <HintPath>..\packages\NUnit.2.6.2\lib\nunit.framework.dll</HintPath>
</Reference> </Reference>
<Reference Include="Prowlin, Version=0.9.4456.26422, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="Prowlin, Version=0.9.4456.26422, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
@ -147,7 +147,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Datastore\ObjectDatabaseFixture.cs" /> <Compile Include="Datastore\ObjectDatabaseFixture.cs" />
<Compile Include="Framework\CoreTestTSubject.cs" /> <Compile Include="Framework\CoreTest.cs" />
<Compile Include="Framework\ObjectDbTest.cs" /> <Compile Include="Framework\ObjectDbTest.cs" />
<Compile Include="HelperTests\XElementHelperTests\ConvertToTFixture.cs" /> <Compile Include="HelperTests\XElementHelperTests\ConvertToTFixture.cs" />
<Compile Include="IndexerTests\NzbxFixture.cs" /> <Compile Include="IndexerTests\NzbxFixture.cs" />
@ -156,7 +156,7 @@
<Compile Include="ProviderTests\DownloadClientTests\NzbgetProviderTests\DownloadNzbFixture.cs" /> <Compile Include="ProviderTests\DownloadClientTests\NzbgetProviderTests\DownloadNzbFixture.cs" />
<Compile Include="ProviderTests\DownloadClientTests\NzbgetProviderTests\QueueFixture.cs" /> <Compile Include="ProviderTests\DownloadClientTests\NzbgetProviderTests\QueueFixture.cs" />
<Compile Include="ProviderTests\DownloadProviderTests\ContainsRecentEpisode.cs" /> <Compile Include="ProviderTests\DownloadProviderTests\ContainsRecentEpisode.cs" />
<Compile Include="ProviderTests\RootDirProviderTests\FreeSpaceOnDrivesFixture.cs" /> <Compile Include="ProviderTests\RootFolderServiceTests\FreeSpaceOnDrivesFixture.cs" />
<Compile Include="ProviderTests\SearchTests\ProcessResultsFixture.cs" /> <Compile Include="ProviderTests\SearchTests\ProcessResultsFixture.cs" />
<Compile Include="ProviderTests\SearchTests\DailyEpisodeSearchTests\CheckReportFixture.cs" /> <Compile Include="ProviderTests\SearchTests\DailyEpisodeSearchTests\CheckReportFixture.cs" />
<Compile Include="ProviderTests\SearchTests\EpisodeSearchTests\CheckReportFixture.cs" /> <Compile Include="ProviderTests\SearchTests\EpisodeSearchTests\CheckReportFixture.cs" />
@ -257,7 +257,7 @@
<Compile Include="ProviderTests\DecisionEngineTests\AllowedDownloadSpecificationFixture.cs" /> <Compile Include="ProviderTests\DecisionEngineTests\AllowedDownloadSpecificationFixture.cs" />
<Compile Include="ProviderTests\JobProviderTests\JobProviderFixture.cs" /> <Compile Include="ProviderTests\JobProviderTests\JobProviderFixture.cs" />
<Compile Include="QualityTest.cs" /> <Compile Include="QualityTest.cs" />
<Compile Include="ProviderTests\RootDirProviderTests\RootDirProviderFixture.cs" /> <Compile Include="ProviderTests\RootFolderServiceTests\RootFolderServiceFixture.cs" />
<Compile Include="ProviderTests\IndexerProviderTest.cs" /> <Compile Include="ProviderTests\IndexerProviderTest.cs" />
<Compile Include="ProviderTests\HistoryProviderTest.cs" /> <Compile Include="ProviderTests\HistoryProviderTest.cs" />
<Compile Include="ProviderTests\MediaFileProviderTest.cs" /> <Compile Include="ProviderTests\MediaFileProviderTest.cs" />

@ -22,14 +22,14 @@ namespace NzbDrone.Core.Test.ProviderTests.RootDirProviderTests
{ {
[TestFixture] [TestFixture]
// ReSharper disable InconsistentNaming // ReSharper disable InconsistentNaming
public class FreeSpaceOnDrivesFixture : SqlCeTest public class FreeSpaceOnDrivesFixture : CoreTest
{ {
[Test] [Test]
public void should_return_one_drive_when_only_one_root_dir_exists() public void should_return_one_drive_when_only_one_root_dir_exists()
{ {
Mocker.GetMock<IDatabase>() Mocker.GetMock<IRootFolderRepository>()
.Setup(s => s.Fetch<RootDir>()) .Setup(s => s.All())
.Returns(new List<RootDir> { new RootDir { Id = 1, Path = @"C:\Test\TV" } }); .Returns(new List<RootFolder> { new RootFolder { Id = 1, Path = @"C:\Test\TV" } });
Mocker.GetMock<DiskProvider>() Mocker.GetMock<DiskProvider>()
.Setup(s => s.GetPathRoot(@"C:\Test\TV")) .Setup(s => s.GetPathRoot(@"C:\Test\TV"))
@ -47,10 +47,10 @@ namespace NzbDrone.Core.Test.ProviderTests.RootDirProviderTests
[Test] [Test]
public void should_return_one_drive_when_two_rootDirs_on_the_same_drive_exist() public void should_return_one_drive_when_two_rootDirs_on_the_same_drive_exist()
{ {
Mocker.GetMock<IDatabase>() Mocker.GetMock<IRootFolderRepository>()
.Setup(s => s.Fetch<RootDir>()) .Setup(s => s.All())
.Returns(new List<RootDir> { new RootDir { Id = 1, Path = @"C:\Test\TV" }, .Returns(new List<RootFolder> { new RootFolder { Id = 1, Path = @"C:\Test\TV" },
new RootDir { Id = 2, Path = @"C:\Test\TV2" }}); new RootFolder { Id = 2, Path = @"C:\Test\TV2" }});
Mocker.GetMock<DiskProvider>() Mocker.GetMock<DiskProvider>()
.Setup(s => s.GetPathRoot(It.IsAny<String>())) .Setup(s => s.GetPathRoot(It.IsAny<String>()))
@ -68,10 +68,10 @@ namespace NzbDrone.Core.Test.ProviderTests.RootDirProviderTests
[Test] [Test]
public void should_return_two_drives_when_two_rootDirs_on_the_different_drive_exist() public void should_return_two_drives_when_two_rootDirs_on_the_different_drive_exist()
{ {
Mocker.GetMock<IDatabase>() Mocker.GetMock<IRootFolderRepository>()
.Setup(s => s.Fetch<RootDir>()) .Setup(s => s.All())
.Returns(new List<RootDir> { new RootDir { Id = 1, Path = @"C:\Test\TV" }, .Returns(new List<RootFolder> { new RootFolder { Id = 1, Path = @"C:\Test\TV" },
new RootDir { Id = 2, Path = @"D:\Test\TV" }}); new RootFolder { Id = 2, Path = @"D:\Test\TV" }});
Mocker.GetMock<DiskProvider>() Mocker.GetMock<DiskProvider>()
.Setup(s => s.GetPathRoot(@"C:\Test\TV")) .Setup(s => s.GetPathRoot(@"C:\Test\TV"))
@ -93,9 +93,9 @@ namespace NzbDrone.Core.Test.ProviderTests.RootDirProviderTests
[Test] [Test]
public void should_skip_rootDir_if_not_found_on_disk() public void should_skip_rootDir_if_not_found_on_disk()
{ {
Mocker.GetMock<IDatabase>() Mocker.GetMock<IRootFolderRepository>()
.Setup(s => s.Fetch<RootDir>()) .Setup(s => s.All())
.Returns(new List<RootDir> { new RootDir { Id = 1, Path = @"C:\Test\TV" } }); .Returns(new List<RootFolder> { new RootFolder { Id = 1, Path = @"C:\Test\TV" } });
Mocker.GetMock<DiskProvider>() Mocker.GetMock<DiskProvider>()
.Setup(s => s.GetPathRoot(@"C:\Test\TV")) .Setup(s => s.GetPathRoot(@"C:\Test\TV"))

@ -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" }));
} }
} }
} }

@ -11,7 +11,7 @@
<package id="NCrunch.Framework" version="1.43.0.23" targetFramework="net40" /> <package id="NCrunch.Framework" version="1.43.0.23" targetFramework="net40" />
<package id="Newtonsoft.Json" version="4.5.11" targetFramework="net40" /> <package id="Newtonsoft.Json" version="4.5.11" targetFramework="net40" />
<package id="NLog" version="2.0.0.2000" /> <package id="NLog" version="2.0.0.2000" />
<package id="NUnit" version="2.6.0.12054" /> <package id="NUnit" version="2.6.2" targetFramework="net40" />
<package id="Prowlin" version="0.9.4456.26422" targetFramework="net40" /> <package id="Prowlin" version="0.9.4456.26422" targetFramework="net40" />
<package id="SignalR.Server" version="0.5.3" targetFramework="net40" /> <package id="SignalR.Server" version="0.5.3" targetFramework="net40" />
<package id="Unity" version="2.1.505.2" targetFramework="net40" /> <package id="Unity" version="2.1.505.2" targetFramework="net40" />

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Eloquera.Client;
namespace NzbDrone.Core.Datastore
{
public abstract class BaseRepositoryModel
{
[ID]
public int Id;
}
}

@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Datastore
{
public interface IBasicRepository<TModel>
{
List<TModel> All();
TModel Get(int rootFolderId);
TModel Add(TModel rootFolder);
void Delete(int rootFolderId);
}
public abstract class BasicRepository<TModel> : IBasicRepository<TModel> where TModel : BaseRepositoryModel, new()
{
public BasicRepository(EloqueraDb eloqueraDb)
{
EloqueraDb = eloqueraDb;
}
protected EloqueraDb EloqueraDb { get; private set; }
public List<TModel> All()
{
return EloqueraDb.AsQueryable<TModel>().ToList();
}
public TModel Get(int rootFolderId)
{
return EloqueraDb.AsQueryable<TModel>().Single(c => c.Id == rootFolderId);
}
public TModel Add(TModel rootFolder)
{
return EloqueraDb.Insert(rootFolder);
}
public void Delete(int rootFolderId)
{
var itemToDelete = Get(rootFolderId);
EloqueraDb.Delete(itemToDelete);
}
}
}

@ -18,10 +18,10 @@ namespace NzbDrone.Core.Datastore.Migrations
using (var dataReader = Database.ExecuteQuery("SELECT * from RootDirs")) using (var dataReader = Database.ExecuteQuery("SELECT * from RootDirs"))
{ {
var dirs = new List<RootDir>(); var dirs = new List<RootFolder>();
while (dataReader.Read()) while (dataReader.Read())
{ {
var rootFolder = new RootDir { Path = dataReader["Path"].ToString() }; var rootFolder = new RootFolder { Path = dataReader["Path"].ToString() };
dirs.Add(rootFolder); dirs.Add(rootFolder);
} }
objectDb.InsertMany(dirs); objectDb.InsertMany(dirs);

@ -231,6 +231,8 @@
</Compile> </Compile>
<Compile Include="Constants.cs" /> <Compile Include="Constants.cs" />
<Compile Include="ContainerExtentions.cs" /> <Compile Include="ContainerExtentions.cs" />
<Compile Include="Datastore\BaseRepositoryModel.cs" />
<Compile Include="Datastore\BasicRepository.cs" />
<Compile Include="Datastore\ConnectionFactory.cs" /> <Compile Include="Datastore\ConnectionFactory.cs" />
<Compile Include="Datastore\EloqueraDb.cs" /> <Compile Include="Datastore\EloqueraDb.cs" />
<Compile Include="Datastore\EloqueraDbFactory.cs" /> <Compile Include="Datastore\EloqueraDbFactory.cs" />
@ -595,7 +597,7 @@
<Compile Include="Repository\Config.cs" /> <Compile Include="Repository\Config.cs" />
<Compile Include="Repository\Quality\QualityType.cs" /> <Compile Include="Repository\Quality\QualityType.cs" />
<Compile Include="Repository\Quality\QualityProfile.cs" /> <Compile Include="Repository\Quality\QualityProfile.cs" />
<Compile Include="Repository\RootDir.cs" /> <Compile Include="RootFolders\RootFolder.cs" />
<Compile Include="Repository\SceneMapping.cs" /> <Compile Include="Repository\SceneMapping.cs" />
<Compile Include="Repository\Series.cs" /> <Compile Include="Repository\Series.cs" />
<Compile Include="CentralDispatch.cs" /> <Compile Include="CentralDispatch.cs" />

@ -1,13 +1,13 @@
using System.Collections.Generic; using System.Collections.Generic;
using NzbDrone.Core.RootFolders; using NzbDrone.Core.Datastore;
using PetaPoco; using PetaPoco;
namespace NzbDrone.Core.Repository namespace NzbDrone.Core.RootFolders
{ {
[TableName("RootDirs")] [TableName("RootDirs")]
[PrimaryKey("Id", autoIncrement = true)] [PrimaryKey("Id", autoIncrement = true)]
public class RootDir : BaseModel public class RootFolder : BaseRepositoryModel
{ {
public string Path { get; set; } public string Path { get; set; }

@ -6,64 +6,14 @@ using System.Linq;
namespace NzbDrone.Core.RootFolders namespace NzbDrone.Core.RootFolders
{ {
public interface IRootFolderRepository : IBasicRepository<RootFolder>
public abstract class BaseModel
{
[ID]
public int Id;
}
public interface IBasicRepository<TModel>
{
List<TModel> All();
TModel Get(int rootFolderId);
TModel Add(TModel rootFolder);
void Delete(int rootFolderId);
}
public abstract class BasicRepository<TModel> : IBasicRepository<TModel> where TModel : BaseModel, new()
{
public BasicRepository(EloqueraDb eloqueraDb)
{
EloqueraDb = eloqueraDb;
}
protected EloqueraDb EloqueraDb { get; private set; }
public List<TModel> All()
{
return EloqueraDb.AsQueryable<TModel>().ToList();
}
public TModel Get(int rootFolderId)
{
return EloqueraDb.AsQueryable<TModel>().Single(c => c.Id == rootFolderId);
}
public TModel Add(TModel rootFolder)
{
return EloqueraDb.Insert(rootFolder);
}
public void Delete(int rootFolderId)
{
var itemToDelete = Get(rootFolderId);
EloqueraDb.Delete(itemToDelete);
}
}
public interface IRootFolderRepository : IBasicRepository<RootDir>
{ {
} }
//This way we only need to implement none_custom methods for repos, like custom queries etc... rest is done automagically. //This way we only need to implement none_custom methods for repos, like custom queries etc... rest is done automagically.
public class RootFolderRepository : BasicRepository<RootDir>, IRootFolderRepository public class RootFolderRepository : BasicRepository<RootFolder>, IRootFolderRepository
{ {
public RootFolderRepository(EloqueraDb eloqueraDb) public RootFolderRepository(EloqueraDb eloqueraDb)
: base(eloqueraDb) : base(eloqueraDb)

@ -11,8 +11,8 @@ namespace NzbDrone.Core.RootFolders
{ {
public interface IRootFolderService public interface IRootFolderService
{ {
List<RootDir> All(); List<RootFolder> All();
RootDir Add(RootDir rootDir); RootFolder Add(RootFolder rootDir);
void Remove(int rootDirId); void Remove(int rootDirId);
List<String> GetUnmappedFolders(string path); List<String> GetUnmappedFolders(string path);
Dictionary<string, ulong> FreeSpaceOnDrives(); Dictionary<string, ulong> FreeSpaceOnDrives();
@ -32,12 +32,12 @@ namespace NzbDrone.Core.RootFolders
_seriesProvider = seriesProvider; _seriesProvider = seriesProvider;
} }
public virtual List<RootDir> All() public virtual List<RootFolder> All()
{ {
return _rootFolderRepository.All(); return _rootFolderRepository.All();
} }
public virtual RootDir Add(RootDir rootDir) public virtual RootFolder Add(RootFolder rootDir)
{ {
if (String.IsNullOrWhiteSpace(rootDir.Path) || !Path.IsPathRooted(rootDir.Path)) if (String.IsNullOrWhiteSpace(rootDir.Path) || !Path.IsPathRooted(rootDir.Path))
throw new ArgumentException("Invalid path"); throw new ArgumentException("Invalid path");

@ -14,7 +14,7 @@
<RootNamespace>NzbDrone.Services.Api</RootNamespace> <RootNamespace>NzbDrone.Services.Api</RootNamespace>
<AssemblyName>NzbDrone.Services.Api</AssemblyName> <AssemblyName>NzbDrone.Services.Api</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<UseIISExpress>false</UseIISExpress> <UseIISExpress>true</UseIISExpress>
<IISExpressSSLPort /> <IISExpressSSLPort />
<IISExpressAnonymousAuthentication /> <IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication /> <IISExpressWindowsAuthentication />
@ -152,7 +152,7 @@
<AutoAssignPort>True</AutoAssignPort> <AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>1306</DevelopmentServerPort> <DevelopmentServerPort>1306</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath> <DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost/NzbDrone.Services.Api</IISUrl> <IISUrl>http://localhost:1306/</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication> <NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer> <UseCustomServer>False</UseCustomServer>
<CustomServerUrl> <CustomServerUrl>

@ -74,9 +74,9 @@
<Reference Include="NLog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL"> <Reference Include="NLog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll</HintPath> <HintPath>..\..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll</HintPath>
</Reference> </Reference>
<Reference Include="nunit.framework, Version=2.6.0.12051, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL"> <Reference Include="nunit.framework, Version=2.6.2.12296, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\NUnit.2.6.0.12054\lib\nunit.framework.dll</HintPath> <HintPath>..\..\packages\NUnit.2.6.2\lib\nunit.framework.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.configuration" /> <Reference Include="System.configuration" />

@ -4,5 +4,5 @@
<package id="Moq" version="4.0.10827" /> <package id="Moq" version="4.0.10827" />
<package id="NBuilder" version="3.0.1.1" /> <package id="NBuilder" version="3.0.1.1" />
<package id="NLog" version="2.0.0.2000" /> <package id="NLog" version="2.0.0.2000" />
<package id="NUnit" version="2.6.0.12054" /> <package id="NUnit" version="2.6.2" targetFramework="net40" />
</packages> </packages>

@ -70,9 +70,9 @@
<Reference Include="NLog"> <Reference Include="NLog">
<HintPath>..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll</HintPath> <HintPath>..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll</HintPath>
</Reference> </Reference>
<Reference Include="nunit.framework, Version=2.6.0.12051, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL"> <Reference Include="nunit.framework, Version=2.6.2.12296, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\NUnit.2.6.0.12054\lib\nunit.framework.dll</HintPath> <HintPath>..\packages\NUnit.2.6.2\lib\nunit.framework.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />

@ -12,7 +12,6 @@ namespace NzbDrone.Test.Common
{ {
protected const string INTEGRATION_TEST = "Integration Test"; protected const string INTEGRATION_TEST = "Integration Test";
private AutoMoqer _mocker; private AutoMoqer _mocker;
protected AutoMoqer Mocker protected AutoMoqer Mocker
{ {
@ -29,7 +28,6 @@ namespace NzbDrone.Test.Common
protected Mock<RestProvider> MockedRestProvider { get; private set; } protected Mock<RestProvider> MockedRestProvider { get; private set; }
private string VirtualPath private string VirtualPath
{ {
get get
@ -41,7 +39,6 @@ namespace NzbDrone.Test.Common
} }
} }
protected string TempFolder { get; private set; } protected string TempFolder { get; private set; }
[SetUp] [SetUp]
@ -83,7 +80,6 @@ namespace NzbDrone.Test.Common
_mocker = new AutoMoqer(MockBehavior.Strict); _mocker = new AutoMoqer(MockBehavior.Strict);
} }
protected void WithTempAsAppPath() protected void WithTempAsAppPath()
{ {
Mocker.GetMock<EnvironmentProvider>() Mocker.GetMock<EnvironmentProvider>()

@ -3,6 +3,6 @@
<package id="CommonServiceLocator" version="1.0" /> <package id="CommonServiceLocator" version="1.0" />
<package id="Moq" version="4.0.10827" /> <package id="Moq" version="4.0.10827" />
<package id="NLog" version="2.0.0.2000" /> <package id="NLog" version="2.0.0.2000" />
<package id="NUnit" version="2.6.0.12054" /> <package id="NUnit" version="2.6.2" targetFramework="net40" />
<package id="Unity" version="2.1.505.2" targetFramework="net40" /> <package id="Unity" version="2.1.505.2" targetFramework="net40" />
</packages> </packages>

@ -53,9 +53,9 @@
<Reference Include="NLog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL"> <Reference Include="NLog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll</HintPath> <HintPath>..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll</HintPath>
</Reference> </Reference>
<Reference Include="nunit.framework, Version=2.6.0.12051, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL"> <Reference Include="nunit.framework, Version=2.6.2.12296, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\NUnit.2.6.0.12054\lib\nunit.framework.dll</HintPath> <HintPath>..\packages\NUnit.2.6.2\lib\nunit.framework.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />

@ -3,5 +3,5 @@
<package id="FluentAssertions" version="2.0.0.1" targetFramework="net40" /> <package id="FluentAssertions" version="2.0.0.1" targetFramework="net40" />
<package id="Moq" version="4.0.10827" /> <package id="Moq" version="4.0.10827" />
<package id="NBuilder" version="3.0.1.1" /> <package id="NBuilder" version="3.0.1.1" />
<package id="NUnit" version="2.6.0.12054" /> <package id="NUnit" version="2.6.2" targetFramework="net40" />
</packages> </packages>

@ -64,7 +64,7 @@
<HintPath>..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll</HintPath> <HintPath>..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference> </Reference>
<Reference Include="nunit.framework"> <Reference Include="nunit.framework">
<HintPath>..\packages\NUnit.2.6.0.12054\lib\nunit.framework.dll</HintPath> <HintPath>..\packages\NUnit.2.6.2\lib\nunit.framework.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />

@ -3,6 +3,6 @@
<package id="DotNetZip" version="1.9.1.8" /> <package id="DotNetZip" version="1.9.1.8" />
<package id="FluentAssertions" version="2.0.0.1" targetFramework="net40" /> <package id="FluentAssertions" version="2.0.0.1" targetFramework="net40" />
<package id="Newtonsoft.Json" version="4.5.11" targetFramework="net40" /> <package id="Newtonsoft.Json" version="4.5.11" targetFramework="net40" />
<package id="NUnit" version="2.6.0.12054" /> <package id="NUnit" version="2.6.2" targetFramework="net40" />
<package id="Selenium.WebDriver" version="2.25.1" targetFramework="net40" /> <package id="Selenium.WebDriver" version="2.25.1" targetFramework="net40" />
</packages> </packages>

@ -2,7 +2,6 @@
<FileVersion>1</FileVersion> <FileVersion>1</FileVersion>
<AutoEnableOnStartup>True</AutoEnableOnStartup> <AutoEnableOnStartup>True</AutoEnableOnStartup>
<AllowParallelTestExecution>true</AllowParallelTestExecution> <AllowParallelTestExecution>true</AllowParallelTestExecution>
<AllowTestsToRunInParallelWithThemselves>true</AllowTestsToRunInParallelWithThemselves>
<FrameworkUtilisationTypeForNUnit>UseDynamicAnalysis</FrameworkUtilisationTypeForNUnit> <FrameworkUtilisationTypeForNUnit>UseDynamicAnalysis</FrameworkUtilisationTypeForNUnit>
<FrameworkUtilisationTypeForGallio>Disabled</FrameworkUtilisationTypeForGallio> <FrameworkUtilisationTypeForGallio>Disabled</FrameworkUtilisationTypeForGallio>
<FrameworkUtilisationTypeForMSpec>Disabled</FrameworkUtilisationTypeForMSpec> <FrameworkUtilisationTypeForMSpec>Disabled</FrameworkUtilisationTypeForMSpec>

Loading…
Cancel
Save