From 26c03d7162472e6f1425ab8fb5bb34869081d553 Mon Sep 17 00:00:00 2001 From: Keivan Date: Wed, 29 Sep 2010 10:19:18 -0700 Subject: [PATCH] Added broken tests --- NzbDrone.Core.Test/MockLib.cs | 13 ++++ NzbDrone.Core.Test/NzbDrone.Core.Test.csproj | 5 +- NzbDrone.Core.Test/QualityProfileTest.cs | 36 ++++++++++ NzbDrone.Core/NzbDrone.Core.csproj | 1 + NzbDrone.Core/Repository/QualityProfile.cs | 15 +++++ NzbDrone.Web/Global.asax.cs | 5 +- NzbDrone.Web/NzbDrone.Web.csproj | 11 ++- NzbDrone.Web/Web.config | 70 +++----------------- 8 files changed, 89 insertions(+), 67 deletions(-) create mode 100644 NzbDrone.Core.Test/QualityProfileTest.cs create mode 100644 NzbDrone.Core/Repository/QualityProfile.cs diff --git a/NzbDrone.Core.Test/MockLib.cs b/NzbDrone.Core.Test/MockLib.cs index b7b7d7a0d..02a013e0d 100644 --- a/NzbDrone.Core.Test/MockLib.cs +++ b/NzbDrone.Core.Test/MockLib.cs @@ -4,6 +4,8 @@ using System.Linq; using System.Text; using Moq; using NzbDrone.Core.Providers; +using SubSonic.DataProviders; +using SubSonic.Repository; namespace NzbDrone.Core.Test { @@ -17,6 +19,17 @@ namespace NzbDrone.Core.Test get { return new string[] { "C:\\TV\\The Simpsons", "C:\\TV\\Family Guy" }; } } + public const string MemoryConnection = "Data Source=:memory:;Version=3;New=True"; + + + public static IRepository MemoryRepository + { + get + { + var provider = ProviderFactory.GetProvider(MemoryConnection, "System.Data.SQLite"); + return new SimpleRepository(provider, SimpleRepositoryOptions.RunMigrations); + } + } public static IConfigProvider StandardConfig { diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index 68e903fc2..631b3c394 100644 --- a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -55,7 +55,9 @@ ..\NzbDrone.Core\Libraries\SubSonic.Core.dll - + + ..\NzbDrone.Core\Libraries\System.Data.SQLite.dll + @@ -72,6 +74,7 @@ + diff --git a/NzbDrone.Core.Test/QualityProfileTest.cs b/NzbDrone.Core.Test/QualityProfileTest.cs new file mode 100644 index 000000000..0d97c27e9 --- /dev/null +++ b/NzbDrone.Core.Test/QualityProfileTest.cs @@ -0,0 +1,36 @@ +using MbUnit.Framework; +using NzbDrone.Core.Repository; + +namespace NzbDrone.Core.Test +{ + [TestFixture] + public class QualityProfileTest + { + /// + /// Test_s the storage. + /// + /// + /// + [Test] + public void Test_Storage() + { + //Arrange + var repo = MockLib.MemoryRepository; + var testProfile = new QualityProfile + { + Cutoff = Quality.SDTV, + Q = new[] { Quality.HDTV, Quality.DVD } + }; + + //Act + var id = (int)repo.Add(testProfile); + var fetch = repo.Single(c => c.Id == id); + + //Assert + Assert.AreEqual(id, fetch.Id); + Assert.AreEqual(testProfile.Cutoff, fetch.Cutoff); + Assert.AreEqual(testProfile.Qualitys, fetch.Qualitys); + Assert.AreElementsEqual(testProfile.Q, fetch.Q); + } + } +} \ No newline at end of file diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index 3bacbe752..4c65666cc 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -147,6 +147,7 @@ + diff --git a/NzbDrone.Core/Repository/QualityProfile.cs b/NzbDrone.Core/Repository/QualityProfile.cs new file mode 100644 index 000000000..d086dead4 --- /dev/null +++ b/NzbDrone.Core/Repository/QualityProfile.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace NzbDrone.Core.Repository +{ + public class QualityProfile + { + public int Id { get; set; } + public Quality Cutoff { get; set; } + public string Qualitys { get; set; } + public Quality[] Q { get; set; } + } +} diff --git a/NzbDrone.Web/Global.asax.cs b/NzbDrone.Web/Global.asax.cs index 007a1bc28..f93920828 100644 --- a/NzbDrone.Web/Global.asax.cs +++ b/NzbDrone.Web/Global.asax.cs @@ -7,9 +7,6 @@ using NzbDrone.Core; namespace NzbDrone.Web { - // Note: For instructions on enabling IIS6 or IIS7 classic mode, - // visit http://go.microsoft.com/?LinkId=9394801 - public class MvcApplication : NinjectHttpApplication { private StandardKernel _kernel; @@ -33,7 +30,7 @@ namespace NzbDrone.Web AreaRegistration.RegisterAllAreas(); RegisterRoutes(RouteTable.Routes); base.OnApplicationStarted(); - } + } protected override IKernel CreateKernel() { diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj index 9294d0ff9..c36a9c25d 100644 --- a/NzbDrone.Web/NzbDrone.Web.csproj +++ b/NzbDrone.Web/NzbDrone.Web.csproj @@ -45,6 +45,9 @@ + + ..\NzbDrone.Core\Libraries\System.Data.SQLite.dll + @@ -53,10 +56,14 @@ 3.5 - + + True + - + + False + diff --git a/NzbDrone.Web/Web.config b/NzbDrone.Web/Web.config index f2e3403a8..a6b92fd65 100644 --- a/NzbDrone.Web/Web.config +++ b/NzbDrone.Web/Web.config @@ -1,81 +1,23 @@  - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -99,4 +41,12 @@ + + + + + +