mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-18 21:34:28 -04:00
removed sqlce
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
</configSections>
|
||||
<appSettings>
|
||||
<!-- Supported values: nunit, xunit and mstest -->
|
||||
<add key="FluentAssertions.TestFramework" value="nunit" />
|
||||
@@ -15,11 +12,4 @@
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<entityFramework>
|
||||
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework">
|
||||
<parameters>
|
||||
<parameter value="System.Data.SqlServerCe.4.0" />
|
||||
</parameters>
|
||||
</defaultConnectionFactory>
|
||||
</entityFramework>
|
||||
</configuration>
|
||||
@@ -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<IIndexerService>().All().Select(c => c.Type).Should().BeEquivalentTo(indexers);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void metadata_clients_are_initialized()
|
||||
{
|
||||
kernel.Resolve<MetadataProvider>().All().Should().HaveSameCount(metadata);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void quality_profile_initialized()
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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<TSubject> : SqlCeTest where TSubject : class
|
||||
{
|
||||
|
||||
private TSubject _subject;
|
||||
|
||||
|
||||
protected TSubject Subject
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_subject == null)
|
||||
{
|
||||
_subject = Mocker.Resolve<TSubject>();
|
||||
}
|
||||
|
||||
return _subject;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void InitiateSubject()
|
||||
{
|
||||
_subject = Mocker.Resolve<TSubject>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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<EpisodeSearchJob>().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<SeasonSearchJob>().Start(new ProgressNotification("Test"), new { SeriesId = 1, SeasonNumber = target });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -75,21 +75,6 @@ namespace NzbDrone.Core.Test.JobTests
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_if_no_episodes_are_moved()
|
||||
{
|
||||
Mocker.Resolve<RenameSeasonJob>().Start(_testNotification, new { SeriesId = _series.Id, SeasonNumber = 5 });
|
||||
|
||||
Mocker.GetMock<MetadataProvider>().Verify(v => v.RemoveForEpisodeFiles(It.IsAny<List<EpisodeFile>>()), Times.Never());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_process_metadata_if_files_are_moved()
|
||||
{
|
||||
WithMovedFiles();
|
||||
Mocker.Resolve<RenameSeasonJob>().Start(_testNotification, new { SeriesId = _series.Id, SeasonNumber = 5 });
|
||||
|
||||
Mocker.GetMock<MetadataProvider>().Verify(v => v.RemoveForEpisodeFiles(It.IsAny<List<EpisodeFile>>()), Times.Once());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<IConfigService>()
|
||||
.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<Episode>.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<Episode>();
|
||||
|
||||
//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<Episode>.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<Episode>();
|
||||
|
||||
//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<Episode>.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<Episode>();
|
||||
|
||||
//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<EpisodeFile>
|
||||
.CreateListOfSize(10)
|
||||
.All()
|
||||
.With(e => e.Quality = Quality.DVD)
|
||||
.Build();
|
||||
var episodes = Builder<Episode>.CreateListOfSize(5).Build();
|
||||
|
||||
Db.InsertMany(episodes);
|
||||
Db.InsertMany(episodeFiles);
|
||||
|
||||
//Act
|
||||
var result = Db.Fetch<EpisodeFile>();
|
||||
|
||||
//Assert
|
||||
result.Should().HaveCount(5);
|
||||
result.Should().OnlyContain(e => e.Id > 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<IMediaFileService>().Delete(1);
|
||||
var result = Db.Fetch<EpisodeFile>();
|
||||
|
||||
//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<IMediaFileService>().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<EpisodeFile>.CreateNew()
|
||||
.With(c => c.Quality = Quality.SDTV)
|
||||
.With(f => f.Path = path.NormalizePath())
|
||||
|
||||
@@ -199,8 +199,6 @@
|
||||
<Compile Include="DecisionEngineTests\QualityUpgradeSpecificationFixture.cs" />
|
||||
<Compile Include="DecisionEngineTests\UpgradePossibleSpecificationFixture.cs" />
|
||||
<Compile Include="ProviderTests\DownloadClientTests\BlackholeProviderFixture.cs" />
|
||||
<Compile Include="MediaFileTests\CleanUpDatabaseFixture.cs" />
|
||||
<Compile Include="ProviderTests\ReferenceDataProviderTest.cs" />
|
||||
<Compile Include="ProviderTests\NotificationProviderTests\NotificationProviderFixture.cs" />
|
||||
<Compile Include="ProviderTests\DownloadClientTests\SabProviderTests\QueueFixture.cs" />
|
||||
<Compile Include="Indexers\NewznabServiceTest.cs" />
|
||||
@@ -209,7 +207,6 @@
|
||||
<Compile Include="ProviderTests\GrowlProviderTest.cs" />
|
||||
<Compile Include="ProviderTests\DiskProviderTests\ExtractArchiveFixture.cs" />
|
||||
<Compile Include="ProviderTests\PostDownloadProviderTests\GetFolderNameWithStatusFixture.cs" />
|
||||
<Compile Include="JobTests\EpisodeSearchJobTest.cs" />
|
||||
<Compile Include="ProviderTests\PostDownloadProviderTests\ProcessDownloadFixture.cs" />
|
||||
<Compile Include="JobTests\TestJobs.cs" />
|
||||
<Compile Include="JobTests\AppUpdateJobFixture.cs" />
|
||||
@@ -233,7 +230,6 @@
|
||||
<Compile Include="FluentTest.cs" />
|
||||
<Compile Include="InstrumentationTests\DatabaseTargetFixture.cs" />
|
||||
<Compile Include="MediaFileTests\GetNewFilenameFixture.cs" />
|
||||
<Compile Include="Framework\SqlCeTest.cs" />
|
||||
<Compile Include="DecisionEngineTests\MonitoredEpisodeSpecificationFixture.cs" />
|
||||
<Compile Include="ProviderTests\DownloadProviderTests\DownloadProviderFixture.cs" />
|
||||
<Compile Include="EpisodeStatusTest.cs" />
|
||||
|
||||
@@ -303,7 +303,6 @@ namespace NzbDrone.Core.Test.ProviderTests.PostDownloadProviderTests
|
||||
Mocker.GetMock<DiskProvider>().Setup(s => s.DeleteFolder(droppedFolder.FullName, true));
|
||||
Mocker.GetMock<DiskProvider>().Setup(s => s.FolderExists(fakeSeries.Path)).Returns(true);
|
||||
Mocker.GetMock<DiskProvider>().Setup(s => s.IsFolderLocked(droppedFolder.FullName)).Returns(false);
|
||||
Mocker.GetMock<MetadataProvider>().Setup(s => s.CreateForEpisodeFiles(It.IsAny<List<EpisodeFile>>()));
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<PostDownloadProvider>().ProcessDownload(droppedFolder);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<IConfigService>().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<HttpProvider>().Setup(s => s.DownloadString(url))
|
||||
.Returns(validSeriesIds);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<ReferenceDataProvider>().GetDailySeriesIds();
|
||||
|
||||
//Assert
|
||||
result.Should().HaveCount(5);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetDailySeriesIds_should_return_empty_list_when_unable_to_parse()
|
||||
{
|
||||
//Setup
|
||||
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadString(url))
|
||||
.Returns(invalidSeriesIds);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<ReferenceDataProvider>().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<HttpProvider>().Setup(s => s.DownloadString(url))
|
||||
.Throws(new Exception());
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<ReferenceDataProvider>().GetDailySeriesIds();
|
||||
|
||||
//Assert
|
||||
result.Should().HaveCount(0);
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsDailySeries_should_return_true()
|
||||
{
|
||||
//Setup
|
||||
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadString(url))
|
||||
.Returns(validSeriesIds);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<ReferenceDataProvider>().IsSeriesDaily(1);
|
||||
|
||||
//Assert
|
||||
result.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsDailySeries_should_return_false()
|
||||
{
|
||||
//Setup
|
||||
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadString(url))
|
||||
.Returns(validSeriesIds);
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<ReferenceDataProvider>().IsSeriesDaily(10);
|
||||
|
||||
//Assert
|
||||
result.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UpdateDailySeries_should_update_series_that_match_daily_series_list()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateListOfSize(5)
|
||||
.All()
|
||||
.With(s => s.SeriesType = SeriesType.Standard)
|
||||
.Build();
|
||||
|
||||
Db.InsertMany(fakeSeries);
|
||||
|
||||
//Setup
|
||||
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadString(url))
|
||||
.Returns(validSeriesIds);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<ReferenceDataProvider>().UpdateDailySeries();
|
||||
|
||||
//Assert
|
||||
var result = Db.Fetch<Series>();
|
||||
|
||||
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<Series>.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<HttpProvider>().Setup(s => s.DownloadString(url))
|
||||
.Returns(validSeriesIds);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<ReferenceDataProvider>().UpdateDailySeries();
|
||||
|
||||
//Assert
|
||||
var result = Db.Fetch<Series>();
|
||||
|
||||
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<Series>.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<HttpProvider>().Setup(s => s.DownloadString(url))
|
||||
.Returns(validSeriesIds);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<ReferenceDataProvider>().UpdateDailySeries();
|
||||
|
||||
//Assert
|
||||
var result = Db.Fetch<Series>();
|
||||
|
||||
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<HttpProvider>().Setup(s => s.DownloadString(It.IsAny<string>()))
|
||||
.Throws(new WebException())
|
||||
.Verifiable();
|
||||
|
||||
Mocker.Resolve<ReferenceDataProvider>().UpdateDailySeries();
|
||||
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
Mocker.VerifyAllMocks();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<IConfigService>().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<SceneMapping>.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<SceneMappingProvider>().GetSceneName(fakeMap.SeriesId);
|
||||
var sceneName = Mocker.Resolve<SceneMappingService>().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<SceneMapping>.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<SceneMappingProvider>().GetSeriesId(fakeMap.CleanTitle);
|
||||
var seriesId = Mocker.Resolve<SceneMappingService>().GetTvDbId(fakeMap.CleanTitle);
|
||||
|
||||
//Assert
|
||||
Assert.AreEqual(fakeMap.SeriesId, seriesId);
|
||||
Assert.AreEqual(fakeMap.TvdbId, seriesId);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetSceneName_null()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
//Setup
|
||||
var fakeMap = Builder<SceneMapping>.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<SceneMappingProvider>().GetSceneName(54321);
|
||||
var sceneName = Mocker.Resolve<SceneMappingService>().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<SceneMapping>.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<SceneMappingProvider>().GetSeriesId("notlaworder");
|
||||
var seriesId = Mocker.Resolve<SceneMappingService>().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<SceneMapping>.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<SceneMapping>.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<SceneMappingProvider>().GetSceneName(fakeMap.SeriesId);
|
||||
var sceneName = Mocker.Resolve<SceneMappingService>().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<SceneMapping>.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<SceneMappingProvider>().GetSceneName(54321, 5).Should().BeNull();
|
||||
Mocker.Resolve<SceneMappingService>().GetSceneName(54321, 5).Should().BeNull();
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -187,12 +178,10 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||
WithValidJson();
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<SceneMappingProvider>().UpdateMappings();
|
||||
Mocker.Resolve<SceneMappingService>().UpdateMappings();
|
||||
|
||||
//Assert
|
||||
Mocker.Verify<HttpProvider>(v => v.DownloadString(SceneMappingUrl), Times.Once());
|
||||
var result = Db.Fetch<SceneMapping>();
|
||||
result.Should().HaveCount(5);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -200,7 +189,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
//Setup
|
||||
var fakeMap = Builder<SceneMapping>.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<SceneMappingProvider>().UpdateMappings();
|
||||
Mocker.Resolve<SceneMappingService>().UpdateMappings();
|
||||
|
||||
//Assert
|
||||
Mocker.Verify<HttpProvider>(v => v.DownloadString(SceneMappingUrl), Times.Once());
|
||||
var result = Db.Fetch<SceneMapping>();
|
||||
result.Should().HaveCount(5);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -222,7 +209,7 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||
{
|
||||
//Setup
|
||||
var fakeMap = Builder<SceneMapping>.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<SceneMappingProvider>().UpdateMappings();
|
||||
Mocker.Resolve<SceneMappingService>().UpdateMappings();
|
||||
|
||||
//Assert
|
||||
Mocker.Verify<HttpProvider>(v => v.DownloadString(SceneMappingUrl), Times.Once());
|
||||
var result = Db.Fetch<SceneMapping>();
|
||||
result.Should().HaveCount(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UpdateIfEmpty_should_not_update_if_count_is_not_zero()
|
||||
{
|
||||
//Setup
|
||||
var fakeMap = Builder<SceneMapping>.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<SceneMappingProvider>().UpdateIfEmpty();
|
||||
|
||||
//Assert
|
||||
Mocker.Verify<HttpProvider>(v => v.DownloadString(SceneMappingUrl), Times.Never());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UpdateIfEmpty_should_update_if_count_is_zero()
|
||||
{
|
||||
//Setup
|
||||
WithValidJson();
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<SceneMappingProvider>().UpdateIfEmpty();
|
||||
|
||||
//Assert
|
||||
Mocker.Verify<HttpProvider>(v => v.DownloadString(SceneMappingUrl), Times.Once());
|
||||
var result = Db.Fetch<SceneMapping>();
|
||||
result.Should().HaveCount(5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<SceneMappingProvider>()
|
||||
Mocker.GetMock<SceneMappingService>()
|
||||
.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<SceneMappingProvider>()
|
||||
Mocker.GetMock<SceneMappingService>()
|
||||
.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<SceneMappingProvider>()
|
||||
Mocker.GetMock<SceneMappingService>()
|
||||
.Setup(s => s.GetSceneName(_series.Id, -1))
|
||||
.Returns("");
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
+2
-1
@@ -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<SceneMappingProvider>()
|
||||
Mocker.GetMock<SceneMappingService>()
|
||||
.Setup(s => s.GetCleanName(_series.Id))
|
||||
.Returns("");
|
||||
|
||||
|
||||
@@ -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<Series>.CreateNew().Build();
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(5)
|
||||
@@ -48,7 +49,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
|
||||
[Test]
|
||||
public void GetEpisodes_by_season_episode_exists()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
|
||||
var fakeSeries = Builder<Series>.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<EpisodeService>().GetEpisode(1, 1, 1);
|
||||
@@ -84,7 +85,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
|
||||
[Test]
|
||||
public void GetEpisode_with_EpisodeFile()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew().Build();
|
||||
var fakeFile = Builder<EpisodeFile>.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<SeriesService>();
|
||||
|
||||
@@ -126,7 +127,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
|
||||
[Test]
|
||||
public void GetEpisodesBySeason_success()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew()
|
||||
.With(s => s.Id = 12)
|
||||
@@ -165,7 +166,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew().With(c => c.Id = seriesId).Build();
|
||||
|
||||
WithRealDb();
|
||||
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
|
||||
@@ -199,7 +200,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew().With(c => c.Id = seriesId).Build();
|
||||
|
||||
WithRealDb();
|
||||
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
|
||||
@@ -240,7 +241,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
|
||||
|
||||
var fakeSeries = Builder<Series>.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<Series>.CreateNew().With(c => c.Id = seriesId).Build();
|
||||
|
||||
WithRealDb();
|
||||
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
|
||||
@@ -316,7 +317,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew().With(c => c.Id = seriesId).Build();
|
||||
|
||||
WithRealDb();
|
||||
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
|
||||
@@ -354,7 +355,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew().With(c => c.Id = seriesId).Build();
|
||||
|
||||
WithRealDb();
|
||||
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
|
||||
@@ -387,7 +388,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew().With(c => c.Id = seriesId).Build();
|
||||
|
||||
WithRealDb();
|
||||
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
|
||||
@@ -420,7 +421,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew().With(c => c.Id = seriesId).Build();
|
||||
|
||||
WithRealDb();
|
||||
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
|
||||
@@ -455,7 +456,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew().With(c => c.Id = seriesId).Build();
|
||||
|
||||
WithRealDb();
|
||||
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
|
||||
@@ -787,7 +788,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
|
||||
|
||||
var fakeSeries = Builder<Series>.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<TvDbProvider>();
|
||||
|
||||
Mocker.GetMock<IConfigService>()
|
||||
@@ -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<EpisodeService>().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<Series>.CreateNew().Build();
|
||||
var fakeFile = Builder<EpisodeFile>.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<Series>.CreateNew().Build();
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(5)
|
||||
@@ -899,7 +900,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
|
||||
[Test]
|
||||
public void GetEpisode_by_AirDate_with_EpisodeFile()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
|
||||
var fakeSeries = Builder<Series>.CreateNew().Build();
|
||||
var fakeFile = Builder<EpisodeFile>.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<Series>.CreateNew().Build();
|
||||
var fakeEpisodes = Builder<Episode>.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<Episode>.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<Episode>.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<Episode>.CreateListOfSize(4)
|
||||
.All()
|
||||
@@ -1067,7 +1068,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
|
||||
[Test]
|
||||
public void IgnoreEpisode_Ignore()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
|
||||
var episodes = Builder<Episode>.CreateListOfSize(4)
|
||||
.All()
|
||||
@@ -1093,7 +1094,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
|
||||
[Test]
|
||||
public void IgnoreEpisode_RemoveIgnore()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
|
||||
var episodes = Builder<Episode>.CreateListOfSize(4)
|
||||
.All()
|
||||
@@ -1119,7 +1120,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
|
||||
[Test]
|
||||
public void EpisodesWithoutFiles_no_specials()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
|
||||
var series = Builder<Series>.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<Series>.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<Series>.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<Series>.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<Series>.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<Series>.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<Episode>.CreateListOfSize(10)
|
||||
.All()
|
||||
@@ -1353,7 +1354,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
|
||||
[Test]
|
||||
public void IsFirstOrLastEpisodeInSeason_true_first()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
|
||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(10)
|
||||
.All()
|
||||
@@ -1373,7 +1374,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
|
||||
[Test]
|
||||
public void IsFirstOrLastEpisodeInSeason_true_last()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
|
||||
var fakeEpisodes = Builder<Episode>.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<Series>.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<Series>.CreateNew().With(c => c.Id = seriesId).Build();
|
||||
|
||||
WithRealDb();
|
||||
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
|
||||
@@ -1513,3 +1514,4 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
+6
-4
@@ -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<EpisodeService>();
|
||||
}
|
||||
@@ -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<Episode>().Should().HaveCount(1);
|
||||
Db<Episode>().Should().HaveCount(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -273,3 +274,4 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -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<Series>
|
||||
.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()
|
||||
|
||||
@@ -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<Season>.CreateNew()
|
||||
.With(s => s.Ignored = !ignoreFlag)
|
||||
.Build();
|
||||
|
||||
var fakeEpisodes = Builder<Episode>.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<ISeasonService>().SetIgnore(fakeSeason.SeriesId, fakeSeason.SeasonNumber, ignoreFlag);
|
||||
|
||||
//Assert
|
||||
var season = Db.SingleOrDefault<Season>(id);
|
||||
season.Ignored.Should().Be(ignoreFlag);
|
||||
|
||||
var episodes = Db.Fetch<Episode>();
|
||||
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<Season>.CreateListOfSize(5)
|
||||
.All()
|
||||
|
||||
Reference in New Issue
Block a user