mirror of https://github.com/Sonarr/Sonarr
aFixed QualityProfile storage test
This commit is contained in:
parent
27164d422c
commit
899e5a9a22
|
@ -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
|
||||||
|
{ }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,14 +19,15 @@ namespace NzbDrone.Core.Test
|
||||||
get { return new string[] { "C:\\TV\\The Simpsons", "C:\\TV\\Family Guy" }; }
|
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
|
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);
|
return new SimpleRepository(provider, SimpleRepositoryOptions.RunMigrations);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,6 +69,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="DbConfigControllerTest.cs" />
|
<Compile Include="DbConfigControllerTest.cs" />
|
||||||
|
<Compile Include="Fixtures.cs" />
|
||||||
<Compile Include="MockLib.cs" />
|
<Compile Include="MockLib.cs" />
|
||||||
<Compile Include="Ninject.Moq\ExtensionsForBindingSyntax.cs" />
|
<Compile Include="Ninject.Moq\ExtensionsForBindingSyntax.cs" />
|
||||||
<Compile Include="Ninject.Moq\MockingKernel.cs" />
|
<Compile Include="Ninject.Moq\MockingKernel.cs" />
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
using System.Reflection;
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using MbUnit.Framework;
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
// set of attributes. Change these attribute values to modify the information
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using MbUnit.Framework;
|
using MbUnit.Framework;
|
||||||
using NzbDrone.Core.Repository;
|
using NzbDrone.Core.Repository;
|
||||||
|
|
||||||
|
@ -14,12 +16,13 @@ namespace NzbDrone.Core.Test
|
||||||
[Test]
|
[Test]
|
||||||
public void Test_Storage()
|
public void Test_Storage()
|
||||||
{
|
{
|
||||||
|
|
||||||
//Arrange
|
//Arrange
|
||||||
var repo = MockLib.MemoryRepository;
|
var repo = MockLib.EmptyRepository;
|
||||||
var testProfile = new QualityProfile
|
var testProfile = new QualityProfile
|
||||||
{
|
{
|
||||||
Cutoff = Quality.SDTV,
|
Cutoff = Quality.SDTV,
|
||||||
Q = new[] { Quality.HDTV, Quality.DVD }
|
Allowed = new List<Quality>() { Quality.HDTV, Quality.DVD },
|
||||||
};
|
};
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
|
@ -29,8 +32,7 @@ namespace NzbDrone.Core.Test
|
||||||
//Assert
|
//Assert
|
||||||
Assert.AreEqual(id, fetch.Id);
|
Assert.AreEqual(id, fetch.Id);
|
||||||
Assert.AreEqual(testProfile.Cutoff, fetch.Cutoff);
|
Assert.AreEqual(testProfile.Cutoff, fetch.Cutoff);
|
||||||
Assert.AreEqual(testProfile.Qualitys, fetch.Qualitys);
|
Assert.AreEqual(testProfile.Allowed, fetch.Allowed);
|
||||||
Assert.AreElementsEqual(testProfile.Q, fetch.Q);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,9 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using SubSonic.SqlGeneration.Schema;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Repository
|
namespace NzbDrone.Core.Repository
|
||||||
{
|
{
|
||||||
|
@ -9,7 +11,31 @@ namespace NzbDrone.Core.Repository
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public Quality Cutoff { 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<Quality>(qualities.Length);
|
||||||
|
foreach (var quality in qualities)
|
||||||
|
{
|
||||||
|
Allowed.Add((Quality)Convert.ToInt32(quality));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[SubSonicIgnore]
|
||||||
|
public List<Quality> Allowed { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue