diff --git a/NzbDrone.Common.Test/PathExtentionFixture.cs b/NzbDrone.Common.Test/PathExtentionFixture.cs
index 29885d890..daf43a56f 100644
--- a/NzbDrone.Common.Test/PathExtentionFixture.cs
+++ b/NzbDrone.Common.Test/PathExtentionFixture.cs
@@ -62,17 +62,6 @@ namespace NzbDrone.Common.Test
GetEnviromentProvider().GetConfigPath().Should().BeEquivalentTo(@"C:\NzbDrone\Config.xml");
}
- [Test]
- public void IISConfig_path_test()
- {
- GetEnviromentProvider().GetIISConfigPath().Should().BeEquivalentTo(@"C:\NzbDrone\IISExpress\AppServer\applicationhost.config");
- }
-
- [Test]
- public void IISExe_path_test()
- {
- GetEnviromentProvider().GetIISExe().Should().BeEquivalentTo(@"C:\NzbDrone\IISExpress\IISExpress.exe");
- }
[Test]
public void NlogConfig_path_test()
diff --git a/NzbDrone.Common/PathExtentions.cs b/NzbDrone.Common/PathExtentions.cs
index 5edc05e6a..6886816fd 100644
--- a/NzbDrone.Common/PathExtentions.cs
+++ b/NzbDrone.Common/PathExtentions.cs
@@ -8,16 +8,12 @@ namespace NzbDrone.Common
private const string WEB_FOLDER = "NzbDrone.Web\\";
private const string APP_DATA = "App_Data\\";
private const string WEB_BIN = "bin\\";
- public const string IIS_FOLDER = "IISExpress";
- public const string IIS_EXE = "iisexpress.exe";
private const string LOG_CONFIG_FILE = "log.config";
private const string APP_CONFIG_FILE = "config.xml";
public const string NZBDRONE_EXE = "NzbDrone.exe";
- public const string NZBDRONE_SQLCE_DB_FILE = "nzbdrone.sdf";
- public const string LOG_SQLCE_DB_FILE = "log.sdf";
public const string OBJ_DB_FOLDER = "objDb";
private const string BACKUP_ZIP_FILE = "NzbDrone_Backup.zip";
@@ -45,20 +41,8 @@ namespace NzbDrone.Common
}
- public static string GetIISFolder(this EnvironmentProvider environmentProvider)
- {
- return Path.Combine(environmentProvider.ApplicationPath, IIS_FOLDER);
- }
- public static string GetIISExe(this EnvironmentProvider environmentProvider)
- {
- return Path.Combine(environmentProvider.GetIISFolder(), IIS_EXE);
- }
- public static string GetIISConfigPath(this EnvironmentProvider environmentProvider)
- {
- return Path.Combine(environmentProvider.GetIISFolder(), "AppServer", "applicationhost.config");
- }
public static string GetWebRoot(this EnvironmentProvider environmentProvider)
{
@@ -85,16 +69,6 @@ namespace NzbDrone.Common
return Path.Combine(environmentProvider.ApplicationPath, APP_CONFIG_FILE);
}
- public static string GetSqlCeMainDbPath(this EnvironmentProvider environmentProvider)
- {
- return Path.Combine(environmentProvider.GetAppDataPath(), NZBDRONE_SQLCE_DB_FILE);
- }
-
- public static string GetSqlCeLogDbPath(this EnvironmentProvider environmentProvider)
- {
- return Path.Combine(environmentProvider.GetAppDataPath(), LOG_SQLCE_DB_FILE);
- }
-
public static string GetObjectDbFolder(this EnvironmentProvider environmentProvider)
{
return Path.Combine(environmentProvider.GetAppDataPath(), OBJ_DB_FOLDER);
diff --git a/NzbDrone.Core.Test/App.config b/NzbDrone.Core.Test/App.config
index 1b714ac64..a7d3b0b7f 100644
--- a/NzbDrone.Core.Test/App.config
+++ b/NzbDrone.Core.Test/App.config
@@ -1,8 +1,5 @@
-
-
-
@@ -15,11 +12,4 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/NzbDrone.Core.Test/CentralDispatchFixture.cs b/NzbDrone.Core.Test/CentralDispatchFixture.cs
index 92e65ecde..ff6478a4d 100644
--- a/NzbDrone.Core.Test/CentralDispatchFixture.cs
+++ b/NzbDrone.Core.Test/CentralDispatchFixture.cs
@@ -36,11 +36,6 @@ namespace NzbDrone.Core.Test
public CentralDispatchFixture()
{
- if (EnvironmentProvider.IsMono)
- {
- throw new IgnoreException("SqlCe is not supported");
- }
-
InitLogging();
}
@@ -116,11 +111,6 @@ namespace NzbDrone.Core.Test
kernel.Resolve().All().Select(c => c.Type).Should().BeEquivalentTo(indexers);
}
- [Test]
- public void metadata_clients_are_initialized()
- {
- kernel.Resolve().All().Should().HaveSameCount(metadata);
- }
[Test]
public void quality_profile_initialized()
diff --git a/NzbDrone.Core.Test/Configuration/ConfigCachingFixture.cs b/NzbDrone.Core.Test/Configuration/ConfigCachingFixture.cs
index 19922c002..b4893b8b5 100644
--- a/NzbDrone.Core.Test/Configuration/ConfigCachingFixture.cs
+++ b/NzbDrone.Core.Test/Configuration/ConfigCachingFixture.cs
@@ -5,7 +5,7 @@ using Moq;
using NUnit.Framework;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Test.Framework;
-using PetaPoco;
+
namespace NzbDrone.Core.Test.Configuration
{
diff --git a/NzbDrone.Core.Test/Framework/SqlCeTest.cs b/NzbDrone.Core.Test/Framework/SqlCeTest.cs
deleted file mode 100644
index 3d5a5bf62..000000000
--- a/NzbDrone.Core.Test/Framework/SqlCeTest.cs
+++ /dev/null
@@ -1,146 +0,0 @@
-using System;
-using System.IO;
-using NUnit.Framework;
-using NzbDrone.Common;
-using NzbDrone.Core.Configuration;
-using NzbDrone.Core.Datastore;
-using NzbDrone.Core.Model.Notification;
-using NzbDrone.Core.Providers.Core;
-using NzbDrone.Test.Common;
-using PetaPoco;
-
-namespace NzbDrone.Core.Test.Framework
-{
- public abstract class SqlCeTest : CoreTest
- {
- private string _dbTemplateName;
-
- [SetUp]
- public void CoreTestSetup()
- {
- if (EnvironmentProvider.IsMono)
- {
- throw new IgnoreException("SqlCe is not supported in mono.");
- }
-
- if (NCrunch.Framework.NCrunchEnvironment.NCrunchIsResident())
- {
- _dbTemplateName = Path.Combine(Path.GetTempPath(), Path.GetTempFileName()) + ".sdf";
- }
- else
- {
- _dbTemplateName = "db_template.sdf";
- }
-
- CreateDataBaseTemplate();
- }
-
- private 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);
-
- var connectionString = ConnectionFactory.GetConnectionString(fileName);
- var database = ConnectionFactory.GetPetaPocoDb(connectionString);
-
- Console.WriteLine("====================DataBase====================");
- Console.WriteLine();
- Console.WriteLine();
-
- 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;
- protected IDatabase Db
- {
- get
- {
- if (_db == null)
- throw new InvalidOperationException("Test db doesn't exists. Make sure you call WithRealDb() if you intend to use an actual database.");
-
- return _db;
- }
- }
-
-
-
- protected void WithRealDb()
- {
- if (EnvironmentProvider.IsMono)
- {
- throw new IgnoreException("SqlCe is not supported in mono.");
- }
-
- _db = GetEmptyDatabase();
- Mocker.SetConstant(Db);
- }
-
-
- [TearDown]
- public void CoreTestTearDown()
- {
- ConfigService.ClearCache();
-
- if (EnvironmentProvider.IsMono)
- {
- return;
- }
-
- if (_db != null && _db.Connection != null && File.Exists(_db.Connection.Database))
- {
- var file = _db.Connection.Database;
- _db.Dispose();
- try
- {
- File.Delete(file);
-
- }
- catch (IOException) { }
- }
- }
- }
-
- public abstract class SqlCeTest : SqlCeTest where TSubject : class
- {
-
- private TSubject _subject;
-
-
- protected TSubject Subject
- {
- get
- {
- if (_subject == null)
- {
- _subject = Mocker.Resolve();
- }
-
- return _subject;
-
- }
- }
-
-
- protected void InitiateSubject()
- {
- _subject = Mocker.Resolve();
- }
- }
-}
diff --git a/NzbDrone.Core.Test/Framework/TestDbHelper.cs b/NzbDrone.Core.Test/Framework/TestDbHelper.cs
index 8ff54d2fa..8d87c13e9 100644
--- a/NzbDrone.Core.Test/Framework/TestDbHelper.cs
+++ b/NzbDrone.Core.Test/Framework/TestDbHelper.cs
@@ -9,7 +9,7 @@ using NzbDrone.Common;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
-using PetaPoco;
+
namespace NzbDrone.Core.Test.Framework
{
diff --git a/NzbDrone.Core.Test/JobTests/EpisodeSearchJobTest.cs b/NzbDrone.Core.Test/JobTests/EpisodeSearchJobTest.cs
deleted file mode 100644
index 4dfe89779..000000000
--- a/NzbDrone.Core.Test/JobTests/EpisodeSearchJobTest.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using System;
-
-using Moq;
-using NUnit.Framework;
-using NzbDrone.Core.Jobs;
-using NzbDrone.Core.Model.Notification;
-using NzbDrone.Core.Test.Framework;
-using NzbDrone.Test.Common.AutoMoq;
-
-namespace NzbDrone.Core.Test.JobTests
-{
- [TestFixture]
- public class EpisodeSearchJobTest:SqlCeTest
- {
- [TestCase(0)]
- [TestCase(-1)]
- [TestCase(-100)]
- [ExpectedException(typeof(ArgumentException))]
- public void start_target_id_less_than_0_throws_exception(int target)
- {
- WithStrictMocker();
- Mocker.Resolve().Start(new ProgressNotification("Test"), new { EpisodeId = target });
- }
-
- [TestCase(-1)]
- [TestCase(-100)]
- [ExpectedException(typeof(ArgumentException))]
- public void start_secondary_target_id_less_than_0_throws_exception(int target)
- {
- WithStrictMocker();
- Mocker.Resolve().Start(new ProgressNotification("Test"), new { SeriesId = 1, SeasonNumber = target });
- }
- }
-}
diff --git a/NzbDrone.Core.Test/JobTests/RenameSeasonJobFixture.cs b/NzbDrone.Core.Test/JobTests/RenameSeasonJobFixture.cs
index 457b5ca9f..b690492be 100644
--- a/NzbDrone.Core.Test/JobTests/RenameSeasonJobFixture.cs
+++ b/NzbDrone.Core.Test/JobTests/RenameSeasonJobFixture.cs
@@ -75,21 +75,6 @@ namespace NzbDrone.Core.Test.JobTests
ExceptionVerification.ExpectedWarns(1);
}
- [Test]
- public void should_return_if_no_episodes_are_moved()
- {
- Mocker.Resolve().Start(_testNotification, new { SeriesId = _series.Id, SeasonNumber = 5 });
-
- Mocker.GetMock().Verify(v => v.RemoveForEpisodeFiles(It.IsAny>()), Times.Never());
- }
-
- [Test]
- public void should_return_process_metadata_if_files_are_moved()
- {
- WithMovedFiles();
- Mocker.Resolve().Start(_testNotification, new { SeriesId = _series.Id, SeasonNumber = 5 });
-
- Mocker.GetMock().Verify(v => v.RemoveForEpisodeFiles(It.IsAny>()), Times.Once());
- }
+
}
}
diff --git a/NzbDrone.Core.Test/MediaFileTests/CleanUpDatabaseFixture.cs b/NzbDrone.Core.Test/MediaFileTests/CleanUpDatabaseFixture.cs
deleted file mode 100644
index b56a8b313..000000000
--- a/NzbDrone.Core.Test/MediaFileTests/CleanUpDatabaseFixture.cs
+++ /dev/null
@@ -1,132 +0,0 @@
-using System;
-using System.Linq;
-using FizzWare.NBuilder;
-using FluentAssertions;
-using NUnit.Framework;
-using NzbDrone.Core.Configuration;
-using NzbDrone.Core.MediaFiles;
-using NzbDrone.Core.Qualities;
-using NzbDrone.Core.Tv;
-using NzbDrone.Core.Model;
-using NzbDrone.Core.Test.Framework;
-
-namespace NzbDrone.Core.Test.MediaFileTests
-{
- [TestFixture]
- public class CleanUpDatabaseFixture : SqlCeTest
- {
-
- [SetUp]
- public void Setup()
- {
- WithRealDb();
- }
-
- private void WithAutoIgnore(bool autoIgnore)
- {
-
- Mocker.GetMock()
- .SetupGet(c => c.AutoIgnorePreviouslyDownloadedEpisodes).Returns(autoIgnore);
- }
-
-
-
- [Test]
- public void CleanUpDatabse_should_detach_none_existing_file_from_episodes_with_auto_ignore()
- {
- WithAutoIgnore(true);
-
- var episodes = Builder.CreateListOfSize(3)
- .All().With(c => c.GrabDate = DateTime.Now)
- .And(c => c.Ignored = false)
- .And(c => c.PostDownloadStatus = PostDownloadStatusType.NoError)
- .Build();
-
-
- Db.InsertMany(episodes);
-
- //Act
- var result = Db.Fetch();
-
- //Assert
- result.Should().HaveSameCount(episodes);
- result.Should().OnlyContain(e => e.EpisodeFileId == 0);
- result.Should().OnlyContain(e => e.PostDownloadStatus == PostDownloadStatusType.Unknown);
- result.Should().OnlyContain(e => e.Ignored);
- result.Should().OnlyContain(e => e.GrabDate == null);
- }
-
- [Test]
- public void CleanUpDatabse_should_detach_none_existing_file_from_episodes_with_no_auto_ignore()
- {
- WithAutoIgnore(false);
-
- var episodes = Builder.CreateListOfSize(3)
- .All().With(c => c.GrabDate = DateTime.Now)
- .And(c => c.PostDownloadStatus = PostDownloadStatusType.NoError)
- .TheFirst(2).With(c => c.Ignored = true)
- .TheLast(1).With(c => c.Ignored = false)
- .Build();
-
-
- Db.InsertMany(episodes);
-
- //Act
- var result = Db.Fetch();
-
- //Assert
- result.Should().HaveSameCount(episodes);
- result.Should().OnlyContain(e => e.EpisodeFileId == 0);
- result.Should().OnlyContain(e => e.PostDownloadStatus == PostDownloadStatusType.Unknown);
- result.Should().OnlyContain(e => e.GrabDate == null);
- result.Should().Contain(c => c.Ignored == true);
- result.Should().Contain(c => c.Ignored == false);
- }
-
- [Test]
- public void CleanUpDatabse_should_not_change_episodes_with_no_file_id()
- {
- //Setup
- var episodes = Builder.CreateListOfSize(3)
- .All().With(c => c.GrabDate = DateTime.Now)
- .And(c => c.Ignored = false)
- .And(c => c.PostDownloadStatus = PostDownloadStatusType.NoError)
- .Build();
-
- Db.InsertMany(episodes);
-
- //Act
- var result = Db.Fetch();
-
- //Assert
- result.Should().HaveSameCount(episodes);
- result.Should().OnlyContain(e => e.EpisodeFileId == 0);
- result.Should().NotContain(e => e.PostDownloadStatus == PostDownloadStatusType.Unknown);
- result.Should().NotContain(e => e.Ignored);
- result.Should().NotContain(e => e.GrabDate == null);
- }
-
-
- [Test]
- public void DeleteOrphanedEpisodeFiles()
- {
- //Setup
- var episodeFiles = Builder
- .CreateListOfSize(10)
- .All()
- .With(e => e.Quality = Quality.DVD)
- .Build();
- var episodes = Builder.CreateListOfSize(5).Build();
-
- Db.InsertMany(episodes);
- Db.InsertMany(episodeFiles);
-
- //Act
- var result = Db.Fetch();
-
- //Assert
- result.Should().HaveCount(5);
- result.Should().OnlyContain(e => e.Id > 0);
- }
- }
-}
diff --git a/NzbDrone.Core.Test/MediaFileTests/MediaFileServiceTest.cs b/NzbDrone.Core.Test/MediaFileTests/MediaFileServiceTest.cs
index 34bf42817..a5db8ec50 100644
--- a/NzbDrone.Core.Test/MediaFileTests/MediaFileServiceTest.cs
+++ b/NzbDrone.Core.Test/MediaFileTests/MediaFileServiceTest.cs
@@ -19,7 +19,7 @@ namespace NzbDrone.Core.Test.MediaFileTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
- public class MediaFileServiceTest : SqlCeTest
+ public class MediaFileServiceTest : ObjectDbTest
{
[Test]
public void get_series_files()
@@ -36,8 +36,6 @@ namespace NzbDrone.Core.Test.MediaFileTests
- WithRealDb();
-
Db.InsertMany(firstSeriesFiles);
Db.InsertMany(secondSeriesFiles);
@@ -66,7 +64,6 @@ namespace NzbDrone.Core.Test.MediaFileTests
.Build();
- WithRealDb();
Db.InsertMany(firstSeriesFiles);
Db.InsertMany(secondSeriesFiles);
@@ -148,23 +145,18 @@ namespace NzbDrone.Core.Test.MediaFileTests
.Build();
- WithRealDb();
Db.InsertMany(episodeFiles);
//Act
Mocker.Resolve().Delete(1);
- var result = Db.Fetch();
- //Assert
- result.Should().HaveCount(9);
- result.Should().NotContain(e => e.Id == 1);
+
}
[Test]
public void GetFileByPath_should_return_null_if_file_does_not_exist_in_database()
{
//Setup
- WithRealDb();
//Act
var result = Mocker.Resolve().GetFileByPath(@"C:\Test\EpisodeFile.avi");
@@ -179,7 +171,6 @@ namespace NzbDrone.Core.Test.MediaFileTests
var path = @"C:\Test\EpisodeFile.avi";
//Setup
- WithRealDb();
var episodeFile = Builder.CreateNew()
.With(c => c.Quality = Quality.SDTV)
.With(f => f.Path = path.NormalizePath())
diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
index f1adc1f45..12bbdb5a2 100644
--- a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
+++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
@@ -199,8 +199,6 @@
-
-
@@ -209,7 +207,6 @@
-
@@ -233,7 +230,6 @@
-
diff --git a/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDownloadFixture.cs b/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDownloadFixture.cs
index a43d92355..20edfd049 100644
--- a/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDownloadFixture.cs
+++ b/NzbDrone.Core.Test/ProviderTests/PostDownloadProviderTests/ProcessDownloadFixture.cs
@@ -303,7 +303,6 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
Mocker.GetMock().Setup(s => s.DeleteFolder(droppedFolder.FullName, true));
Mocker.GetMock().Setup(s => s.FolderExists(fakeSeries.Path)).Returns(true);
Mocker.GetMock().Setup(s => s.IsFolderLocked(droppedFolder.FullName)).Returns(false);
- Mocker.GetMock().Setup(s => s.CreateForEpisodeFiles(It.IsAny>()));
//Act
Mocker.Resolve().ProcessDownload(droppedFolder);
diff --git a/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/CleanupFixture.cs b/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/CleanupFixture.cs
index 73bae6228..91e1c3287 100644
--- a/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/CleanupFixture.cs
+++ b/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/CleanupFixture.cs
@@ -17,7 +17,7 @@ using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common.AutoMoq;
-using PetaPoco;
+
using TvdbLib.Data;
namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests
diff --git a/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/DeleteDirectoryFixture.cs b/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/DeleteDirectoryFixture.cs
index 35da6fbc8..eaa0c90ed 100644
--- a/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/DeleteDirectoryFixture.cs
+++ b/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/DeleteDirectoryFixture.cs
@@ -17,7 +17,7 @@ using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common.AutoMoq;
-using PetaPoco;
+
using TvdbLib.Data;
namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests
diff --git a/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/DeleteFileFixture.cs b/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/DeleteFileFixture.cs
index 5c334642e..586d8e12d 100644
--- a/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/DeleteFileFixture.cs
+++ b/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/DeleteFileFixture.cs
@@ -17,7 +17,7 @@ using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common.AutoMoq;
-using PetaPoco;
+
using TvdbLib.Data;
namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests
diff --git a/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/EmptyFixture.cs b/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/EmptyFixture.cs
index 4f675d522..e6c6086d2 100644
--- a/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/EmptyFixture.cs
+++ b/NzbDrone.Core.Test/ProviderTests/RecycleBinProviderTests/EmptyFixture.cs
@@ -17,7 +17,7 @@ using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common.AutoMoq;
-using PetaPoco;
+
using TvdbLib.Data;
namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests
diff --git a/NzbDrone.Core.Test/ProviderTests/ReferenceDataProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/ReferenceDataProviderTest.cs
deleted file mode 100644
index ccecf58a1..000000000
--- a/NzbDrone.Core.Test/ProviderTests/ReferenceDataProviderTest.cs
+++ /dev/null
@@ -1,212 +0,0 @@
-using System;
-using System.Linq;
-using System.Net;
-using FizzWare.NBuilder;
-using FluentAssertions;
-using Moq;
-using NUnit.Framework;
-using NzbDrone.Common;
-using NzbDrone.Core.Configuration;
-using NzbDrone.Core.Tv;
-using NzbDrone.Core.Providers;
-using NzbDrone.Core.Providers.Core;
-using NzbDrone.Core.Test.Framework;
-using NzbDrone.Test.Common;
-
-namespace NzbDrone.Core.Test.ProviderTests
-{
- [TestFixture]
- // ReSharper disable InconsistentNaming
- public class ReferenceDataProviderTest : SqlCeTest
- {
- private const string validSeriesIds = "[1,2,3,4,5]";
- private const string invalidSeriesIds = "[1,2,NaN,4,5]";
-
- private const string url = "http://services.nzbdrone.com/DailySeries/AllIds";
-
- [SetUp]
- public void Setup()
- {
- Mocker.GetMock().SetupGet(s => s.ServiceRootUrl)
- .Returns("http://services.nzbdrone.com");
- }
-
-
- [Test]
- public void GetDailySeriesIds_should_return_list_of_int_when_all_are_valid()
- {
- //Setup
- Mocker.GetMock().Setup(s => s.DownloadString(url))
- .Returns(validSeriesIds);
-
- //Act
- var result = Mocker.Resolve().GetDailySeriesIds();
-
- //Assert
- result.Should().HaveCount(5);
- }
-
- [Test]
- public void GetDailySeriesIds_should_return_empty_list_when_unable_to_parse()
- {
- //Setup
- Mocker.GetMock().Setup(s => s.DownloadString(url))
- .Returns(invalidSeriesIds);
-
- //Act
- var result = Mocker.Resolve().GetDailySeriesIds();
-
- //Assert
- result.Should().BeEmpty();
- ExceptionVerification.ExpectedWarns(1);
- }
-
- [Test]
- public void GetDailySeriesIds_should_return_empty_list_of_int_when_server_is_unavailable()
- {
- //Setup
- Mocker.GetMock().Setup(s => s.DownloadString(url))
- .Throws(new Exception());
-
- //Act
- var result = Mocker.Resolve().GetDailySeriesIds();
-
- //Assert
- result.Should().HaveCount(0);
- ExceptionVerification.ExpectedWarns(1);
- }
-
- [Test]
- public void IsDailySeries_should_return_true()
- {
- //Setup
- Mocker.GetMock().Setup(s => s.DownloadString(url))
- .Returns(validSeriesIds);
-
- //Act
- var result = Mocker.Resolve().IsSeriesDaily(1);
-
- //Assert
- result.Should().BeTrue();
- }
-
- [Test]
- public void IsDailySeries_should_return_false()
- {
- //Setup
- Mocker.GetMock().Setup(s => s.DownloadString(url))
- .Returns(validSeriesIds);
-
- //Act
- var result = Mocker.Resolve().IsSeriesDaily(10);
-
- //Assert
- result.Should().BeFalse();
- }
-
- [Test]
- public void UpdateDailySeries_should_update_series_that_match_daily_series_list()
- {
- WithRealDb();
-
- var fakeSeries = Builder.CreateListOfSize(5)
- .All()
- .With(s => s.SeriesType = SeriesType.Standard)
- .Build();
-
- Db.InsertMany(fakeSeries);
-
- //Setup
- Mocker.GetMock().Setup(s => s.DownloadString(url))
- .Returns(validSeriesIds);
-
- //Act
- Mocker.Resolve().UpdateDailySeries();
-
- //Assert
- var result = Db.Fetch();
-
- result.Where(s => s.SeriesType == SeriesType.Daily).Should().HaveCount(5);
- }
-
- [Test]
- public void UpdateDailySeries_should_update_series_should_skip_series_that_dont_match()
- {
- WithRealDb();
-
- var fakeSeries = Builder.CreateListOfSize(5)
- .All()
- .With(s => s.SeriesType = SeriesType.Standard)
- .TheFirst(1)
- .With(s => s.Id = 10)
- .TheNext(1)
- .With(s => s.Id = 11)
- .TheNext(1)
- .With(s => s.Id = 12)
- .Build();
-
- Db.InsertMany(fakeSeries);
-
- //Setup
- Mocker.GetMock().Setup(s => s.DownloadString(url))
- .Returns(validSeriesIds);
-
- //Act
- Mocker.Resolve().UpdateDailySeries();
-
- //Assert
- var result = Db.Fetch();
-
- result.Where(s => s.SeriesType == SeriesType.Standard).Should().HaveCount(3);
- result.Where(s => s.SeriesType == SeriesType.Daily).Should().HaveCount(2);
- }
-
- [Test]
- public void UpdateDailySeries_should_update_series_should_not_overwrite_existing_isDaily()
- {
- WithRealDb();
-
- var fakeSeries = Builder.CreateListOfSize(5)
- .All()
- .With(s => s.SeriesType = SeriesType.Standard)
- .TheFirst(1)
- .With(s => s.Id = 10)
- .With(s => s.SeriesType = SeriesType.Daily)
- .TheNext(1)
- .With(s => s.Id = 11)
- .TheNext(1)
- .With(s => s.Id = 12)
- .Build();
-
- Db.InsertMany(fakeSeries);
-
- //Setup
- Mocker.GetMock().Setup(s => s.DownloadString(url))
- .Returns(validSeriesIds);
-
- //Act
- Mocker.Resolve().UpdateDailySeries();
-
- //Assert
- var result = Db.Fetch();
-
- result.Where(s => s.SeriesType == SeriesType.Daily).Should().HaveCount(3);
- result.Where(s => s.SeriesType == SeriesType.Standard).Should().HaveCount(2);
- }
-
- [Test]
- public void broken_service_should_not_cause_this_call_to_fail()
- {
- WithRealDb();
-
- Mocker.GetMock().Setup(s => s.DownloadString(It.IsAny()))
- .Throws(new WebException())
- .Verifiable();
-
- Mocker.Resolve().UpdateDailySeries();
-
- ExceptionVerification.ExpectedWarns(1);
- Mocker.VerifyAllMocks();
- }
- }
-}
\ No newline at end of file
diff --git a/NzbDrone.Core.Test/ProviderTests/SceneMappingProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/SceneMappingProviderTest.cs
index a5017ec5d..65b49f8e5 100644
--- a/NzbDrone.Core.Test/ProviderTests/SceneMappingProviderTest.cs
+++ b/NzbDrone.Core.Test/ProviderTests/SceneMappingProviderTest.cs
@@ -7,17 +7,14 @@ using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
-using NzbDrone.Core.Providers;
-using NzbDrone.Core.Providers.Core;
-using NzbDrone.Core.Repository;
+using NzbDrone.Core.ReferenceData;
using NzbDrone.Core.Test.Framework;
-using NzbDrone.Test.Common.AutoMoq;
namespace NzbDrone.Core.Test.ProviderTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
- public class SceneMappingProviderTest : SqlCeTest
+ public class SceneMappingProviderTest : ObjectDbTest
{
private const string SceneMappingUrl = "http://services.nzbdrone.com/SceneMapping/Active";
@@ -27,7 +24,6 @@ namespace NzbDrone.Core.Test.ProviderTests
Mocker.GetMock().SetupGet(s => s.ServiceRootUrl)
.Returns("http://services.nzbdrone.com");
- WithRealDb();
}
private void WithValidJson()
@@ -47,12 +43,11 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test]
public void GetSceneName_exists()
{
- WithRealDb();
//Setup
var fakeMap = Builder.CreateNew()
.With(f => f.CleanTitle = "laworder")
- .With(f => f.SeriesId = 12345)
+ .With(f => f.TvdbId = 12345)
.With(f => f.SceneName = "Law and Order")
.With(f => f.SeasonNumber = -1)
.Build();
@@ -60,7 +55,7 @@ namespace NzbDrone.Core.Test.ProviderTests
Db.Insert(fakeMap);
//Act
- var sceneName = Mocker.Resolve().GetSceneName(fakeMap.SeriesId);
+ var sceneName = Mocker.Resolve().GetSceneName(fakeMap.TvdbId);
//Assert
Assert.AreEqual(fakeMap.SceneName, sceneName);
@@ -69,11 +64,10 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test]
public void GetSeriesId_exists()
{
- WithRealDb();
//Setup
var fakeMap = Builder.CreateNew()
- .With(f => f.SeriesId = 12345)
+ .With(f => f.TvdbId = 12345)
.With(f => f.SceneName = "Law and Order")
.With(f => f.SceneName = "laworder")
.Build();
@@ -82,20 +76,19 @@ namespace NzbDrone.Core.Test.ProviderTests
Db.Insert(fakeMap);
//Act
- var seriesId = Mocker.Resolve().GetSeriesId(fakeMap.CleanTitle);
+ var seriesId = Mocker.Resolve().GetTvDbId(fakeMap.CleanTitle);
//Assert
- Assert.AreEqual(fakeMap.SeriesId, seriesId);
+ Assert.AreEqual(fakeMap.TvdbId, seriesId);
}
[Test]
public void GetSceneName_null()
{
- WithRealDb();
//Setup
var fakeMap = Builder.CreateNew()
- .With(f => f.SeriesId = 12345)
+ .With(f => f.TvdbId = 12345)
.With(f => f.SceneName = "Law and Order")
.With(f => f.SceneName = "laworder")
.Build();
@@ -104,7 +97,7 @@ namespace NzbDrone.Core.Test.ProviderTests
Db.Insert(fakeMap);
//Act
- var sceneName = Mocker.Resolve().GetSceneName(54321);
+ var sceneName = Mocker.Resolve().GetSceneName(54321);
//Assert
Assert.AreEqual(null, sceneName);
@@ -113,11 +106,10 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test]
public void GetSeriesId_null()
{
- WithRealDb();
//Setup
var fakeMap = Builder.CreateNew()
- .With(f => f.SeriesId = 12345)
+ .With(f => f.TvdbId = 12345)
.With(f => f.SceneName = "Law and Order")
.With(f => f.CleanTitle = "laworder")
.Build();
@@ -125,7 +117,7 @@ namespace NzbDrone.Core.Test.ProviderTests
Db.Insert(fakeMap);
//Act
- var seriesId = Mocker.Resolve().GetSeriesId("notlaworder");
+ var seriesId = Mocker.Resolve().GetTvDbId("notlaworder");
//Assert
Assert.AreEqual(null, seriesId);
@@ -134,20 +126,19 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test]
public void GetSceneName_multiple_clean_names()
{
- WithRealDb();
//Test that ensures a series with clean names (office, officeus) can be looked up by seriesId
//Setup
var fakeMap = Builder.CreateNew()
.With(f => f.CleanTitle = "office")
- .With(f => f.SeriesId = 12345)
+ .With(f => f.TvdbId = 12345)
.With(f => f.SceneName = "The Office")
.With(f => f.SeasonNumber = -1)
.Build();
var fakeMap2 = Builder.CreateNew()
.With(f => f.CleanTitle = "officeus")
- .With(f => f.SeriesId = 12345)
+ .With(f => f.TvdbId = 12345)
.With(f => f.SceneName = "The Office")
.With(f => f.SeasonNumber = -1)
.Build();
@@ -158,7 +149,7 @@ namespace NzbDrone.Core.Test.ProviderTests
Db.Insert(fakeMap2);
//Act
- var sceneName = Mocker.Resolve().GetSceneName(fakeMap.SeriesId);
+ var sceneName = Mocker.Resolve().GetSceneName(fakeMap.TvdbId);
//Assert
Assert.AreEqual(fakeMap.SceneName, sceneName);
@@ -167,10 +158,10 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test]
public void GetSceneName_should_be_null_when_seasonNumber_does_not_match()
{
- WithRealDb();
+
var fakeMap = Builder.CreateNew()
- .With(f => f.SeriesId = 12345)
+ .With(f => f.TvdbId = 12345)
.With(f => f.SceneName = "Law and Order")
.With(f => f.SceneName = "laworder")
.With(f => f.SeasonNumber = 10)
@@ -178,7 +169,7 @@ namespace NzbDrone.Core.Test.ProviderTests
Db.Insert(fakeMap);
- Mocker.Resolve().GetSceneName(54321, 5).Should().BeNull();
+ Mocker.Resolve().GetSceneName(54321, 5).Should().BeNull();
}
[Test]
@@ -187,12 +178,10 @@ namespace NzbDrone.Core.Test.ProviderTests
WithValidJson();
//Act
- Mocker.Resolve().UpdateMappings();
+ Mocker.Resolve().UpdateMappings();
//Assert
Mocker.Verify(v => v.DownloadString(SceneMappingUrl), Times.Once());
- var result = Db.Fetch();
- result.Should().HaveCount(5);
}
[Test]
@@ -200,7 +189,7 @@ namespace NzbDrone.Core.Test.ProviderTests
{
//Setup
var fakeMap = Builder.CreateNew()
- .With(f => f.SeriesId = 12345)
+ .With(f => f.TvdbId = 12345)
.With(f => f.SceneName = "Law and Order")
.With(f => f.SceneName = "laworder")
.Build();
@@ -209,12 +198,10 @@ namespace NzbDrone.Core.Test.ProviderTests
Db.Insert(fakeMap);
//Act
- Mocker.Resolve().UpdateMappings();
+ Mocker.Resolve().UpdateMappings();
//Assert
Mocker.Verify(v => v.DownloadString(SceneMappingUrl), Times.Once());
- var result = Db.Fetch();
- result.Should().HaveCount(5);
}
[Test]
@@ -222,7 +209,7 @@ namespace NzbDrone.Core.Test.ProviderTests
{
//Setup
var fakeMap = Builder.CreateNew()
- .With(f => f.SeriesId = 12345)
+ .With(f => f.TvdbId = 12345)
.With(f => f.SceneName = "Law and Order")
.With(f => f.SceneName = "laworder")
.Build();
@@ -231,46 +218,11 @@ namespace NzbDrone.Core.Test.ProviderTests
Db.Insert(fakeMap);
//Act
- Mocker.Resolve().UpdateMappings();
+ Mocker.Resolve().UpdateMappings();
//Assert
Mocker.Verify(v => v.DownloadString(SceneMappingUrl), Times.Once());
- var result = Db.Fetch();
- result.Should().HaveCount(1);
}
- [Test]
- public void UpdateIfEmpty_should_not_update_if_count_is_not_zero()
- {
- //Setup
- var fakeMap = Builder.CreateNew()
- .With(f => f.SeriesId = 12345)
- .With(f => f.SceneName = "Law and Order")
- .With(f => f.SceneName = "laworder")
- .Build();
-
- Db.Insert(fakeMap);
-
- //Act
- Mocker.Resolve().UpdateIfEmpty();
-
- //Assert
- Mocker.Verify(v => v.DownloadString(SceneMappingUrl), Times.Never());
- }
-
- [Test]
- public void UpdateIfEmpty_should_update_if_count_is_zero()
- {
- //Setup
- WithValidJson();
-
- //Act
- Mocker.Resolve().UpdateIfEmpty();
-
- //Assert
- Mocker.Verify(v => v.DownloadString(SceneMappingUrl), Times.Once());
- var result = Db.Fetch();
- result.Should().HaveCount(5);
- }
}
}
diff --git a/NzbDrone.Core.Test/ProviderTests/SearchTests/GetSearchTitleFixture.cs b/NzbDrone.Core.Test/ProviderTests/SearchTests/GetSearchTitleFixture.cs
index 5f3ae7b74..1cdde80d1 100644
--- a/NzbDrone.Core.Test/ProviderTests/SearchTests/GetSearchTitleFixture.cs
+++ b/NzbDrone.Core.Test/ProviderTests/SearchTests/GetSearchTitleFixture.cs
@@ -5,6 +5,7 @@ using System.Text;
using FizzWare.NBuilder;
using FluentAssertions;
using NUnit.Framework;
+using NzbDrone.Core.ReferenceData;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Search;
@@ -28,7 +29,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests
private void WithSceneMapping()
{
- Mocker.GetMock()
+ Mocker.GetMock()
.Setup(s => s.GetSceneName(_series.Id, -1))
.Returns("Hawaii Five 0 2010");
}
@@ -52,7 +53,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests
[Test]
public void should_return_season_scene_name_when_one_exists()
{
- Mocker.GetMock()
+ Mocker.GetMock()
.Setup(s => s.GetSceneName(_series.Id, 5))
.Returns("Hawaii Five 0 2010 - Season 5");
@@ -85,7 +86,7 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests
{
_series.Title = input;
- Mocker.GetMock()
+ Mocker.GetMock()
.Setup(s => s.GetSceneName(_series.Id, -1))
.Returns("");
diff --git a/NzbDrone.Core.Test/ProviderTests/SearchTests/TestSearch.cs b/NzbDrone.Core.Test/ProviderTests/SearchTests/TestSearch.cs
index 19a0cddc7..b75e148da 100644
--- a/NzbDrone.Core.Test/ProviderTests/SearchTests/TestSearch.cs
+++ b/NzbDrone.Core.Test/ProviderTests/SearchTests/TestSearch.cs
@@ -6,6 +6,7 @@ using System.Threading.Tasks;
using NLog;
using NzbDrone.Core.Download;
using NzbDrone.Core.Indexers;
+using NzbDrone.Core.ReferenceData;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
@@ -20,9 +21,9 @@ namespace NzbDrone.Core.Test.ProviderTests.SearchTests
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
public TestSearch(ISeriesService seriesService, IEpisodeService episodeService, DownloadProvider downloadProvider,
- IIndexerService indexerService, SceneMappingProvider sceneMappingProvider,
+ IIndexerService indexerService, SceneMappingService sceneMappingService,
AllowedDownloadSpecification allowedDownloadSpecification, ISeriesRepository seriesRepository)
- : base(seriesService, seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingProvider,
+ : base(seriesService, seriesRepository, episodeService, downloadProvider, indexerService, sceneMappingService,
allowedDownloadSpecification)
{
}
diff --git a/NzbDrone.Core.Test/ProviderTests/TvRageMappingProviderTests/FindMatchingTvRageSeriesFixture.cs b/NzbDrone.Core.Test/ProviderTests/TvRageMappingProviderTests/FindMatchingTvRageSeriesFixture.cs
index d6c24d4de..d3f9f2b7b 100644
--- a/NzbDrone.Core.Test/ProviderTests/TvRageMappingProviderTests/FindMatchingTvRageSeriesFixture.cs
+++ b/NzbDrone.Core.Test/ProviderTests/TvRageMappingProviderTests/FindMatchingTvRageSeriesFixture.cs
@@ -5,6 +5,7 @@ using System.Text;
using FizzWare.NBuilder;
using FluentAssertions;
using NUnit.Framework;
+using NzbDrone.Core.ReferenceData;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model.TvRage;
using NzbDrone.Core.Providers;
@@ -49,7 +50,7 @@ namespace NzbDrone.Core.Test.ProviderTests.TvRageMappingProviderTests
.Setup(s => s.GetEpisode(_series.Id, 1, 1))
.Returns(_episode);
- Mocker.GetMock()
+ Mocker.GetMock()
.Setup(s => s.GetCleanName(_series.Id))
.Returns("");
diff --git a/NzbDrone.Core.Test/TvTests/EpisodeProviderTests/EpisodeProviderTest.cs b/NzbDrone.Core.Test/TvTests/EpisodeProviderTests/EpisodeProviderTest.cs
index 4df8ce673..c457b9fd1 100644
--- a/NzbDrone.Core.Test/TvTests/EpisodeProviderTests/EpisodeProviderTest.cs
+++ b/NzbDrone.Core.Test/TvTests/EpisodeProviderTests/EpisodeProviderTest.cs
@@ -1,4 +1,5 @@
-// ReSharper disable RedundantUsingDirective
+/*
+// ReSharper disable RedundantUsingDirective
using System;
using System.Collections.Generic;
@@ -16,19 +17,19 @@ using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Test.Framework;
-using PetaPoco;
+
using TvdbLib.Data;
namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
- public class EpisodeProviderTest : SqlCeTest
+ public class EpisodeProviderTest : ObjectDbTest
{
[Test]
public void GetEpisodes_exists()
{
- WithRealDb();
+
var fakeSeries = Builder.CreateNew().Build();
var fakeEpisodes = Builder.CreateListOfSize(5)
@@ -48,7 +49,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
[Test]
public void GetEpisodes_by_season_episode_exists()
{
- WithRealDb();
+
var fakeSeries = Builder.CreateNew()
.With(s => s.Id = 1)
@@ -72,7 +73,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
[Test]
public void GetEpisodes_by_season_episode_doesnt_exists()
{
- WithRealDb();
+
//Act
var episode = Mocker.Resolve().GetEpisode(1, 1, 1);
@@ -84,7 +85,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
[Test]
public void GetEpisode_with_EpisodeFile()
{
- WithRealDb();
+
var fakeSeries = Builder.CreateNew().Build();
var fakeFile = Builder.CreateNew().With(f => f.Id).With(c => c.Quality = Quality.SDTV).Build();
@@ -108,7 +109,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
[ExpectedException(typeof(InvalidOperationException), ExpectedMessage = "Sequence contains no elements")]
public void GetEpisodes_invalid_series()
{
- WithRealDb();
+
Mocker.Resolve();
@@ -126,7 +127,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
[Test]
public void GetEpisodesBySeason_success()
{
- WithRealDb();
+
var fakeSeries = Builder.CreateNew()
.With(s => s.Id = 12)
@@ -165,7 +166,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
var fakeSeries = Builder.CreateNew().With(c => c.Id = seriesId).Build();
- WithRealDb();
+
Db.Insert(fakeSeries);
@@ -199,7 +200,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
var fakeSeries = Builder.CreateNew().With(c => c.Id = seriesId).Build();
- WithRealDb();
+
Db.Insert(fakeSeries);
@@ -240,7 +241,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
var fakeSeries = Builder.CreateNew().With(c => c.Id = seriesId).Build();
- WithRealDb();
+
Db.Insert(fakeSeries);
Db.Insert(fakeEpisode);
@@ -277,7 +278,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
var fakeSeries = Builder.CreateNew().With(c => c.Id = seriesId).Build();
- WithRealDb();
+
Db.Insert(fakeSeries);
@@ -316,7 +317,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
var fakeSeries = Builder.CreateNew().With(c => c.Id = seriesId).Build();
- WithRealDb();
+
Db.Insert(fakeSeries);
@@ -354,7 +355,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
var fakeSeries = Builder.CreateNew().With(c => c.Id = seriesId).Build();
- WithRealDb();
+
Db.Insert(fakeSeries);
@@ -387,7 +388,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
var fakeSeries = Builder.CreateNew().With(c => c.Id = seriesId).Build();
- WithRealDb();
+
Db.Insert(fakeSeries);
@@ -420,7 +421,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
var fakeSeries = Builder.CreateNew().With(c => c.Id = seriesId).Build();
- WithRealDb();
+
Db.Insert(fakeSeries);
@@ -455,7 +456,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
var fakeSeries = Builder.CreateNew().With(c => c.Id = seriesId).Build();
- WithRealDb();
+
Db.Insert(fakeSeries);
@@ -787,7 +788,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
var fakeSeries = Builder.CreateNew().With(c => c.Id = seriesId).Build();
- WithRealDb();
+
Db.Insert(fakeSeries);
Db.Insert(fakeEpisode);
@@ -814,7 +815,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
[Explicit]
public void Add_daily_show_episodes()
{
- WithRealDb();
+
Mocker.Resolve();
Mocker.GetMock()
@@ -843,7 +844,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
[Test]
public void GetEpisode_by_Season_Episode_none_existing()
{
- WithRealDb();
+
//Act
var episode = Mocker.Resolve().GetEpisode(1, 1, 1);
@@ -855,7 +856,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
[Test]
public void GetEpisode_by_Season_Episode_with_EpisodeFile()
{
- WithRealDb();
+
var fakeSeries = Builder.CreateNew().Build();
var fakeFile = Builder.CreateNew().With(f => f.Id).With(c => c.Quality = Quality.SDTV).Build();
@@ -878,7 +879,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
[Test]
public void GetEpisode_by_Season_Episode_without_EpisodeFile()
{
- WithRealDb();
+
var fakeSeries = Builder.CreateNew().Build();
var fakeEpisodes = Builder.CreateListOfSize(5)
@@ -899,7 +900,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
[Test]
public void GetEpisode_by_AirDate_with_EpisodeFile()
{
- WithRealDb();
+
var fakeSeries = Builder.CreateNew().Build();
var fakeFile = Builder.CreateNew().With(f => f.Id).With(c => c.Quality = Quality.SDTV).Build();
@@ -922,7 +923,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
[Test]
public void GetEpisode_by_AirDate_without_EpisodeFile()
{
- WithRealDb();
+
var fakeSeries = Builder.CreateNew().Build();
var fakeEpisodes = Builder.CreateListOfSize(5)
@@ -959,7 +960,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
[Test]
public void AddEpisode_episode_is_ignored_when_full_season_is_ignored()
{
- WithRealDb();
+
var episodes = Builder.CreateListOfSize(4)
.All()
@@ -997,7 +998,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
[Test]
public void AddEpisode_episode_is_not_ignored_when_full_season_is_not_ignored()
{
- WithRealDb();
+
var episodes = Builder.CreateListOfSize(4)
.All()
@@ -1031,7 +1032,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
[Test]
public void AddEpisode_episode_is_not_ignored_when_not_full_season_is_not_ignored()
{
- WithRealDb();
+
var episodes = Builder.CreateListOfSize(4)
.All()
@@ -1067,7 +1068,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
[Test]
public void IgnoreEpisode_Ignore()
{
- WithRealDb();
+
var episodes = Builder.CreateListOfSize(4)
.All()
@@ -1093,7 +1094,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
[Test]
public void IgnoreEpisode_RemoveIgnore()
{
- WithRealDb();
+
var episodes = Builder.CreateListOfSize(4)
.All()
@@ -1119,7 +1120,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
[Test]
public void EpisodesWithoutFiles_no_specials()
{
- WithRealDb();
+
var series = Builder.CreateNew()
.With(s => s.Id = 10)
@@ -1162,7 +1163,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
[Test]
public void EpisodesWithoutFiles_with_specials()
{
- WithRealDb();
+
var series = Builder.CreateNew()
.With(s => s.Id = 10)
@@ -1206,7 +1207,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
[Test]
public void EpisodesWithFiles_success()
{
- WithRealDb();
+
var series = Builder.CreateNew()
.With(s => s.Id = 10)
@@ -1250,7 +1251,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
[Test]
public void EpisodesWithFiles_no_files()
{
- WithRealDb();
+
var series = Builder.CreateNew()
.With(s => s.Id = 10)
@@ -1279,7 +1280,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
[Test]
public void GetEpisodesByFileId_multi_episodes()
{
- WithRealDb();
+
var series = Builder.CreateNew()
.With(s => s.Id = 10)
@@ -1306,7 +1307,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
[Test]
public void GetEpisodesByFileId_single_episode()
{
- WithRealDb();
+
var series = Builder.CreateNew()
.With(s => s.Id = 10)
@@ -1333,7 +1334,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
[Test]
public void IsFirstOrLastEpisodeInSeason_false()
{
- WithRealDb();
+
var fakeEpisodes = Builder.CreateListOfSize(10)
.All()
@@ -1353,7 +1354,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
[Test]
public void IsFirstOrLastEpisodeInSeason_true_first()
{
- WithRealDb();
+
var fakeEpisodes = Builder.CreateListOfSize(10)
.All()
@@ -1373,7 +1374,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
[Test]
public void IsFirstOrLastEpisodeInSeason_true_last()
{
- WithRealDb();
+
var fakeEpisodes = Builder.CreateListOfSize(10)
.All()
@@ -1398,7 +1399,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
[TestCase("The Office (US) - Season 01 - Episode Title", PostDownloadStatusType.Failed, 10)]
public void SetPostDownloadStatus(string folderName, PostDownloadStatusType postDownloadStatus, int episodeCount)
{
- WithRealDb();
+
var fakeSeries = Builder.CreateNew()
.With(s => s.Id = 12345)
@@ -1428,7 +1429,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
[Test]
public void SetPostDownloadStatus_Invalid_EpisodeId()
{
- WithRealDb();
+
var postDownloadStatus = PostDownloadStatusType.Failed;
@@ -1492,7 +1493,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
var fakeSeries = Builder.CreateNew().With(c => c.Id = seriesId).Build();
- WithRealDb();
+
Db.Insert(fakeSeries);
@@ -1513,3 +1514,4 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
}
}
+*/
diff --git a/NzbDrone.Core.Test/TvTests/EpisodeProviderTests/EpisodeProviderTest_GetEpisodesByParseResult.cs b/NzbDrone.Core.Test/TvTests/EpisodeProviderTests/EpisodeProviderTest_GetEpisodesByParseResult.cs
index c35c96f4c..f2749a215 100644
--- a/NzbDrone.Core.Test/TvTests/EpisodeProviderTests/EpisodeProviderTest_GetEpisodesByParseResult.cs
+++ b/NzbDrone.Core.Test/TvTests/EpisodeProviderTests/EpisodeProviderTest_GetEpisodesByParseResult.cs
@@ -1,4 +1,5 @@
-// ReSharper disable RedundantUsingDirective
+/*
+// ReSharper disable RedundantUsingDirective
using System;
using System.Collections.Generic;
@@ -15,7 +16,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
- public class EpisodeProviderTest_GetEpisodesByParseResult : SqlCeTest
+ public class EpisodeProviderTest_GetEpisodesByParseResult : ObjectDbTest
{
private IEpisodeService episodeService;
@@ -53,7 +54,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
.With(e => e.Title = "Daily Episode 1")
.Build();
- WithRealDb();
+
episodeService = Mocker.Resolve();
}
@@ -76,7 +77,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
ep.Should().HaveCount(1);
parseResult.EpisodeTitle.Should().Be(fakeEpisode.Title);
VerifyEpisode(ep[0], fakeEpisode);
- Db.Fetch().Should().HaveCount(1);
+ Db().Should().HaveCount(1);
}
[Test]
@@ -273,3 +274,4 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
}
}
}
+*/
diff --git a/NzbDrone.Core.Test/TvTests/EpisodeProviderTests/GetEpisodeBySceneNumberFixture.cs b/NzbDrone.Core.Test/TvTests/EpisodeProviderTests/GetEpisodeBySceneNumberFixture.cs
index 366d4b560..733c934cc 100644
--- a/NzbDrone.Core.Test/TvTests/EpisodeProviderTests/GetEpisodeBySceneNumberFixture.cs
+++ b/NzbDrone.Core.Test/TvTests/EpisodeProviderTests/GetEpisodeBySceneNumberFixture.cs
@@ -11,7 +11,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
- public class GetEpisodeBySceneNumberFixture : SqlCeTest
+ public class GetEpisodeBySceneNumberFixture : ObjectDbTest
{
private Series _series;
private Episode _episode;
@@ -19,7 +19,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
[SetUp]
public void Setup()
{
- WithRealDb();
+
_series = Builder
.CreateNew()
@@ -36,7 +36,6 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
.Build();
Db.Insert(_episode);
- Db.Execute("UPDATE Episodes SET SceneSeasonNumber = NULL, SceneEpisodeNumber = NULL");
}
public void WithSceneNumbering()
diff --git a/NzbDrone.Core.Test/TvTests/SeasonProviderTest.cs b/NzbDrone.Core.Test/TvTests/SeasonProviderTest.cs
index bba507219..f5bf689e3 100644
--- a/NzbDrone.Core.Test/TvTests/SeasonProviderTest.cs
+++ b/NzbDrone.Core.Test/TvTests/SeasonProviderTest.cs
@@ -13,46 +13,15 @@ namespace NzbDrone.Core.Test.TvTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
- public class SeasonProviderTest : SqlCeTest
+ public class SeasonProviderTest : ObjectDbTest
{
[SetUp]
public void Setup()
{
- WithRealDb();
+
}
- [TestCase(true)]
- [TestCase(false)]
- public void SetIgnore_should_update_ignored_status(bool ignoreFlag)
- {
- var fakeSeason = Builder.CreateNew()
- .With(s => s.Ignored = !ignoreFlag)
- .Build();
-
- var fakeEpisodes = Builder.CreateListOfSize(4)
- .All()
- .With(c => c.SeriesId = fakeSeason.SeriesId)
- .With(c => c.SeasonNumber = fakeSeason.Id)
- .With(c => c.Ignored = !ignoreFlag)
- .Build().ToList();
-
- fakeEpisodes.ForEach(c => Db.Insert(c));
-
- var id = Db.Insert(fakeSeason);
-
- //Act
- Mocker.Resolve().SetIgnore(fakeSeason.SeriesId, fakeSeason.SeasonNumber, ignoreFlag);
-
- //Assert
- var season = Db.SingleOrDefault(id);
- season.Ignored.Should().Be(ignoreFlag);
-
- var episodes = Db.Fetch();
- episodes.Should().HaveSameCount(fakeEpisodes);
- episodes.Should().OnlyContain(c => c.Ignored == ignoreFlag);
- }
-
[TestCase(true)]
[TestCase(false)]
public void IsIgnored_should_return_ignored_status_of_season(bool ignoreFlag)
@@ -111,7 +80,7 @@ namespace NzbDrone.Core.Test.TvTests
const int seriesId = 10;
//Setup
- WithRealDb();
+
var seasons = Builder.CreateListOfSize(5)
.All()
diff --git a/NzbDrone.Core/App.config b/NzbDrone.Core/App.config
index fc91a3745..99ddf3e08 100644
--- a/NzbDrone.Core/App.config
+++ b/NzbDrone.Core/App.config
@@ -1,13 +1,3 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/NzbDrone.Core/ContainerExtentions.cs b/NzbDrone.Core/ContainerExtentions.cs
index 80b8f7058..a31effc8c 100644
--- a/NzbDrone.Core/ContainerExtentions.cs
+++ b/NzbDrone.Core/ContainerExtentions.cs
@@ -11,7 +11,6 @@ using NzbDrone.Core.Indexers;
using NzbDrone.Core.Instrumentation;
using NzbDrone.Core.Providers.Metadata;
using NzbDrone.Core.Providers.Search;
-using PetaPoco;
namespace NzbDrone.Core
{
@@ -62,15 +61,7 @@ namespace NzbDrone.Core
var appDataPath = new EnvironmentProvider().GetAppDataPath();
if (!Directory.Exists(appDataPath)) Directory.CreateDirectory(appDataPath);
- container.Register(c => c.Resolve().GetMainPetaPocoDb())
- .As();
- container.Register(c => c.Resolve().GetLogPetaPocoDb(false))
- .SingleInstance()
- .Named("DatabaseTarget");
-
- container.Register(c => c.Resolve().GetLogPetaPocoDb())
- .Named("LogProvider");
container.Register(c =>
{
@@ -78,9 +69,6 @@ namespace NzbDrone.Core
}).As().SingleInstance();
container.RegisterGeneric(typeof(BasicRepository<>)).As(typeof(IBasicRepository<>));
-
- container.RegisterType().WithParameter(ResolvedParameter.ForNamed("DatabaseTarget"));
- container.RegisterType().WithParameter(ResolvedParameter.ForNamed("LogProvider"));
}
}
}
\ No newline at end of file
diff --git a/NzbDrone.Core/Datastore/BasicRepository.cs b/NzbDrone.Core/Datastore/BasicRepository.cs
index 0ae110aa9..000f5627b 100644
--- a/NzbDrone.Core/Datastore/BasicRepository.cs
+++ b/NzbDrone.Core/Datastore/BasicRepository.cs
@@ -3,7 +3,7 @@ using System.Linq;
namespace NzbDrone.Core.Datastore
{
- public interface IBasicRepository
+ public interface IBasicRepository where TModel : ModelBase, new()
{
IEnumerable All();
int Count();
@@ -15,6 +15,7 @@ namespace NzbDrone.Core.Datastore
IList InsertMany(IList model);
IList UpdateMany(IList model);
void Purge();
+ bool HasItems();
}
public class BasicRepository : IBasicRepository where TModel : ModelBase, new()
@@ -90,5 +91,10 @@ namespace NzbDrone.Core.Datastore
{
DeleteMany(Queryable.Select(c => c.Id));
}
+
+ public bool HasItems()
+ {
+ return Queryable.Any();
+ }
}
}
diff --git a/NzbDrone.Core/Datastore/ConnectionFactory.cs b/NzbDrone.Core/Datastore/ConnectionFactory.cs
deleted file mode 100644
index 3cf62665c..000000000
--- a/NzbDrone.Core/Datastore/ConnectionFactory.cs
+++ /dev/null
@@ -1,160 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Configuration;
-using System.Data;
-using System.Data.Common;
-using System.Reflection;
-using NLog;
-using NzbDrone.Common;
-using PetaPoco;
-
-namespace NzbDrone.Core.Datastore
-{
- public class ConnectionFactory
- {
- private readonly EnvironmentProvider _environmentProvider;
- private static readonly Logger logger = LogManager.GetLogger("ConnectionFactory");
- private static readonly DbProviderFactory _factory;
-
- static ConnectionFactory()
- {
- Database.Mapper = new CustomeMapper();
-
- if (EnvironmentProvider.IsMono) return;
-
- var dataSet = (DataSet)ConfigurationManager.GetSection("system.data");
- dataSet.Tables[0].Rows.Add("Microsoft SQL Server Compact Data Provider 4.0"
- , "System.Data.SqlServerCe.4.0"
- , ".NET Framework Data Provider for Microsoft SQL Server Compact"
- ,
- "System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91");
-
- _factory = SqlCeProxy.GetSqlCeProviderFactory();
- }
-
-
- public ConnectionFactory(EnvironmentProvider environmentProvider)
- {
- _environmentProvider = environmentProvider;
- }
-
- public String MainConnectionString
- {
- get
- {
- return GetConnectionString(_environmentProvider.GetSqlCeMainDbPath());
- }
- }
-
- public String LogConnectionString
- {
- get
- {
- return GetConnectionString(_environmentProvider.GetSqlCeLogDbPath());
- }
- }
-
- public static string GetConnectionString(string path)
- {
- return String.Format("Data Source=\"{0}\"; Max Database Size = 512;", path);
- }
-
- public IDatabase GetMainPetaPocoDb(Boolean profiled = true)
- {
- return GetPetaPocoDb(MainConnectionString, profiled);
- }
-
- public IDatabase GetLogPetaPocoDb(Boolean profiled = true)
- {
- return GetPetaPocoDb(LogConnectionString, profiled);
- }
-
-
- static readonly HashSet initilized = new HashSet();
-
-
-
- public static IDatabase GetPetaPocoDb(string connectionString, Boolean profiled = true)
- {
- if (EnvironmentProvider.IsMono)
- {
- throw new NotSupportedException("SqlCe is not supported in mono");
- }
-
- lock (initilized)
- {
- if (!initilized.Contains(connectionString))
- {
- //VerifyDatabase(connectionString);
- MigrationsHelper.Run(connectionString, true);
- initilized.Add(connectionString);
- }
- }
-
-
-
- var db = new Database(connectionString, _factory, Database.DBType.SqlServerCE)
- {
- KeepConnectionAlive = true,
- ForceDateTimesToUtc = false,
- };
-
- return db;
- }
-
- /*private static void VerifyDatabase(string connectionString)
- {
- logger.Debug("Verifying database {0}", connectionString);
-
- var sqlConnection = new SqlCeConnection(connectionString);
-
- if (!File.Exists(sqlConnection.Database))
- {
- logger.Debug("database file doesn't exist. {0}", sqlConnection.Database);
- return;
- }
-
- using (var sqlEngine = new SqlCeEngine(connectionString))
- {
-
- if (sqlEngine.Verify(VerifyOption.Default))
- {
- logger.Debug("Database integrity verified.");
- }
- else
- {
- logger.Error("Database verification failed.");
- RepairDatabase(connectionString);
- }
- }
- }
-
- private static void RepairDatabase(string connectionString)
- {
- logger.Info("Attempting to repair database: {0}", connectionString);
- using (var sqlEngine = new SqlCeEngine(connectionString))
- {
- try
- {
- sqlEngine.Repair(connectionString, RepairOption.RecoverAllOrFail);
- logger.Info("Recovery was successful without any data loss {0}", connectionString);
- }
- catch (SqlCeException e)
- {
- if (e.Message.Contains("file sharing violation"))
- {
- logger.WarnException("file is in use. skipping.", e);
- return;
- }
- logger.WarnException(
- "Safe recovery failed. will attempts a more aggressive strategy. might cause loss of data.",
- e);
- sqlEngine.Repair(connectionString, RepairOption.DeleteCorruptedRows);
- logger.Warn("Database was recovered. some data might have been lost");
-
- //TODO: do db cleanup to avoid broken relationships.
- }
- }
- }*/
- }
-}
diff --git a/NzbDrone.Core/Datastore/CustomeMapper.cs b/NzbDrone.Core/Datastore/CustomeMapper.cs
deleted file mode 100644
index 87219400f..000000000
--- a/NzbDrone.Core/Datastore/CustomeMapper.cs
+++ /dev/null
@@ -1,75 +0,0 @@
-using System;
-using System.Reflection;
-using NzbDrone.Core.Qualities;
-using PetaPoco;
-
-namespace NzbDrone.Core.Datastore
-{
- public class CustomeMapper : DefaultMapper
- {
- public override Func