From 7ed148b12c2bb3304009baa07bbd3ce29dc8159b Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Mon, 4 Feb 2013 20:07:07 -0800 Subject: [PATCH] Fixed most of the broken tests --- NzbDrone.Api/RootFolders/RootFolderModule.cs | 2 +- NzbDrone.App.Test/NzbDrone.App.Test.csproj | 4 +- NzbDrone.App.Test/packages.config | 2 +- .../NzbDrone.Common.Test.csproj | 4 +- NzbDrone.Common.Test/packages.config | 2 +- .../Datastore/ObjectDatabaseFixture.cs | 202 +++++++++--------- NzbDrone.Core.Test/Framework/CoreTest.cs | 34 +++ .../Framework/CoreTestTSubject.cs | 29 --- NzbDrone.Core.Test/Framework/SqlCeTest.cs | 73 +++---- NzbDrone.Core.Test/NzbDrone.Core.Test.csproj | 10 +- .../FreeSpaceOnDrivesFixture.cs | 30 +-- .../RootFolderServiceFixture.cs} | 28 +-- NzbDrone.Core.Test/packages.config | 2 +- .../Datastore/BaseRepositoryModel.cs | 14 ++ NzbDrone.Core/Datastore/BasicRepository.cs | 47 ++++ .../Datastore/Migrations/Migration20130203.cs | 4 +- NzbDrone.Core/NzbDrone.Core.csproj | 4 +- .../RootDir.cs => RootFolders/RootFolder.cs} | 6 +- .../RootFolders/RootFolderRepository.cs | 54 +---- .../RootFolders/RootFolderService.cs | 8 +- .../NzbDrone.Services.Api.csproj | 4 +- .../NzbDrone.Services.Tests.csproj | 4 +- .../NzbDrone.Services.Tests/packages.config | 2 +- .../NzbDrone.Test.Common.csproj | 4 +- NzbDrone.Test.Common/TestBase.cs | 4 - NzbDrone.Test.Common/packages.config | 2 +- .../NzbDrone.Update.Test.csproj | 4 +- NzbDrone.Update.Test/packages.config | 2 +- .../NzbDrone.Web.UI.Automation.csproj | 2 +- NzbDrone.Web.UI.Test/packages.config | 2 +- NzbDrone.ncrunchsolution | 1 - 31 files changed, 293 insertions(+), 297 deletions(-) create mode 100644 NzbDrone.Core.Test/Framework/CoreTest.cs delete mode 100644 NzbDrone.Core.Test/Framework/CoreTestTSubject.cs rename NzbDrone.Core.Test/ProviderTests/{RootDirProviderTests => RootFolderServiceTests}/FreeSpaceOnDrivesFixture.cs (74%) rename NzbDrone.Core.Test/ProviderTests/{RootDirProviderTests/RootDirProviderFixture.cs => RootFolderServiceTests/RootFolderServiceFixture.cs} (79%) create mode 100644 NzbDrone.Core/Datastore/BaseRepositoryModel.cs create mode 100644 NzbDrone.Core/Datastore/BasicRepository.cs rename NzbDrone.Core/{Repository/RootDir.cs => RootFolders/RootFolder.cs} (73%) diff --git a/NzbDrone.Api/RootFolders/RootFolderModule.cs b/NzbDrone.Api/RootFolders/RootFolderModule.cs index 46c39dd3a..ed44fe195 100644 --- a/NzbDrone.Api/RootFolders/RootFolderModule.cs +++ b/NzbDrone.Api/RootFolders/RootFolderModule.cs @@ -23,7 +23,7 @@ namespace NzbDrone.Api.RootFolders private Response AddRootFolder() { - var dir = _rootFolderService.Add(Request.Body.FromJson()); + var dir = _rootFolderService.Add(Request.Body.FromJson()); return dir.AsResponse(HttpStatusCode.Created); } diff --git a/NzbDrone.App.Test/NzbDrone.App.Test.csproj b/NzbDrone.App.Test/NzbDrone.App.Test.csproj index 1d78377b4..8a49860c0 100644 --- a/NzbDrone.App.Test/NzbDrone.App.Test.csproj +++ b/NzbDrone.App.Test/NzbDrone.App.Test.csproj @@ -72,9 +72,9 @@ ..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll - + False - ..\packages\NUnit.2.6.0.12054\lib\nunit.framework.dll + ..\packages\NUnit.2.6.2\lib\nunit.framework.dll diff --git a/NzbDrone.App.Test/packages.config b/NzbDrone.App.Test/packages.config index 7fe15cba5..d78223afa 100644 --- a/NzbDrone.App.Test/packages.config +++ b/NzbDrone.App.Test/packages.config @@ -5,5 +5,5 @@ - + \ No newline at end of file diff --git a/NzbDrone.Common.Test/NzbDrone.Common.Test.csproj b/NzbDrone.Common.Test/NzbDrone.Common.Test.csproj index cf8f13cc0..74af0762e 100644 --- a/NzbDrone.Common.Test/NzbDrone.Common.Test.csproj +++ b/NzbDrone.Common.Test/NzbDrone.Common.Test.csproj @@ -69,9 +69,9 @@ ..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll - + False - ..\packages\NUnit.2.6.0.12054\lib\nunit.framework.dll + ..\packages\NUnit.2.6.2\lib\nunit.framework.dll diff --git a/NzbDrone.Common.Test/packages.config b/NzbDrone.Common.Test/packages.config index 9eebdc51e..1ed33377b 100644 --- a/NzbDrone.Common.Test/packages.config +++ b/NzbDrone.Common.Test/packages.config @@ -4,5 +4,5 @@ - + \ No newline at end of file diff --git a/NzbDrone.Core.Test/Datastore/ObjectDatabaseFixture.cs b/NzbDrone.Core.Test/Datastore/ObjectDatabaseFixture.cs index cadc86a33..25dac579e 100644 --- a/NzbDrone.Core.Test/Datastore/ObjectDatabaseFixture.cs +++ b/NzbDrone.Core.Test/Datastore/ObjectDatabaseFixture.cs @@ -1,101 +1,101 @@ -using System.Linq; -using Eloquera.Client; -using FizzWare.NBuilder; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Repository; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.Datastore -{ - [TestFixture] - public class ObjectDatabaseFixture : ObjectDbTest - { - private Series testSeries; - private Episode testEpisode; - - - [SetUp] - public void SetUp() - { - WithObjectDb(); - - testSeries = Builder.CreateNew().Build(); - testEpisode = Builder.CreateNew().Build(); - - - } - - [Test] - public void should_be_able_to_write_to_database() - { - Db.Insert(testSeries); - - Db.AsQueryable().Should().HaveCount(1); - - } - - [Test] - public void should_not_store_dirty_data_in_cache() - { - Db.Insert(testEpisode); - - Db.AsQueryable().Single().Series.Should().BeNull(); - - testEpisode.Series = Builder.CreateNew().Build(); - - Db.AsQueryable().Single().Series.Should().BeNull(); - } - - - - [Test] - public void should_store_nested_objects() - { - testEpisode.Series = testSeries; - - Db.Insert(testEpisode); - - Db.AsQueryable().Should().HaveCount(1); - Db.AsQueryable().Single().Series.Should().NotBeNull(); - } - - [Test] - public void should_update_nested_objects() - { - testEpisode.Series = Builder.CreateNew().Build(); - - Db.Insert(testEpisode); - - testEpisode.Series.Title = "UpdatedTitle"; - - Db.Update(testEpisode); - - Db.AsQueryable().Should().HaveCount(1); - Db.AsQueryable().Single().Series.Should().NotBeNull(); - Db.AsQueryable().Single().Series.Title.Should().Be("UpdatedTitle"); - } - - - [Test] - public void new_objects_should_get_id() - { - Db.Insert(testSeries); - testSeries.Id.Should().NotBe(0); - } - - [Test] - public void should_be_able_to_read_unknow_type() - { - Db.AsQueryable().ToList().Should().BeEmpty(); - } - } - - public class UnKnowType - { - [ID] - public string Id; - public string Field1 { get; set; } - } -} - +using System.Linq; +using Eloquera.Client; +using FizzWare.NBuilder; +using FluentAssertions; +using NUnit.Framework; +using NzbDrone.Core.Repository; +using NzbDrone.Core.Test.Framework; + +namespace NzbDrone.Core.Test.Datastore +{ + [TestFixture] + public class ObjectDatabaseFixture : ObjectDbTest + { + private Series testSeries; + private Episode testEpisode; + + + [SetUp] + public void SetUp() + { + WithObjectDb(); + + testSeries = Builder.CreateNew().Build(); + testEpisode = Builder.CreateNew().Build(); + + + } + + [Test] + public void should_be_able_to_write_to_database() + { + Db.Insert(testSeries); + + Db.AsQueryable().Should().HaveCount(1); + + } + + [Test] + public void should_not_store_dirty_data_in_cache() + { + Db.Insert(testEpisode); + + Db.AsQueryable().Single().Series.Should().BeNull(); + + testEpisode.Series = Builder.CreateNew().Build(); + + Db.AsQueryable().Single().Series.Should().BeNull(); + } + + + + [Test] + public void should_store_nested_objects() + { + testEpisode.Series = testSeries; + + Db.Insert(testEpisode); + + Db.AsQueryable().Should().HaveCount(1); + Db.AsQueryable().Single().Series.Should().NotBeNull(); + } + + [Test] + public void should_update_nested_objects() + { + testEpisode.Series = Builder.CreateNew().Build(); + + Db.Insert(testEpisode); + + testEpisode.Series.Title = "UpdatedTitle"; + + Db.Update(testEpisode); + + Db.AsQueryable().Should().HaveCount(1); + Db.AsQueryable().Single().Series.Should().NotBeNull(); + Db.AsQueryable().Single().Series.Title.Should().Be("UpdatedTitle"); + } + + + [Test] + public void new_objects_should_get_id() + { + Db.Insert(testSeries); + testSeries.Id.Should().NotBe(0); + } + + [Test] + public void should_be_able_to_read_unknow_type() + { + Db.AsQueryable().ToList().Should().BeEmpty(); + } + } + + public class UnknownType + { + [ID] + public string Id; + public string Field1 { get; set; } + } +} + diff --git a/NzbDrone.Core.Test/Framework/CoreTest.cs b/NzbDrone.Core.Test/Framework/CoreTest.cs new file mode 100644 index 000000000..368fd84e4 --- /dev/null +++ b/NzbDrone.Core.Test/Framework/CoreTest.cs @@ -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 : CoreTest + { + [SetUp] + public void CoreTestSetup() + { + Subject = Mocker.Resolve(); + } + + protected TSubject Subject { get; set; } + } +} diff --git a/NzbDrone.Core.Test/Framework/CoreTestTSubject.cs b/NzbDrone.Core.Test/Framework/CoreTestTSubject.cs deleted file mode 100644 index 00793cba1..000000000 --- a/NzbDrone.Core.Test/Framework/CoreTestTSubject.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace NzbDrone.Core.Test.Framework -{ - public abstract class SqlCeTest : SqlCeTest where TSubject : class - { - - private TSubject _subject; - - - protected TSubject Subject - { - get - { - if (_subject == null) - { - _subject = Mocker.Resolve(); - } - - return _subject; - - } - } - - - protected void InitiateSubject() - { - _subject = Mocker.Resolve(); - } - } -} diff --git a/NzbDrone.Core.Test/Framework/SqlCeTest.cs b/NzbDrone.Core.Test/Framework/SqlCeTest.cs index 89bf44cda..7a782ff41 100644 --- a/NzbDrone.Core.Test/Framework/SqlCeTest.cs +++ b/NzbDrone.Core.Test/Framework/SqlCeTest.cs @@ -9,52 +9,6 @@ using PetaPoco; 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 : CoreTest - { - private TSubject _subject; - - - protected TSubject Subject - { - get - { - if (_subject == null) - { - _subject = Mocker.Resolve(); - } - - return _subject; - - } - } - - - protected void InitiateSubject() - { - _subject = Mocker.Resolve(); - } - } - - public abstract class SqlCeTest : CoreTest { private string _dbTemplateName; @@ -145,4 +99,31 @@ namespace NzbDrone.Core.Test.Framework } } } + + public abstract class SqlCeTest : SqlCeTest where TSubject : class + { + + private TSubject _subject; + + + protected TSubject Subject + { + get + { + if (_subject == null) + { + _subject = Mocker.Resolve(); + } + + return _subject; + + } + } + + + protected void InitiateSubject() + { + _subject = Mocker.Resolve(); + } + } } diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index 33e889883..473d5a61e 100644 --- a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -114,9 +114,9 @@ ..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll - + False - ..\packages\NUnit.2.6.0.12054\lib\nunit.framework.dll + ..\packages\NUnit.2.6.2\lib\nunit.framework.dll False @@ -147,7 +147,7 @@ - + @@ -156,7 +156,7 @@ - + @@ -257,7 +257,7 @@ - + diff --git a/NzbDrone.Core.Test/ProviderTests/RootDirProviderTests/FreeSpaceOnDrivesFixture.cs b/NzbDrone.Core.Test/ProviderTests/RootFolderServiceTests/FreeSpaceOnDrivesFixture.cs similarity index 74% rename from NzbDrone.Core.Test/ProviderTests/RootDirProviderTests/FreeSpaceOnDrivesFixture.cs rename to NzbDrone.Core.Test/ProviderTests/RootFolderServiceTests/FreeSpaceOnDrivesFixture.cs index fb5902d53..1c6d60edf 100644 --- a/NzbDrone.Core.Test/ProviderTests/RootDirProviderTests/FreeSpaceOnDrivesFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/RootFolderServiceTests/FreeSpaceOnDrivesFixture.cs @@ -22,14 +22,14 @@ namespace NzbDrone.Core.Test.ProviderTests.RootDirProviderTests { [TestFixture] // ReSharper disable InconsistentNaming - public class FreeSpaceOnDrivesFixture : SqlCeTest + public class FreeSpaceOnDrivesFixture : CoreTest { [Test] public void should_return_one_drive_when_only_one_root_dir_exists() { - Mocker.GetMock() - .Setup(s => s.Fetch()) - .Returns(new List { new RootDir { Id = 1, Path = @"C:\Test\TV" } }); + Mocker.GetMock() + .Setup(s => s.All()) + .Returns(new List { new RootFolder { Id = 1, Path = @"C:\Test\TV" } }); Mocker.GetMock() .Setup(s => s.GetPathRoot(@"C:\Test\TV")) @@ -47,10 +47,10 @@ namespace NzbDrone.Core.Test.ProviderTests.RootDirProviderTests [Test] public void should_return_one_drive_when_two_rootDirs_on_the_same_drive_exist() { - Mocker.GetMock() - .Setup(s => s.Fetch()) - .Returns(new List { new RootDir { Id = 1, Path = @"C:\Test\TV" }, - new RootDir { Id = 2, Path = @"C:\Test\TV2" }}); + Mocker.GetMock() + .Setup(s => s.All()) + .Returns(new List { new RootFolder { Id = 1, Path = @"C:\Test\TV" }, + new RootFolder { Id = 2, Path = @"C:\Test\TV2" }}); Mocker.GetMock() .Setup(s => s.GetPathRoot(It.IsAny())) @@ -68,10 +68,10 @@ namespace NzbDrone.Core.Test.ProviderTests.RootDirProviderTests [Test] public void should_return_two_drives_when_two_rootDirs_on_the_different_drive_exist() { - Mocker.GetMock() - .Setup(s => s.Fetch()) - .Returns(new List { new RootDir { Id = 1, Path = @"C:\Test\TV" }, - new RootDir { Id = 2, Path = @"D:\Test\TV" }}); + Mocker.GetMock() + .Setup(s => s.All()) + .Returns(new List { new RootFolder { Id = 1, Path = @"C:\Test\TV" }, + new RootFolder { Id = 2, Path = @"D:\Test\TV" }}); Mocker.GetMock() .Setup(s => s.GetPathRoot(@"C:\Test\TV")) @@ -93,9 +93,9 @@ namespace NzbDrone.Core.Test.ProviderTests.RootDirProviderTests [Test] public void should_skip_rootDir_if_not_found_on_disk() { - Mocker.GetMock() - .Setup(s => s.Fetch()) - .Returns(new List { new RootDir { Id = 1, Path = @"C:\Test\TV" } }); + Mocker.GetMock() + .Setup(s => s.All()) + .Returns(new List { new RootFolder { Id = 1, Path = @"C:\Test\TV" } }); Mocker.GetMock() .Setup(s => s.GetPathRoot(@"C:\Test\TV")) diff --git a/NzbDrone.Core.Test/ProviderTests/RootDirProviderTests/RootDirProviderFixture.cs b/NzbDrone.Core.Test/ProviderTests/RootFolderServiceTests/RootFolderServiceFixture.cs similarity index 79% rename from NzbDrone.Core.Test/ProviderTests/RootDirProviderTests/RootDirProviderFixture.cs rename to NzbDrone.Core.Test/ProviderTests/RootFolderServiceTests/RootFolderServiceFixture.cs index 111ac0ade..ab231306c 100644 --- a/NzbDrone.Core.Test/ProviderTests/RootDirProviderTests/RootDirProviderFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/RootFolderServiceTests/RootFolderServiceFixture.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; - using FluentAssertions; using Moq; using NUnit.Framework; @@ -16,18 +15,22 @@ using NzbDrone.Core.RootFolders; using NzbDrone.Core.Test.Framework; using NzbDrone.Test.Common.AutoMoq; -namespace NzbDrone.Core.Test.ProviderTests.RootDirProviderTests +namespace NzbDrone.Core.Test.ProviderTests.RootFolderServiceTests { [TestFixture] // ReSharper disable InconsistentNaming - public class RootDirProviderFixture : CoreTest + public class RootFolderServiceFixture : CoreTest { [SetUp] public void Setup() { Mocker.GetMock() - .Setup(m => m.FolderExists(It.IsAny())) - .Returns(true); + .Setup(m => m.FolderExists(It.IsAny())) + .Returns(true); + + Mocker.GetMock() + .Setup(s => s.All()) + .Returns(new List()); } private void WithNoneExistingFolder() @@ -37,12 +40,12 @@ namespace NzbDrone.Core.Test.ProviderTests.RootDirProviderTests .Returns(false); } - [TestCase("D:\\TV Shows\\")] [TestCase("//server//folder")] 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); Mocker.GetMock().Verify(c => c.Add(root), Times.Once()); @@ -53,7 +56,7 @@ namespace NzbDrone.Core.Test.ProviderTests.RootDirProviderTests { WithNoneExistingFolder(); - Assert.Throws(() => Subject.Add(new RootDir { Path = "C:\\TEST" })); + Assert.Throws(() => Subject.Add(new RootFolder { Path = "C:\\TEST" })); } [Test] @@ -67,7 +70,7 @@ namespace NzbDrone.Core.Test.ProviderTests.RootDirProviderTests { WithNoneExistingFolder(); - Mocker.GetMock().Setup(c => c.All()).Returns(new List()); + Mocker.GetMock().Setup(c => c.All()).Returns(new List()); 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) { Assert.Throws(() => - Mocker.Resolve().Add(new RootDir { Id = 0, Path = path }) + Mocker.Resolve().Add(new RootFolder { Id = 0, Path = path }) ); } [Test] public void adding_duplicated_root_folder_should_throw() { - Mocker.GetMock().Setup(c => c.All()).Returns(new List { new RootDir { Path = "C:\\TV" } }); + Mocker.GetMock().Setup(c => c.All()).Returns(new List { new RootFolder { Path = "C:\\TV" } }); - Subject.Add(new RootDir { Path = @"C:\TV" }); - Assert.Throws(() => Subject.Add(new RootDir { Path = @"C:\TV" })); + Assert.Throws(() => Subject.Add(new RootFolder { Path = @"C:\TV" })); } } } \ No newline at end of file diff --git a/NzbDrone.Core.Test/packages.config b/NzbDrone.Core.Test/packages.config index bce8f8a52..659d8cc59 100644 --- a/NzbDrone.Core.Test/packages.config +++ b/NzbDrone.Core.Test/packages.config @@ -11,7 +11,7 @@ - + diff --git a/NzbDrone.Core/Datastore/BaseRepositoryModel.cs b/NzbDrone.Core/Datastore/BaseRepositoryModel.cs new file mode 100644 index 000000000..e7133afd4 --- /dev/null +++ b/NzbDrone.Core/Datastore/BaseRepositoryModel.cs @@ -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; + } +} diff --git a/NzbDrone.Core/Datastore/BasicRepository.cs b/NzbDrone.Core/Datastore/BasicRepository.cs new file mode 100644 index 000000000..e280dffb6 --- /dev/null +++ b/NzbDrone.Core/Datastore/BasicRepository.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace NzbDrone.Core.Datastore +{ + public interface IBasicRepository + { + List All(); + TModel Get(int rootFolderId); + TModel Add(TModel rootFolder); + void Delete(int rootFolderId); + } + + public abstract class BasicRepository : IBasicRepository where TModel : BaseRepositoryModel, new() + { + public BasicRepository(EloqueraDb eloqueraDb) + { + EloqueraDb = eloqueraDb; + } + + protected EloqueraDb EloqueraDb { get; private set; } + + + public List All() + { + return EloqueraDb.AsQueryable().ToList(); + } + + public TModel Get(int rootFolderId) + { + return EloqueraDb.AsQueryable().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); + } + } +} diff --git a/NzbDrone.Core/Datastore/Migrations/Migration20130203.cs b/NzbDrone.Core/Datastore/Migrations/Migration20130203.cs index 795c82766..9ba4e2471 100644 --- a/NzbDrone.Core/Datastore/Migrations/Migration20130203.cs +++ b/NzbDrone.Core/Datastore/Migrations/Migration20130203.cs @@ -18,10 +18,10 @@ namespace NzbDrone.Core.Datastore.Migrations using (var dataReader = Database.ExecuteQuery("SELECT * from RootDirs")) { - var dirs = new List(); + var dirs = new List(); while (dataReader.Read()) { - var rootFolder = new RootDir { Path = dataReader["Path"].ToString() }; + var rootFolder = new RootFolder { Path = dataReader["Path"].ToString() }; dirs.Add(rootFolder); } objectDb.InsertMany(dirs); diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index 777e7997d..f140c3221 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -231,6 +231,8 @@ + + @@ -595,7 +597,7 @@ - + diff --git a/NzbDrone.Core/Repository/RootDir.cs b/NzbDrone.Core/RootFolders/RootFolder.cs similarity index 73% rename from NzbDrone.Core/Repository/RootDir.cs rename to NzbDrone.Core/RootFolders/RootFolder.cs index 6e6383374..45f196a06 100644 --- a/NzbDrone.Core/Repository/RootDir.cs +++ b/NzbDrone.Core/RootFolders/RootFolder.cs @@ -1,13 +1,13 @@ using System.Collections.Generic; -using NzbDrone.Core.RootFolders; +using NzbDrone.Core.Datastore; using PetaPoco; -namespace NzbDrone.Core.Repository +namespace NzbDrone.Core.RootFolders { [TableName("RootDirs")] [PrimaryKey("Id", autoIncrement = true)] - public class RootDir : BaseModel + public class RootFolder : BaseRepositoryModel { public string Path { get; set; } diff --git a/NzbDrone.Core/RootFolders/RootFolderRepository.cs b/NzbDrone.Core/RootFolders/RootFolderRepository.cs index ff3f7dd7c..1aaa5f531 100644 --- a/NzbDrone.Core/RootFolders/RootFolderRepository.cs +++ b/NzbDrone.Core/RootFolders/RootFolderRepository.cs @@ -6,64 +6,14 @@ using System.Linq; namespace NzbDrone.Core.RootFolders { - - public abstract class BaseModel - { - [ID] - public int Id; - } - - public interface IBasicRepository - { - List All(); - TModel Get(int rootFolderId); - TModel Add(TModel rootFolder); - void Delete(int rootFolderId); - } - - - public abstract class BasicRepository : IBasicRepository where TModel : BaseModel, new() - { - - - public BasicRepository(EloqueraDb eloqueraDb) - { - EloqueraDb = eloqueraDb; - } - - protected EloqueraDb EloqueraDb { get; private set; } - - - public List All() - { - return EloqueraDb.AsQueryable().ToList(); - } - - public TModel Get(int rootFolderId) - { - return EloqueraDb.AsQueryable().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 + public interface IRootFolderRepository : IBasicRepository { } //This way we only need to implement none_custom methods for repos, like custom queries etc... rest is done automagically. - public class RootFolderRepository : BasicRepository, IRootFolderRepository + public class RootFolderRepository : BasicRepository, IRootFolderRepository { public RootFolderRepository(EloqueraDb eloqueraDb) : base(eloqueraDb) diff --git a/NzbDrone.Core/RootFolders/RootFolderService.cs b/NzbDrone.Core/RootFolders/RootFolderService.cs index 02b0de1e3..2afa40c34 100644 --- a/NzbDrone.Core/RootFolders/RootFolderService.cs +++ b/NzbDrone.Core/RootFolders/RootFolderService.cs @@ -11,8 +11,8 @@ namespace NzbDrone.Core.RootFolders { public interface IRootFolderService { - List All(); - RootDir Add(RootDir rootDir); + List All(); + RootFolder Add(RootFolder rootDir); void Remove(int rootDirId); List GetUnmappedFolders(string path); Dictionary FreeSpaceOnDrives(); @@ -32,12 +32,12 @@ namespace NzbDrone.Core.RootFolders _seriesProvider = seriesProvider; } - public virtual List All() + public virtual List 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)) throw new ArgumentException("Invalid path"); diff --git a/NzbDrone.Services.Api/NzbDrone.Services.Api.csproj b/NzbDrone.Services.Api/NzbDrone.Services.Api.csproj index 4e6d27d09..6c492fbe6 100644 --- a/NzbDrone.Services.Api/NzbDrone.Services.Api.csproj +++ b/NzbDrone.Services.Api/NzbDrone.Services.Api.csproj @@ -14,7 +14,7 @@ NzbDrone.Services.Api NzbDrone.Services.Api v4.0 - false + true @@ -152,7 +152,7 @@ True 1306 / - http://localhost/NzbDrone.Services.Api + http://localhost:1306/ False False diff --git a/NzbDrone.Services/NzbDrone.Services.Tests/NzbDrone.Services.Tests.csproj b/NzbDrone.Services/NzbDrone.Services.Tests/NzbDrone.Services.Tests.csproj index 9132f5fff..93bc80b6e 100644 --- a/NzbDrone.Services/NzbDrone.Services.Tests/NzbDrone.Services.Tests.csproj +++ b/NzbDrone.Services/NzbDrone.Services.Tests/NzbDrone.Services.Tests.csproj @@ -74,9 +74,9 @@ ..\..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll - + False - ..\..\packages\NUnit.2.6.0.12054\lib\nunit.framework.dll + ..\..\packages\NUnit.2.6.2\lib\nunit.framework.dll diff --git a/NzbDrone.Services/NzbDrone.Services.Tests/packages.config b/NzbDrone.Services/NzbDrone.Services.Tests/packages.config index f136e652d..a52902780 100644 --- a/NzbDrone.Services/NzbDrone.Services.Tests/packages.config +++ b/NzbDrone.Services/NzbDrone.Services.Tests/packages.config @@ -4,5 +4,5 @@ - + \ No newline at end of file diff --git a/NzbDrone.Test.Common/NzbDrone.Test.Common.csproj b/NzbDrone.Test.Common/NzbDrone.Test.Common.csproj index df4d67595..2888cf687 100644 --- a/NzbDrone.Test.Common/NzbDrone.Test.Common.csproj +++ b/NzbDrone.Test.Common/NzbDrone.Test.Common.csproj @@ -70,9 +70,9 @@ ..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll - + False - ..\packages\NUnit.2.6.0.12054\lib\nunit.framework.dll + ..\packages\NUnit.2.6.2\lib\nunit.framework.dll diff --git a/NzbDrone.Test.Common/TestBase.cs b/NzbDrone.Test.Common/TestBase.cs index b5968ae5f..f34ed66fb 100644 --- a/NzbDrone.Test.Common/TestBase.cs +++ b/NzbDrone.Test.Common/TestBase.cs @@ -12,7 +12,6 @@ namespace NzbDrone.Test.Common { protected const string INTEGRATION_TEST = "Integration Test"; - private AutoMoqer _mocker; protected AutoMoqer Mocker { @@ -29,7 +28,6 @@ namespace NzbDrone.Test.Common protected Mock MockedRestProvider { get; private set; } - private string VirtualPath { get @@ -41,7 +39,6 @@ namespace NzbDrone.Test.Common } } - protected string TempFolder { get; private set; } [SetUp] @@ -83,7 +80,6 @@ namespace NzbDrone.Test.Common _mocker = new AutoMoqer(MockBehavior.Strict); } - protected void WithTempAsAppPath() { Mocker.GetMock() diff --git a/NzbDrone.Test.Common/packages.config b/NzbDrone.Test.Common/packages.config index c108fe589..e4abed86a 100644 --- a/NzbDrone.Test.Common/packages.config +++ b/NzbDrone.Test.Common/packages.config @@ -3,6 +3,6 @@ - + \ No newline at end of file diff --git a/NzbDrone.Update.Test/NzbDrone.Update.Test.csproj b/NzbDrone.Update.Test/NzbDrone.Update.Test.csproj index 43473ea6e..a43fc8f6c 100644 --- a/NzbDrone.Update.Test/NzbDrone.Update.Test.csproj +++ b/NzbDrone.Update.Test/NzbDrone.Update.Test.csproj @@ -53,9 +53,9 @@ ..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll - + False - ..\packages\NUnit.2.6.0.12054\lib\nunit.framework.dll + ..\packages\NUnit.2.6.2\lib\nunit.framework.dll diff --git a/NzbDrone.Update.Test/packages.config b/NzbDrone.Update.Test/packages.config index f920aa6f3..abc526247 100644 --- a/NzbDrone.Update.Test/packages.config +++ b/NzbDrone.Update.Test/packages.config @@ -3,5 +3,5 @@ - + \ No newline at end of file diff --git a/NzbDrone.Web.UI.Test/NzbDrone.Web.UI.Automation.csproj b/NzbDrone.Web.UI.Test/NzbDrone.Web.UI.Automation.csproj index 6fd04f03e..5cef9f400 100644 --- a/NzbDrone.Web.UI.Test/NzbDrone.Web.UI.Automation.csproj +++ b/NzbDrone.Web.UI.Test/NzbDrone.Web.UI.Automation.csproj @@ -64,7 +64,7 @@ ..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll - ..\packages\NUnit.2.6.0.12054\lib\nunit.framework.dll + ..\packages\NUnit.2.6.2\lib\nunit.framework.dll diff --git a/NzbDrone.Web.UI.Test/packages.config b/NzbDrone.Web.UI.Test/packages.config index eb81cbf9a..f008c2551 100644 --- a/NzbDrone.Web.UI.Test/packages.config +++ b/NzbDrone.Web.UI.Test/packages.config @@ -3,6 +3,6 @@ - + \ No newline at end of file diff --git a/NzbDrone.ncrunchsolution b/NzbDrone.ncrunchsolution index 13efc6321..c875ef518 100644 --- a/NzbDrone.ncrunchsolution +++ b/NzbDrone.ncrunchsolution @@ -2,7 +2,6 @@ 1 True true - true UseDynamicAnalysis Disabled Disabled