diff --git a/NzbDrone.Core.Test/Fixtures.cs b/NzbDrone.Core.Test/Fixtures.cs new file mode 100644 index 000000000..74bca0b8a --- /dev/null +++ b/NzbDrone.Core.Test/Fixtures.cs @@ -0,0 +1,27 @@ +using System; +using System.IO; +using MbUnit.Framework; + +namespace NzbDrone.Core.Test +{ + [AssemblyFixture] + public class Fixtures + { + [TearDown] + public void TearDown() + { + var dbFiles = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.testdb"); + + foreach (var dbFile in dbFiles) + { + try + { + File.Delete(dbFile); + } + catch + { } + + } + } + } +} \ No newline at end of file diff --git a/NzbDrone.Core.Test/MockLib.cs b/NzbDrone.Core.Test/MockLib.cs index 02a013e0d..84e6ab923 100644 --- a/NzbDrone.Core.Test/MockLib.cs +++ b/NzbDrone.Core.Test/MockLib.cs @@ -19,14 +19,15 @@ 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 + + public static IRepository EmptyRepository { get { - var provider = ProviderFactory.GetProvider(MemoryConnection, "System.Data.SQLite"); + + var provider = ProviderFactory.GetProvider("Data Source=" + Guid.NewGuid() + ".testdb;Version=3;New=True", "System.Data.SQLite"); return new SimpleRepository(provider, SimpleRepositoryOptions.RunMigrations); } } diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index a5e443d43..95a681547 100644 --- a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -69,6 +69,7 @@ + diff --git a/NzbDrone.Core.Test/Properties/AssemblyInfo.cs b/NzbDrone.Core.Test/Properties/AssemblyInfo.cs index b6cea33f9..874626192 100644 --- a/NzbDrone.Core.Test/Properties/AssemblyInfo.cs +++ b/NzbDrone.Core.Test/Properties/AssemblyInfo.cs @@ -1,6 +1,8 @@ -using System.Reflection; +using System; +using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; +using MbUnit.Framework; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information diff --git a/NzbDrone.Core.Test/QualityProfileTest.cs b/NzbDrone.Core.Test/QualityProfileTest.cs index 0d97c27e9..9b1f0a676 100644 --- a/NzbDrone.Core.Test/QualityProfileTest.cs +++ b/NzbDrone.Core.Test/QualityProfileTest.cs @@ -1,3 +1,5 @@ +using System.Collections.Generic; +using System.IO; using MbUnit.Framework; using NzbDrone.Core.Repository; @@ -14,12 +16,13 @@ namespace NzbDrone.Core.Test [Test] public void Test_Storage() { + //Arrange - var repo = MockLib.MemoryRepository; + var repo = MockLib.EmptyRepository; var testProfile = new QualityProfile { Cutoff = Quality.SDTV, - Q = new[] { Quality.HDTV, Quality.DVD } + Allowed = new List() { Quality.HDTV, Quality.DVD }, }; //Act @@ -29,8 +32,7 @@ namespace NzbDrone.Core.Test //Assert Assert.AreEqual(id, fetch.Id); Assert.AreEqual(testProfile.Cutoff, fetch.Cutoff); - Assert.AreEqual(testProfile.Qualitys, fetch.Qualitys); - Assert.AreElementsEqual(testProfile.Q, fetch.Q); + Assert.AreEqual(testProfile.Allowed, fetch.Allowed); } } } \ No newline at end of file diff --git a/NzbDrone.Core/Repository/QualityProfile.cs b/NzbDrone.Core/Repository/QualityProfile.cs index d086dead4..42fbaf077 100644 --- a/NzbDrone.Core/Repository/QualityProfile.cs +++ b/NzbDrone.Core/Repository/QualityProfile.cs @@ -1,7 +1,9 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text; +using SubSonic.SqlGeneration.Schema; namespace NzbDrone.Core.Repository { @@ -9,7 +11,31 @@ namespace NzbDrone.Core.Repository { public int Id { get; set; } public Quality Cutoff { get; set; } - public string Qualitys { get; set; } - public Quality[] Q { get; set; } + + [EditorBrowsable(EditorBrowsableState.Never)] + public string SonicAllowed + { + get + { + string result = String.Empty; + foreach (var q in Allowed) + { + result += (int)q + "|"; + } + return result.Trim('|'); + } + private set + { + var qualities = value.Split('|'); + Allowed = new List(qualities.Length); + foreach (var quality in qualities) + { + Allowed.Add((Quality)Convert.ToInt32(quality)); + } + } + } + + [SubSonicIgnore] + public List Allowed { get; set; } } }