cleaned up CoreTest base class.

pull/2/head
kay.one 12 years ago
parent 77bb790672
commit 64a3e1caf0

@ -1,7 +1,7 @@
using System; using System;
using System.IO; using System.IO;
using NUnit.Framework; using NUnit.Framework;
using NzbDrone.Common; using NzbDrone.Core.Datastore;
using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Providers.Core;
using NzbDrone.Test.Common; using NzbDrone.Test.Common;
@ -11,30 +11,46 @@ namespace NzbDrone.Core.Test.Framework
{ {
public class CoreTest : TestBase public class CoreTest : TestBase
{ {
static CoreTest() private string _dbTemplateName;
[SetUp]
public void CoreTestSetup()
{
_dbTemplateName = Path.Combine(Path.GetTempPath(), Path.GetTempFileName()) + ".sdf";
CreateDataBaseTemplate();
}
private IDatabase GetEmptyDatabase(string fileName = "")
{ {
//Delete old db files Console.WriteLine("====================DataBase====================");
var oldDbFiles = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.sdf", SearchOption.AllDirectories); Console.WriteLine("Cloning database from template.");
foreach (var file in oldDbFiles)
if (String.IsNullOrWhiteSpace(fileName))
{ {
try fileName = Guid.NewGuid() + ".sdf";
{
File.Delete(file);
}
catch { }
} }
/* //Delete App_data folder File.Copy(_dbTemplateName, fileName);
var appData = new EnvironmentProvider().GetAppDataPath();
if (Directory.Exists(appData)) var connectionString = ConnectionFactory.GetConnectionString(fileName);
{ var database = ConnectionFactory.GetPetaPocoDb(connectionString);
//Directory.Delete(appData, true);
}*/ Console.WriteLine("====================DataBase====================");
Console.WriteLine();
Console.WriteLine();
TestDbHelper.CreateDataBaseTemplate(); return database;
} }
private void CreateDataBaseTemplate()
{
Console.WriteLine("Creating an empty PetaPoco database");
var connectionString = ConnectionFactory.GetConnectionString(_dbTemplateName);
var database = ConnectionFactory.GetPetaPocoDb(connectionString);
database.Dispose();
}
private IDatabase _db; private IDatabase _db;
protected IDatabase Db protected IDatabase Db
@ -50,7 +66,7 @@ namespace NzbDrone.Core.Test.Framework
protected void WithRealDb() protected void WithRealDb()
{ {
_db = TestDbHelper.GetEmptyDatabase(); _db = GetEmptyDatabase();
Mocker.SetConstant(Db); Mocker.SetConstant(Db);
} }
@ -71,6 +87,18 @@ namespace NzbDrone.Core.Test.Framework
public void CoreTestTearDown() public void CoreTestTearDown()
{ {
ConfigProvider.ClearCache(); ConfigProvider.ClearCache();
if (_db != null && _db.Connection != null && File.Exists(_db.Connection.Database))
{
var file = _db.Connection.Database;
_db.Dispose();
try
{
File.Delete(file);
}
catch (IOException) { }
}
} }
} }
} }

@ -16,44 +16,6 @@ namespace NzbDrone.Core.Test.Framework
{ {
internal static class TestDbHelper internal static class TestDbHelper
{ {
private static readonly string dbTemplateName;
static TestDbHelper()
{
dbTemplateName = Path.Combine(Path.GetTempPath(), Path.GetTempFileName()) + ".sdf";
}
internal static string ConnectionString { get; private set; }
internal static IDatabase GetEmptyDatabase(string fileName = "")
{
Console.WriteLine("====================DataBase====================");
Console.WriteLine("Cloning database from template.");
if (String.IsNullOrWhiteSpace(fileName))
{
fileName = Guid.NewGuid() + ".sdf";
}
File.Copy(dbTemplateName, fileName);
ConnectionString = ConnectionFactory.GetConnectionString(fileName);
var database = ConnectionFactory.GetPetaPocoDb(ConnectionString);
Console.WriteLine("====================DataBase====================");
Console.WriteLine();
Console.WriteLine();
return database;
}
internal static void CreateDataBaseTemplate()
{
Console.WriteLine("Creating an empty PetaPoco database");
var connectionString = ConnectionFactory.GetConnectionString(dbTemplateName);
var database = ConnectionFactory.GetPetaPocoDb(connectionString);
database.Dispose();
}
} }
} }

@ -27,7 +27,7 @@ namespace NzbDrone.Core.Test.ProviderTests.EpisodeProviderTests
All() All()
.With(l => l.Language = new TvdbLanguage(0, "eng", "a")) .With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
.Build(); .Build();
var fakeSeries = Builder<Series>.CreateNew() var fakeSeries = Builder<Series>.CreateNew()
.With(c => c.SeriesId = seriesId) .With(c => c.SeriesId = seriesId)
@ -38,19 +38,18 @@ namespace NzbDrone.Core.Test.ProviderTests.EpisodeProviderTests
.With(e => e.TvDbEpisodeId = tvDbSeries.First().Id) .With(e => e.TvDbEpisodeId = tvDbSeries.First().Id)
.Build(); .Build();
var db = TestDbHelper.GetEmptyDatabase();
Mocker.SetConstant(db);
db.Insert(fakeSeries); WithRealDb();
db.Insert(fakeEpisode);
Db.Insert(fakeSeries);
Db.Insert(fakeEpisode);
//Act //Act
Mocker.Resolve<EpisodeProvider>().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries); Mocker.Resolve<EpisodeProvider>().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries);
//Assert //Assert
var result = db.Fetch<Episode>(); var result = Db.Fetch<Episode>();
result.Should().HaveCount(1); result.Should().HaveCount(1);
} }
@ -75,19 +74,18 @@ namespace NzbDrone.Core.Test.ProviderTests.EpisodeProviderTests
.With(e => e.TvDbEpisodeId = 0) .With(e => e.TvDbEpisodeId = 0)
.Build(); .Build();
var db = TestDbHelper.GetEmptyDatabase();
Mocker.SetConstant(db);
db.Insert(fakeSeries); WithRealDb();
db.Insert(fakeEpisode);
Db.Insert(fakeSeries);
Db.Insert(fakeEpisode);
//Act //Act
Mocker.Resolve<EpisodeProvider>().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries); Mocker.Resolve<EpisodeProvider>().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries);
//Assert //Assert
var result = db.Fetch<Episode>(); var result = Db.Fetch<Episode>();
result.Should().HaveCount(1); result.Should().HaveCount(1);
} }
@ -112,19 +110,16 @@ namespace NzbDrone.Core.Test.ProviderTests.EpisodeProviderTests
.With(e => e.TvDbEpisodeId = null) .With(e => e.TvDbEpisodeId = null)
.Build(); .Build();
WithRealDb();
var db = TestDbHelper.GetEmptyDatabase();
Mocker.SetConstant(db);
db.Insert(fakeSeries); Db.Insert(fakeSeries);
db.Insert(fakeEpisode); Db.Insert(fakeEpisode);
//Act //Act
Mocker.Resolve<EpisodeProvider>().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries); Mocker.Resolve<EpisodeProvider>().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries);
//Assert //Assert
var result = db.Fetch<Episode>(); var result = Db.Fetch<Episode>();
result.Should().HaveCount(1); result.Should().HaveCount(1);
} }
@ -151,19 +146,18 @@ namespace NzbDrone.Core.Test.ProviderTests.EpisodeProviderTests
.With(e => e.TvDbEpisodeId = 300) .With(e => e.TvDbEpisodeId = 300)
.Build(); .Build();
var db = TestDbHelper.GetEmptyDatabase();
Mocker.SetConstant(db);
db.Insert(fakeSeries); WithRealDb();
db.Insert(fakeEpisode);
Db.Insert(fakeSeries);
Db.Insert(fakeEpisode);
//Act //Act
Mocker.Resolve<EpisodeProvider>().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries); Mocker.Resolve<EpisodeProvider>().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries);
//Assert //Assert
var result = db.Fetch<Episode>(); var result = Db.Fetch<Episode>();
result.Should().HaveCount(0); result.Should().HaveCount(0);
} }
@ -203,24 +197,23 @@ namespace NzbDrone.Core.Test.ProviderTests.EpisodeProviderTests
.With(e => e.TvDbEpisodeId = 300) .With(e => e.TvDbEpisodeId = 300)
.Build(); .Build();
var db = TestDbHelper.GetEmptyDatabase();
Mocker.SetConstant(db);
db.Insert(fakeSeries); WithRealDb();
db.Insert(fakeEpisode);
db.Insert(otherFakeSeries); Db.Insert(fakeSeries);
db.Insert(otherFakeEpisode); Db.Insert(fakeEpisode);
Db.Insert(otherFakeSeries);
Db.Insert(otherFakeEpisode);
//Act //Act
Mocker.Resolve<EpisodeProvider>().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries); Mocker.Resolve<EpisodeProvider>().DeleteEpisodesNotInTvdb(fakeSeries, tvDbSeries);
//Assert //Assert
var result = db.Fetch<Episode>(); var result = Db.Fetch<Episode>();
result.Should().HaveCount(1); result.Should().HaveCount(1);
} }
[Test] [Test]
public void should_not_do_anything_if_episode_list_is_empty() public void should_not_do_anything_if_episode_list_is_empty()
{ {

@ -24,9 +24,7 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test] [Test]
public void Init_indexer_test() public void Init_indexer_test()
{ {
WithRealDb();
Mocker.SetConstant(TestDbHelper.GetEmptyDatabase());
Mocker.SetConstant<IEnumerable<IndexerBase>>(new List<IndexerBase> { Mocker.Resolve<MockIndexer>() }); Mocker.SetConstant<IEnumerable<IndexerBase>>(new List<IndexerBase> { Mocker.Resolve<MockIndexer>() });
@ -46,7 +44,7 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test] [Test]
public void Init_indexer_with_disabled_job() public void Init_indexer_with_disabled_job()
{ {
Mocker.SetConstant(TestDbHelper.GetEmptyDatabase()); WithRealDb();
Mocker.SetConstant<IEnumerable<IndexerBase>>(new List<IndexerBase> { Mocker.Resolve<MockIndexer>() }); Mocker.SetConstant<IEnumerable<IndexerBase>>(new List<IndexerBase> { Mocker.Resolve<MockIndexer>() });
@ -65,7 +63,7 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test] [Test]
public void Init_indexer_should_enable_indexer_that_is_enabled_by_default() public void Init_indexer_should_enable_indexer_that_is_enabled_by_default()
{ {
Mocker.SetConstant(TestDbHelper.GetEmptyDatabase()); WithRealDb();
Mocker.SetConstant<IEnumerable<IndexerBase>>(new List<IndexerBase> { Mocker.Resolve<DefaultEnabledIndexer>() }); Mocker.SetConstant<IEnumerable<IndexerBase>>(new List<IndexerBase> { Mocker.Resolve<DefaultEnabledIndexer>() });
@ -82,7 +80,7 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test] [Test]
public void Init_indexer_should_not_enable_indexer_that_is_not_enabled_by_default() public void Init_indexer_should_not_enable_indexer_that_is_not_enabled_by_default()
{ {
Mocker.SetConstant(TestDbHelper.GetEmptyDatabase()); WithRealDb();
Mocker.SetConstant<IEnumerable<IndexerBase>>(new List<IndexerBase> { Mocker.Resolve<MockIndexer>() }); Mocker.SetConstant<IEnumerable<IndexerBase>>(new List<IndexerBase> { Mocker.Resolve<MockIndexer>() });

@ -37,13 +37,11 @@ namespace NzbDrone.Core.Test.ProviderTests
var database = TestDbHelper.GetEmptyDatabase(); WithRealDb();
database.InsertMany(firstSeriesFiles);
database.InsertMany(secondSeriesFiles);
Mocker.SetConstant(database); Db.InsertMany(firstSeriesFiles);
Db.InsertMany(secondSeriesFiles);
var result = Mocker.Resolve<MediaFileProvider>().GetSeriesFiles(12); var result = Mocker.Resolve<MediaFileProvider>().GetSeriesFiles(12);
@ -69,13 +67,10 @@ namespace NzbDrone.Core.Test.ProviderTests
.Build(); .Build();
WithRealDb();
var database = TestDbHelper.GetEmptyDatabase(); Db.InsertMany(firstSeriesFiles);
Db.InsertMany(secondSeriesFiles);
database.InsertMany(firstSeriesFiles);
database.InsertMany(secondSeriesFiles);
Mocker.SetConstant(database);
var result = Mocker.Resolve<MediaFileProvider>().GetSeasonFiles(12, 1); var result = Mocker.Resolve<MediaFileProvider>().GetSeasonFiles(12, 1);
@ -157,13 +152,12 @@ namespace NzbDrone.Core.Test.ProviderTests
.Build(); .Build();
var database = TestDbHelper.GetEmptyDatabase(); WithRealDb();
Mocker.SetConstant(database); Db.InsertMany(episodeFiles);
database.InsertMany(episodeFiles);
//Act //Act
Mocker.Resolve<MediaFileProvider>().Delete(1); Mocker.Resolve<MediaFileProvider>().Delete(1);
var result = database.Fetch<EpisodeFile>(); var result = Db.Fetch<EpisodeFile>();
//Assert //Assert
result.Should().HaveCount(9); result.Should().HaveCount(9);

@ -16,14 +16,15 @@ namespace NzbDrone.Core.Test.ProviderTests
// ReSharper disable InconsistentNaming // ReSharper disable InconsistentNaming
public class QualityTypeProviderTest : CoreTest public class QualityTypeProviderTest : CoreTest
{ {
[SetUp]
public void SetuUp()
{
WithRealDb();
}
[Test] [Test]
public void SetupDefault_should_add_all_profiles() public void SetupDefault_should_add_all_profiles()
{ {
var db = TestDbHelper.GetEmptyDatabase();
Mocker.SetConstant(db);
Mocker.Resolve<QualityTypeProvider>(); Mocker.Resolve<QualityTypeProvider>();
@ -45,11 +46,8 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test] [Test]
public void SetupDefault_already_exists_should_insert_missing() public void SetupDefault_already_exists_should_insert_missing()
{ {
var db = TestDbHelper.GetEmptyDatabase();
Mocker.SetConstant(db);
db.Insert(new QualityType { QualityTypeId = 1, Name = "SDTV", MinSize = 0, MaxSize = 100 }); Db.Insert(new QualityType { QualityTypeId = 1, Name = "SDTV", MinSize = 0, MaxSize = 100 });
Mocker.Resolve<QualityTypeProvider>(); Mocker.Resolve<QualityTypeProvider>();
@ -63,16 +61,12 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test] [Test]
public void GetList_single_quality_type() public void GetList_single_quality_type()
{ {
var db = TestDbHelper.GetEmptyDatabase();
Mocker.SetConstant(db);
var fakeQualityTypes = Builder<QualityType>.CreateListOfSize(6) var fakeQualityTypes = Builder<QualityType>.CreateListOfSize(6)
.Build(); .Build();
var ids = new List<int> { 1 }; var ids = new List<int> { 1 };
db.InsertMany(fakeQualityTypes); Db.InsertMany(fakeQualityTypes);
var result = Mocker.Resolve<QualityTypeProvider>().GetList(ids); var result = Mocker.Resolve<QualityTypeProvider>().GetList(ids);
@ -84,16 +78,12 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test] [Test]
public void GetList_multiple_quality_type() public void GetList_multiple_quality_type()
{ {
var db = TestDbHelper.GetEmptyDatabase();
Mocker.SetConstant(db);
var fakeQualityTypes = Builder<QualityType>.CreateListOfSize(6) var fakeQualityTypes = Builder<QualityType>.CreateListOfSize(6)
.Build(); .Build();
var ids = new List<int> { 1, 2 }; var ids = new List<int> { 1, 2 };
db.InsertMany(fakeQualityTypes); Db.InsertMany(fakeQualityTypes);
var result = Mocker.Resolve<QualityTypeProvider>().GetList(ids); var result = Mocker.Resolve<QualityTypeProvider>().GetList(ids);

@ -25,6 +25,8 @@ namespace NzbDrone.Core.Test.ProviderTests
{ {
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.ServiceRootUrl) Mocker.GetMock<ConfigProvider>().SetupGet(s => s.ServiceRootUrl)
.Returns("http://services.nzbdrone.com"); .Returns("http://services.nzbdrone.com");
WithRealDb();
} }
private void WithValidJson() private void WithValidJson()
@ -75,6 +77,7 @@ namespace NzbDrone.Core.Test.ProviderTests
.With(f => f.SceneName = "laworder") .With(f => f.SceneName = "laworder")
.Build(); .Build();
Db.Insert(fakeMap); Db.Insert(fakeMap);
//Act //Act
@ -96,6 +99,7 @@ namespace NzbDrone.Core.Test.ProviderTests
.With(f => f.SceneName = "laworder") .With(f => f.SceneName = "laworder")
.Build(); .Build();
Db.Insert(fakeMap); Db.Insert(fakeMap);
//Act //Act
@ -147,6 +151,8 @@ namespace NzbDrone.Core.Test.ProviderTests
.With(f => f.SeasonNumber = -1) .With(f => f.SeasonNumber = -1)
.Build(); .Build();
Db.Insert(fakeMap); Db.Insert(fakeMap);
Db.Insert(fakeMap2); Db.Insert(fakeMap2);
@ -177,8 +183,6 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test] [Test]
public void UpdateMappings_should_add_all_mappings_to_database() public void UpdateMappings_should_add_all_mappings_to_database()
{ {
//Setup
WithRealDb();
WithValidJson(); WithValidJson();
//Act //Act
@ -200,7 +204,6 @@ namespace NzbDrone.Core.Test.ProviderTests
.With(f => f.SceneName = "laworder") .With(f => f.SceneName = "laworder")
.Build(); .Build();
WithRealDb();
WithValidJson(); WithValidJson();
Db.Insert(fakeMap); Db.Insert(fakeMap);
@ -223,7 +226,6 @@ namespace NzbDrone.Core.Test.ProviderTests
.With(f => f.SceneName = "laworder") .With(f => f.SceneName = "laworder")
.Build(); .Build();
WithRealDb();
WithErrorDownloadingJson(); WithErrorDownloadingJson();
Db.Insert(fakeMap); Db.Insert(fakeMap);
@ -246,7 +248,6 @@ namespace NzbDrone.Core.Test.ProviderTests
.With(f => f.SceneName = "laworder") .With(f => f.SceneName = "laworder")
.Build(); .Build();
WithRealDb();
Db.Insert(fakeMap); Db.Insert(fakeMap);
//Act //Act
@ -260,7 +261,6 @@ namespace NzbDrone.Core.Test.ProviderTests
public void UpdateIfEmpty_should_update_if_count_is_zero() public void UpdateIfEmpty_should_update_if_count_is_zero()
{ {
//Setup //Setup
WithRealDb();
WithValidJson(); WithValidJson();
//Act //Act

@ -17,11 +17,16 @@ namespace NzbDrone.Core.Test
// ReSharper disable InconsistentNaming // ReSharper disable InconsistentNaming
public class QualityProfileTest : CoreTest<QualityProvider> public class QualityProfileTest : CoreTest<QualityProvider>
{ {
[SetUp]
public void SetUp()
{
WithRealDb();
}
[Test] [Test]
public void Test_Storage() public void Test_Storage()
{ {
//Arrange //Arrange
var database = TestDbHelper.GetEmptyDatabase();
var testProfile = new QualityProfile var testProfile = new QualityProfile
{ {
Name = Guid.NewGuid().ToString(), Name = Guid.NewGuid().ToString(),
@ -30,8 +35,8 @@ namespace NzbDrone.Core.Test
}; };
var id = Convert.ToInt32(database.Insert(testProfile)); var id = Convert.ToInt32(Db.Insert(testProfile));
var fetch = database.SingleOrDefault<QualityProfile>(id); var fetch = Db.SingleOrDefault<QualityProfile>(id);
Assert.AreEqual(id, fetch.QualityProfileId); Assert.AreEqual(id, fetch.QualityProfileId);
@ -45,7 +50,6 @@ namespace NzbDrone.Core.Test
public void Test_Storage_no_allowed() public void Test_Storage_no_allowed()
{ {
//Arrange //Arrange
var database = TestDbHelper.GetEmptyDatabase();
var testProfile = new QualityProfile var testProfile = new QualityProfile
{ {
Name = Guid.NewGuid().ToString(), Name = Guid.NewGuid().ToString(),
@ -53,8 +57,8 @@ namespace NzbDrone.Core.Test
}; };
var id = Convert.ToInt32(database.Insert(testProfile)); var id = Convert.ToInt32(Db.Insert(testProfile));
var fetch = database.SingleOrDefault<QualityProfile>(id); var fetch = Db.SingleOrDefault<QualityProfile>(id);
Assert.AreEqual(id, fetch.QualityProfileId); Assert.AreEqual(id, fetch.QualityProfileId);
@ -67,11 +71,6 @@ namespace NzbDrone.Core.Test
[Test] [Test]
public void Update_Success() public void Update_Success()
{ {
//Arrange
var db = TestDbHelper.GetEmptyDatabase();
Mocker.SetConstant(db);
var testProfile = new QualityProfile var testProfile = new QualityProfile
{ {
Name = Guid.NewGuid().ToString(), Name = Guid.NewGuid().ToString(),
@ -79,8 +78,8 @@ namespace NzbDrone.Core.Test
}; };
var id = Convert.ToInt32(db.Insert(testProfile)); var id = Convert.ToInt32(Db.Insert(testProfile));
var currentProfile = db.SingleOrDefault<QualityProfile>(id); var currentProfile = Db.SingleOrDefault<QualityProfile>(id);
//Update //Update
@ -99,9 +98,6 @@ namespace NzbDrone.Core.Test
[Test] [Test]
public void Test_Series_Quality() public void Test_Series_Quality()
{ {
//Arrange
var database = TestDbHelper.GetEmptyDatabase();
var testProfile = new QualityProfile var testProfile = new QualityProfile
{ {
Name = Guid.NewGuid().ToString(), Name = Guid.NewGuid().ToString(),
@ -110,18 +106,18 @@ namespace NzbDrone.Core.Test
}; };
var profileId = Convert.ToInt32(database.Insert(testProfile)); var profileId = Convert.ToInt32(Db.Insert(testProfile));
var series = Builder<Series>.CreateNew().Build(); var series = Builder<Series>.CreateNew().Build();
series.QualityProfileId = profileId; series.QualityProfileId = profileId;
database.Insert(testProfile); Db.Insert(testProfile);
database.Insert(series); Db.Insert(series);
var result = database.Fetch<Series>(); var result = Db.Fetch<Series>();
result.Should().HaveCount(1); result.Should().HaveCount(1);
var profile = database.SingleOrDefault<QualityProfile>(result[0].QualityProfileId); var profile = Db.SingleOrDefault<QualityProfile>(result[0].QualityProfileId);
Assert.AreEqual(profileId, result[0].QualityProfileId); Assert.AreEqual(profileId, result[0].QualityProfileId);
Assert.AreEqual(testProfile.Name, profile.Name); Assert.AreEqual(testProfile.Name, profile.Name);
} }
@ -131,10 +127,6 @@ namespace NzbDrone.Core.Test
public void SetupInitial_should_add_two_profiles() public void SetupInitial_should_add_two_profiles()
{ {
var db = TestDbHelper.GetEmptyDatabase();
Mocker.SetConstant(db);
Mocker.Resolve<QualityProvider>(); Mocker.Resolve<QualityProvider>();
@ -152,8 +144,6 @@ namespace NzbDrone.Core.Test
//We don't want to keep adding them back if a user deleted them on purpose. //We don't want to keep adding them back if a user deleted them on purpose.
public void SetupInitial_should_skip_if_any_profile_exists() public void SetupInitial_should_skip_if_any_profile_exists()
{ {
WithRealDb();
InitiateSubject(); InitiateSubject();
var profiles = Subject.All(); var profiles = Subject.All();

@ -32,7 +32,8 @@ namespace NzbDrone.Core.Test
[TestFixtureSetUp] [TestFixtureSetUp]
public void Setup() public void Setup()
{ {
db = TestDbHelper.GetEmptyDatabase(); WithRealDb();
int currentFileId = 0; int currentFileId = 0;
@ -42,7 +43,7 @@ namespace NzbDrone.Core.Test
Allowed = new List<QualityTypes> { QualityTypes.DVD, QualityTypes.Bluray1080p }, Allowed = new List<QualityTypes> { QualityTypes.DVD, QualityTypes.Bluray1080p },
Cutoff = QualityTypes.DVD Cutoff = QualityTypes.DVD
}; };
db.Insert(qulityProfile); Db.Insert(qulityProfile);
foreach (var _seriesId in seriesIds) foreach (var _seriesId in seriesIds)
{ {
@ -52,7 +53,7 @@ namespace NzbDrone.Core.Test
.With(s => s.Monitored = true) .With(s => s.Monitored = true)
.Build(); .Build();
db.Insert(series); Db.Insert(series);
foreach (var _seasonNumber in seasonsNumbers) foreach (var _seasonNumber in seasonsNumbers)
{ {
@ -94,8 +95,8 @@ namespace NzbDrone.Core.Test
} }
db.InsertMany(episodes); Db.InsertMany(episodes);
db.InsertMany(files); Db.InsertMany(files);
} }

@ -100,6 +100,13 @@
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\MiniProfiler.2.0.2\lib\net40\MiniProfiler.dll</HintPath> <HintPath>..\packages\MiniProfiler.2.0.2\lib\net40\MiniProfiler.dll</HintPath>
</Reference> </Reference>
<Reference Include="Nancy, Version=0.15.3.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Nancy.0.15.3\lib\net40\Nancy.dll</HintPath>
</Reference>
<Reference Include="Nancy.Hosting.Aspnet">
<HintPath>..\packages\Nancy.Hosting.Aspnet.0.15.3\lib\net40\Nancy.Hosting.Aspnet.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll</HintPath> <HintPath>..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll</HintPath>

@ -41,6 +41,7 @@
<remove name="UrlRoutingHandler" /> <remove name="UrlRoutingHandler" />
<add name="MvcHttpHandler" preCondition="integratedMode" verb="" path=".mvc" type="System.Web.Mvc.MvcHttpHandler" /> <add name="MvcHttpHandler" preCondition="integratedMode" verb="" path=".mvc" type="System.Web.Mvc.MvcHttpHandler" />
<add name="CassetteHttpHandler" path="cassette.axd" preCondition="integratedMode" verb="*" allowPathInfo="true" type="Cassette.Aspnet.CassetteHttpHandler, Cassette.Aspnet" /> <add name="CassetteHttpHandler" path="cassette.axd" preCondition="integratedMode" verb="*" allowPathInfo="true" type="Cassette.Aspnet.CassetteHttpHandler, Cassette.Aspnet" />
<add name="Nancy" verb="*" type="Nancy.Hosting.Aspnet.NancyHttpRequestHandler" path="*" />
</handlers> </handlers>
<directoryBrowse enabled="false" /> <directoryBrowse enabled="false" />
<staticContent> <staticContent>
@ -81,4 +82,22 @@
<add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" /> <add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
</DbProviderFactories> </DbProviderFactories>
</system.data> </system.data>
<location path="api" allowOverride="false">
<system.web>
<customErrors mode="Off" />
</system.web>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Cache-Control" value="no-cache, no-store, must-revalidate" />
<add name="Pragma" value="no-cache" />
<add name="Expires" value="0" />
</customHeaders>
</httpProtocol>
<handlers>
<add name="Nancy" verb="*" type="Nancy.Hosting.Aspnet.NancyHttpRequestHandler" path="*" />
</handlers>
<httpErrors errorMode="Detailed" />
</system.webServer>
</location>
</configuration> </configuration>

@ -26,6 +26,8 @@
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" /> <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" />
<package id="MiniProfiler" version="2.0.2" /> <package id="MiniProfiler" version="2.0.2" />
<package id="MiniProfiler.MVC3" version="2.0.2" /> <package id="MiniProfiler.MVC3" version="2.0.2" />
<package id="Nancy" version="0.15.3" targetFramework="net40" />
<package id="Nancy.Hosting.Aspnet" version="0.15.3" targetFramework="net40" />
<package id="Newtonsoft.Json" version="4.5.11" targetFramework="net40" /> <package id="Newtonsoft.Json" version="4.5.11" targetFramework="net40" />
<package id="NLog" version="2.0.0.2000" /> <package id="NLog" version="2.0.0.2000" />
<package id="ServiceStack.Text" version="3.9.27" targetFramework="net40" /> <package id="ServiceStack.Text" version="3.9.27" targetFramework="net40" />

Loading…
Cancel
Save