From 01c1943d0e361b30bd5a720baf58b2ebd1d49cae Mon Sep 17 00:00:00 2001 From: Keivan Date: Mon, 27 Sep 2010 21:25:41 -0700 Subject: [PATCH] Renamed all Core.Controllers to Core.Providers to avoid confusion between Core Controllers and MVC controllers --- NzbDrone.Core.Test/DbConfigControllerTest.cs | 6 ++-- NzbDrone.Core.Test/MockLib.cs | 10 +++--- NzbDrone.Core.Test/SabControllerTest.cs | 32 +++++++++---------- NzbDrone.Core.Test/SeriesTest.cs | 14 ++++---- NzbDrone.Core.Test/TvDbControllerTest.cs | 4 +-- .../Controllers/IConfigController.cs | 18 ----------- NzbDrone.Core/Controllers/IHttpController.cs | 12 ------- NzbDrone.Core/Main.cs | 10 +++--- NzbDrone.Core/NzbDrone.Core.csproj | 25 ++++++++------- .../ConfigProvider.cs} | 14 ++++---- .../DiskProvider.cs} | 6 ++-- .../HttpProvider.cs} | 8 ++--- NzbDrone.Core/Providers/IConfigProvider.cs | 12 +++++++ .../IDiskProvider.cs} | 4 +-- .../IDownloadProvider.cs} | 10 ++---- NzbDrone.Core/Providers/IHttpProvider.cs | 7 ++++ .../ISeriesProvider.cs} | 4 +-- .../ITvDbProvider.cs} | 4 +-- .../SabProvider.cs} | 17 ++++------ .../SeriesProvider.cs} | 25 +++++++-------- .../TvDbProvider.cs} | 8 ++--- NzbDrone.Core/Repository/Config.cs | 1 - NzbDrone.Web/Controllers/SeriesController.cs | 14 ++++---- .../Controllers/SettingsController.cs | 12 +++---- 24 files changed, 125 insertions(+), 152 deletions(-) delete mode 100644 NzbDrone.Core/Controllers/IConfigController.cs delete mode 100644 NzbDrone.Core/Controllers/IHttpController.cs rename NzbDrone.Core/{Controllers/DbConfigController.cs => Providers/ConfigProvider.cs} (83%) rename NzbDrone.Core/{Controllers/DiskController.cs => Providers/DiskProvider.cs} (77%) rename NzbDrone.Core/{Controllers/HttpController.cs => Providers/HttpProvider.cs} (75%) create mode 100644 NzbDrone.Core/Providers/IConfigProvider.cs rename NzbDrone.Core/{Controllers/IDiskController.cs => Providers/IDiskProvider.cs} (67%) rename NzbDrone.Core/{Controllers/IDownloadClientController.cs => Providers/IDownloadProvider.cs} (54%) create mode 100644 NzbDrone.Core/Providers/IHttpProvider.cs rename NzbDrone.Core/{Controllers/ISeriesController.cs => Providers/ISeriesProvider.cs} (70%) rename NzbDrone.Core/{Controllers/ITvDbController.cs => Providers/ITvDbProvider.cs} (72%) rename NzbDrone.Core/{Controllers/SabController.cs => Providers/SabProvider.cs} (86%) rename NzbDrone.Core/{Controllers/SeriesController.cs => Providers/SeriesProvider.cs} (73%) rename NzbDrone.Core/{Controllers/TvDbController.cs => Providers/TvDbProvider.cs} (81%) diff --git a/NzbDrone.Core.Test/DbConfigControllerTest.cs b/NzbDrone.Core.Test/DbConfigControllerTest.cs index 88ac644af..55d3f992c 100644 --- a/NzbDrone.Core.Test/DbConfigControllerTest.cs +++ b/NzbDrone.Core.Test/DbConfigControllerTest.cs @@ -6,7 +6,7 @@ using log4net; using MbUnit.Framework; using MbUnit.Framework.ContractVerifiers; using Moq; -using NzbDrone.Core.Controllers; +using NzbDrone.Core.Providers; using NzbDrone.Core.Repository; using SubSonic.Repository; @@ -26,7 +26,7 @@ namespace NzbDrone.Core.Test var repo = new Mock(); var config = new Config { Key = key, Value = value }; repo.Setup(r => r.Single(key)).Returns(config); - var target = new DbConfigController(new Mock().Object, repo.Object); + var target = new ConfigProvider(new Mock().Object, repo.Object); //Act target.SetValue(key, value); @@ -45,7 +45,7 @@ namespace NzbDrone.Core.Test //Arrange var repo = new Mock(); repo.Setup(r => r.Single(It.IsAny())).Returns(null).Verifiable(); - var target = new DbConfigController(new Mock().Object, repo.Object); + var target = new ConfigProvider(new Mock().Object, repo.Object); //Act target.SetValue(key, value); diff --git a/NzbDrone.Core.Test/MockLib.cs b/NzbDrone.Core.Test/MockLib.cs index 5a1dad397..b7b7d7a0d 100644 --- a/NzbDrone.Core.Test/MockLib.cs +++ b/NzbDrone.Core.Test/MockLib.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using Moq; -using NzbDrone.Core.Controllers; +using NzbDrone.Core.Providers; namespace NzbDrone.Core.Test { @@ -18,21 +18,21 @@ namespace NzbDrone.Core.Test } - public static IConfigController StandardConfig + public static IConfigProvider StandardConfig { get { - var mock = new Mock(); + var mock = new Mock(); mock.SetupGet(c => c.SeriesRoot).Returns("C:\\"); return mock.Object; } } - public static IDiskController StandardDisk + public static IDiskProvider StandardDisk { get { - var mock = new Mock(); + var mock = new Mock(); mock.Setup(c => c.GetDirectories(It.IsAny())).Returns(StandardSeries); mock.Setup(c => c.Exists(It.Is(d => StandardSeries.Contains(d)))).Returns(true); return mock.Object; diff --git a/NzbDrone.Core.Test/SabControllerTest.cs b/NzbDrone.Core.Test/SabControllerTest.cs index 0325fa6a7..6727e01ce 100644 --- a/NzbDrone.Core.Test/SabControllerTest.cs +++ b/NzbDrone.Core.Test/SabControllerTest.cs @@ -7,8 +7,8 @@ using log4net; using MbUnit.Framework; using MbUnit.Framework.ContractVerifiers; using Moq; +using NzbDrone.Core.Providers; using NzbDrone.Core.Repository; -using NzbDrone.Core.Controllers; using SubSonic.Repository; namespace NzbDrone.Core.Test @@ -26,17 +26,17 @@ namespace NzbDrone.Core.Test string password = "pass"; string priority = "0"; - var config = new Mock(); + var config = new Mock(); config.Setup(c => c.GetValue("SabnzbdInfo", String.Empty, false)).Returns(sabnzbdInfo); config.Setup(c => c.GetValue("ApiKey", String.Empty, false)).Returns(apikey); config.Setup(c => c.GetValue("Username", String.Empty, false)).Returns(username); config.Setup(c => c.GetValue("Password", String.Empty, false)).Returns(password); config.Setup(c => c.GetValue("Priority", String.Empty, false)).Returns(priority); - var http = new Mock(); + var http = new Mock(); http.Setup(s => s.GetRequest("http://192.168.5.55:2222/sabnzbd/api?mode=addurl&name=http://www.nzbclub.com/nzb_download.aspx?mid=1950232&priority=0&cat=tv&nzbname=This+is+an+Nzb&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass")).Returns("ok"); - var target = new SabController(config.Object, new Mock().Object, http.Object); + var target = new SabProvider(config.Object, new Mock().Object, http.Object); ItemInfo nzb = new ItemInfo(); nzb.Link = new Uri("http://www.nzbclub.com/nzb_download.aspx?mid=1950232"); @@ -59,17 +59,17 @@ namespace NzbDrone.Core.Test string password = "pass"; string priority = "0"; - var config = new Mock(); + var config = new Mock(); config.Setup(c => c.GetValue("SabnzbdInfo", String.Empty, false)).Returns(sabnzbdInfo); config.Setup(c => c.GetValue("ApiKey", String.Empty, false)).Returns(apikey); config.Setup(c => c.GetValue("Username", String.Empty, false)).Returns(username); config.Setup(c => c.GetValue("Password", String.Empty, false)).Returns(password); config.Setup(c => c.GetValue("Priority", String.Empty, false)).Returns(priority); - var http = new Mock(); + var http = new Mock(); http.Setup(s => s.GetRequest("http://192.168.5.55:2222/sabnzbd/api?mode=addurl&name=http://www.nzbclub.com/nzb_download.aspx?mid=1950232&priority=0&cat=tv&nzbname=This+is+an+Nzb&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass")).Returns("error"); - var target = new SabController(config.Object, new Mock().Object, http.Object); + var target = new SabProvider(config.Object, new Mock().Object, http.Object); ItemInfo nzb = new ItemInfo(); nzb.Link = new Uri("http://www.nzbclub.com/nzb_download.aspx?mid=1950232"); @@ -92,21 +92,21 @@ namespace NzbDrone.Core.Test string password = "pass"; string priority = "0"; - var config = new Mock(); + var config = new Mock(); config.Setup(c => c.GetValue("SabnzbdInfo", String.Empty, false)).Returns(sabnzbdInfo); config.Setup(c => c.GetValue("ApiKey", String.Empty, false)).Returns(apikey); config.Setup(c => c.GetValue("Username", String.Empty, false)).Returns(username); config.Setup(c => c.GetValue("Password", String.Empty, false)).Returns(password); config.Setup(c => c.GetValue("Priority", String.Empty, false)).Returns(priority); - var http = new Mock(); + var http = new Mock(); http.Setup( s => s.GetRequest( "http://192.168.5.55:2222/sabnzbd/api?mode=queue&output=xml&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass")) .Returns(new StreamReader(@".\Files\Queue.xml").ReadToEnd()); - var target = new SabController(config.Object, new Mock().Object, http.Object); + var target = new SabProvider(config.Object, new Mock().Object, http.Object); Episode episode = new Episode(); FeedItem item = new FeedItem(); @@ -130,21 +130,21 @@ namespace NzbDrone.Core.Test string password = "pass"; string priority = "0"; - var config = new Mock(); + var config = new Mock(); config.Setup(c => c.GetValue("SabnzbdInfo", String.Empty, false)).Returns(sabnzbdInfo); config.Setup(c => c.GetValue("ApiKey", String.Empty, false)).Returns(apikey); config.Setup(c => c.GetValue("Username", String.Empty, false)).Returns(username); config.Setup(c => c.GetValue("Password", String.Empty, false)).Returns(password); config.Setup(c => c.GetValue("Priority", String.Empty, false)).Returns(priority); - var http = new Mock(); + var http = new Mock(); http.Setup( s => s.GetRequest( "http://192.168.5.55:2222/sabnzbd/api?mode=queue&output=xml&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass")) .Returns(new StreamReader(@".\Files\QueueEmpty.xml").ReadToEnd()); - var target = new SabController(config.Object, new Mock().Object, http.Object); + var target = new SabProvider(config.Object, new Mock().Object, http.Object); Episode episode = new Episode(); FeedItem item = new FeedItem(); @@ -168,21 +168,21 @@ namespace NzbDrone.Core.Test string password = "pass"; string priority = "0"; - var config = new Mock(); + var config = new Mock(); config.Setup(c => c.GetValue("SabnzbdInfo", String.Empty, false)).Returns(sabnzbdInfo); config.Setup(c => c.GetValue("ApiKey", String.Empty, false)).Returns(apikey); config.Setup(c => c.GetValue("Username", String.Empty, false)).Returns(username); config.Setup(c => c.GetValue("Password", String.Empty, false)).Returns(password); config.Setup(c => c.GetValue("Priority", String.Empty, false)).Returns(priority); - var http = new Mock(); + var http = new Mock(); http.Setup( s => s.GetRequest( "http://192.168.5.55:2222/sabnzbd/api?mode=queue&output=xml&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass")) .Returns(new StreamReader(@".\Files\QueueError.xml").ReadToEnd()); - var target = new SabController(config.Object, new Mock().Object, http.Object); + var target = new SabProvider(config.Object, new Mock().Object, http.Object); Episode episode = new Episode(); FeedItem item = new FeedItem(); diff --git a/NzbDrone.Core.Test/SeriesTest.cs b/NzbDrone.Core.Test/SeriesTest.cs index 8ac0db330..8d374c16e 100644 --- a/NzbDrone.Core.Test/SeriesTest.cs +++ b/NzbDrone.Core.Test/SeriesTest.cs @@ -10,7 +10,7 @@ using MbUnit.Framework.ContractVerifiers; using Moq; using Ninject; using Ninject.Moq; -using NzbDrone.Core.Controllers; +using NzbDrone.Core.Providers; using NzbDrone.Core.Repository; using SubSonic.Repository; using TvdbLib.Data; @@ -30,7 +30,7 @@ namespace NzbDrone.Core.Test //Arrange var moqData = new Mock(); - var moqTvdb = new Mock(); + var moqTvdb = new Mock(); //setup db to return a fake series Series fakeSeries = Builder.CreateNew() @@ -52,14 +52,14 @@ namespace NzbDrone.Core.Test var kernel = new MockingKernel(); kernel.Bind().ToConstant(moqData.Object); - kernel.Bind().ToConstant(moqTvdb.Object); - kernel.Bind().ToConstant(MockLib.StandardConfig); - kernel.Bind().ToConstant(MockLib.StandardDisk); - kernel.Bind().To(); + kernel.Bind().ToConstant(moqTvdb.Object); + kernel.Bind().ToConstant(MockLib.StandardConfig); + kernel.Bind().ToConstant(MockLib.StandardDisk); + kernel.Bind().To(); //Act - var seriesController = kernel.Get(); + var seriesController = kernel.Get(); seriesController.SyncSeriesWithDisk(); //Assert diff --git a/NzbDrone.Core.Test/TvDbControllerTest.cs b/NzbDrone.Core.Test/TvDbControllerTest.cs index cda749b55..e35b19cbc 100644 --- a/NzbDrone.Core.Test/TvDbControllerTest.cs +++ b/NzbDrone.Core.Test/TvDbControllerTest.cs @@ -4,7 +4,7 @@ using System.Text; using Gallio.Framework; using MbUnit.Framework; using MbUnit.Framework.ContractVerifiers; -using NzbDrone.Core.Controllers; +using NzbDrone.Core.Providers; namespace NzbDrone.Core.Test { @@ -18,7 +18,7 @@ namespace NzbDrone.Core.Test [Ignore("Have to find a way to mock app path for tests.")] public void TestSearch(string title) { - var tvCont =new TvDbController(); + var tvCont =new TvDbProvider(); var result = tvCont.SearchSeries(title); Assert.AreNotEqual(0, result.Count); diff --git a/NzbDrone.Core/Controllers/IConfigController.cs b/NzbDrone.Core/Controllers/IConfigController.cs deleted file mode 100644 index e76ef216b..000000000 --- a/NzbDrone.Core/Controllers/IConfigController.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace NzbDrone.Core.Controllers -{ - public interface IConfigController - { - String SeriesRoot - { - get; - - set; - } - - string GetValue(string key, object defaultValue, bool makePermanent); - void SetValue(string key, string value); - } -} \ No newline at end of file diff --git a/NzbDrone.Core/Controllers/IHttpController.cs b/NzbDrone.Core/Controllers/IHttpController.cs deleted file mode 100644 index c1fa8fd5c..000000000 --- a/NzbDrone.Core/Controllers/IHttpController.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace NzbDrone.Core.Controllers -{ - public interface IHttpController - { - string GetRequest(string request); - } -} diff --git a/NzbDrone.Core/Main.cs b/NzbDrone.Core/Main.cs index 5d9aa8a57..f05461cd9 100644 --- a/NzbDrone.Core/Main.cs +++ b/NzbDrone.Core/Main.cs @@ -3,7 +3,7 @@ using System.IO; using System.Web; using log4net; using Ninject; -using NzbDrone.Core.Controllers; +using NzbDrone.Core.Providers; using SubSonic.DataProviders; using SubSonic.Repository; @@ -17,10 +17,10 @@ namespace NzbDrone.Core string connectionString = String.Format("Data Source={0};Version=3;", Path.Combine(AppPath, "nzbdrone.db")); var provider = ProviderFactory.GetProvider(connectionString, "System.Data.SQLite"); - kernel.Bind().To(); - kernel.Bind().To(); - kernel.Bind().To(); - kernel.Bind().To(); + kernel.Bind().To(); + kernel.Bind().To(); + kernel.Bind().To(); + kernel.Bind().To(); kernel.Bind().ToMethod(c => LogManager.GetLogger("logger-name")); kernel.Bind().ToMethod(c => new SimpleRepository(provider, SimpleRepositoryOptions.RunMigrations)); } diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index 41823a5cd..4e0f4a0e4 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -135,13 +135,13 @@ - - - - - - - + + + + + + + @@ -151,11 +151,11 @@ - - - - - + + + + + @@ -202,6 +202,7 @@ +