1
0
mirror of https://github.com/Radarr/Radarr.git synced 2026-04-18 21:35:51 -04:00

moved config to objectdb.

This commit is contained in:
kay.one
2013-02-23 22:48:52 -08:00
parent 65061cdc96
commit 13658e3c6d
88 changed files with 627 additions and 586 deletions
@@ -7,6 +7,7 @@ using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
@@ -42,28 +43,28 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
[Test]
public void should_be_true_when_allowedReleaseGroups_is_empty()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.AllowedReleaseGroups).Returns(String.Empty);
Mocker.GetMock<ConfigService>().SetupGet(s => s.AllowedReleaseGroups).Returns(String.Empty);
Mocker.Resolve<AllowedReleaseGroupSpecification>().IsSatisfiedBy(parseResult).Should().BeTrue();
}
[Test]
public void should_be_true_when_allowedReleaseGroups_is_nzbs_releaseGroup()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.AllowedReleaseGroups).Returns("2HD");
Mocker.GetMock<ConfigService>().SetupGet(s => s.AllowedReleaseGroups).Returns("2HD");
Mocker.Resolve<AllowedReleaseGroupSpecification>().IsSatisfiedBy(parseResult).Should().BeTrue();
}
[Test]
public void should_be_true_when_allowedReleaseGroups_contains_nzbs_releaseGroup()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.AllowedReleaseGroups).Returns("2HD, LOL");
Mocker.GetMock<ConfigService>().SetupGet(s => s.AllowedReleaseGroups).Returns("2HD, LOL");
Mocker.Resolve<AllowedReleaseGroupSpecification>().IsSatisfiedBy(parseResult).Should().BeTrue();
}
[Test]
public void should_be_false_when_allowedReleaseGroups_does_not_contain_nzbs_releaseGroup()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.AllowedReleaseGroups).Returns("LOL,DTD");
Mocker.GetMock<ConfigService>().SetupGet(s => s.AllowedReleaseGroups).Returns("LOL,DTD");
Mocker.Resolve<AllowedReleaseGroupSpecification>().IsSatisfiedBy(parseResult).Should().BeFalse();
}
}
@@ -7,6 +7,7 @@ using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
@@ -37,22 +38,22 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
private void WithUnlimitedRetention()
{
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.Retention).Returns(0);
Mocker.GetMock<ConfigService>().SetupGet(c => c.Retention).Returns(0);
}
private void WithLongRetention()
{
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.Retention).Returns(1000);
Mocker.GetMock<ConfigService>().SetupGet(c => c.Retention).Returns(1000);
}
private void WithShortRetention()
{
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.Retention).Returns(10);
Mocker.GetMock<ConfigService>().SetupGet(c => c.Retention).Returns(10);
}
private void WithEqualRetention()
{
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.Retention).Returns(100);
Mocker.GetMock<ConfigService>().SetupGet(c => c.Retention).Returns(100);
}
[Test]
+2 -1
View File
@@ -2,6 +2,7 @@
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;
@@ -95,7 +96,7 @@ namespace NzbDrone.Core.Test.Framework
[TearDown]
public void CoreTestTearDown()
{
ConfigProvider.ClearCache();
ConfigService.ClearCache();
if (EnvironmentProvider.IsMono)
{
@@ -10,6 +10,7 @@ using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
@@ -29,17 +30,17 @@ namespace NzbDrone.Core.Test.IndexerTests
{
private void WithConfiguredIndexers()
{
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.NzbsOrgHash).Returns("MockedConfigValue");
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.NzbsOrgUId).Returns("MockedConfigValue");
Mocker.GetMock<ConfigService>().SetupGet(c => c.NzbsOrgHash).Returns("MockedConfigValue");
Mocker.GetMock<ConfigService>().SetupGet(c => c.NzbsOrgUId).Returns("MockedConfigValue");
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.NzbsrusHash).Returns("MockedConfigValue");
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.NzbsrusUId).Returns("MockedConfigValue");
Mocker.GetMock<ConfigService>().SetupGet(c => c.NzbsrusHash).Returns("MockedConfigValue");
Mocker.GetMock<ConfigService>().SetupGet(c => c.NzbsrusUId).Returns("MockedConfigValue");
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.FileSharingTalkUid).Returns("MockedConfigValue");
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.FileSharingTalkSecret).Returns("MockedConfigValue");
Mocker.GetMock<ConfigService>().SetupGet(c => c.FileSharingTalkUid).Returns("MockedConfigValue");
Mocker.GetMock<ConfigService>().SetupGet(c => c.FileSharingTalkSecret).Returns("MockedConfigValue");
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.OmgwtfnzbsUsername).Returns("MockedConfigValue");
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.OmgwtfnzbsApiKey).Returns("MockedConfigValue");
Mocker.GetMock<ConfigService>().SetupGet(c => c.OmgwtfnzbsUsername).Returns("MockedConfigValue");
Mocker.GetMock<ConfigService>().SetupGet(c => c.OmgwtfnzbsApiKey).Returns("MockedConfigValue");
}
[TestCase("nzbsrus.xml")]
@@ -8,6 +8,7 @@ using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
@@ -75,8 +76,8 @@ namespace NzbDrone.Core.Test.Indexers
public class MockIndexer : IndexerBase
{
public MockIndexer(HttpProvider httpProvider, ConfigProvider configProvider)
: base(httpProvider, configProvider)
public MockIndexer(HttpProvider httpProvider, ConfigService configService)
: base(httpProvider, configService)
{
}
@@ -133,8 +134,8 @@ namespace NzbDrone.Core.Test.Indexers
public class TestUrlIndexer : IndexerBase
{
public TestUrlIndexer(HttpProvider httpProvider, ConfigProvider configProvider)
: base(httpProvider, configProvider)
public TestUrlIndexer(HttpProvider httpProvider, ConfigService configService)
: base(httpProvider, configService)
{
}
@@ -186,8 +187,8 @@ namespace NzbDrone.Core.Test.Indexers
public class CustomParserIndexer : IndexerBase
{
public CustomParserIndexer(HttpProvider httpProvider, ConfigProvider configProvider)
: base(httpProvider, configProvider)
public CustomParserIndexer(HttpProvider httpProvider, ConfigService configService)
: base(httpProvider, configService)
{
}
@@ -246,8 +247,8 @@ namespace NzbDrone.Core.Test.Indexers
public class NotConfiguredIndexer : IndexerBase
{
public NotConfiguredIndexer(HttpProvider httpProvider, ConfigProvider configProvider)
: base(httpProvider, configProvider)
public NotConfiguredIndexer(HttpProvider httpProvider, ConfigService configService)
: base(httpProvider, configService)
{
}
@@ -299,8 +300,8 @@ namespace NzbDrone.Core.Test.Indexers
public class DefaultEnabledIndexer : IndexerBase
{
public DefaultEnabledIndexer(HttpProvider httpProvider, ConfigProvider configProvider)
: base(httpProvider, configProvider)
public DefaultEnabledIndexer(HttpProvider httpProvider, ConfigService configService)
: base(httpProvider, configService)
{
}
@@ -4,6 +4,7 @@ using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Jobs;
using NzbDrone.Core.Model;
@@ -21,7 +22,7 @@ namespace NzbDrone.Core.Test.JobTests
{
private void WithEnableBacklogSearching()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.EnableBacklogSearching).Returns(true);
Mocker.GetMock<ConfigService>().SetupGet(s => s.EnableBacklogSearching).Returns(true);
}
[Test]
@@ -7,6 +7,7 @@ using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Jobs;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
@@ -44,7 +45,7 @@ namespace NzbDrone.Core.Test.JobTests
Mocker.GetMock<PostDownloadProvider>().Setup(s => s.ProcessDropFolder(path));
Mocker.Resolve<PostDownloadScanJob>().Start(MockNotification, new { Path = path });
Mocker.GetMock<ConfigProvider>().Verify(s => s.DownloadClientTvDirectory, Times.Never());
Mocker.GetMock<ConfigService>().Verify(s => s.DownloadClientTvDirectory, Times.Never());
}
[Test]
@@ -52,10 +53,10 @@ namespace NzbDrone.Core.Test.JobTests
{
var path = @"C:\Test\Unsorted TV";
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.DownloadClientTvDirectory).Returns(path);
Mocker.GetMock<ConfigService>().SetupGet(s => s.DownloadClientTvDirectory).Returns(path);
Mocker.Resolve<PostDownloadScanJob>().Start(MockNotification, null);
Mocker.GetMock<ConfigProvider>().Verify(s => s.DownloadClientTvDirectory, Times.Once());
Mocker.GetMock<ConfigService>().Verify(s => s.DownloadClientTvDirectory, Times.Once());
}
[Test]
@@ -63,7 +64,7 @@ namespace NzbDrone.Core.Test.JobTests
{
var path = @"C:\Test\Unsorted TV";
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.DownloadClientTvDirectory).Returns(path);
Mocker.GetMock<ConfigService>().SetupGet(s => s.DownloadClientTvDirectory).Returns(path);
Mocker.Resolve<PostDownloadScanJob>().Start(MockNotification, null);
Mocker.GetMock<PostDownloadProvider>().Verify(s => s.ProcessDropFolder(path), Times.Once());
@@ -6,6 +6,7 @@ using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Jobs;
using NzbDrone.Core.Model;
@@ -24,7 +25,7 @@ namespace NzbDrone.Core.Test.JobTests
{
private void WithEnableBacklogSearching()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.EnableBacklogSearching).Returns(true);
Mocker.GetMock<ConfigService>().SetupGet(s => s.EnableBacklogSearching).Returns(true);
}
[SetUp]
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Jobs;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers;
@@ -18,7 +19,7 @@ namespace NzbDrone.Core.Test.JobTests
{
public void WithMinutes(int minutes)
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.RssSyncInterval).Returns(minutes);
Mocker.GetMock<ConfigService>().SetupGet(s => s.RssSyncInterval).Returns(minutes);
}
[TestCase(10)]
+2 -2
View File
@@ -172,7 +172,7 @@
<Compile Include="JobTests\PostDownloadScanJobFixture.cs" />
<Compile Include="JobTests\RecentBacklogSearchJobTest.cs" />
<Compile Include="ParserTests\QualityParserFixture.cs" />
<Compile Include="ProviderTests\ConfigProviderTests\ConfigCachingFixture.cs" />
<Compile Include="Configuration\ConfigCachingFixture.cs" />
<Compile Include="ProviderTests\BannerProviderTest.cs" />
<Compile Include="DecisionEngineTests\AllowedReleaseGroupSpecificationFixture.cs" />
<Compile Include="DecisionEngineTests\CustomStartDateSpecificationFixture.cs" />
@@ -250,7 +250,7 @@
<Compile Include="Indexers\IndexerServiceTest.cs" />
<Compile Include="HistoryTests\HistoryServiceTest.cs" />
<Compile Include="ProviderTests\MediaFileProviderTest.cs" />
<Compile Include="ProviderTests\ConfigProviderTests\ConfigProviderFixture.cs" />
<Compile Include="Configuration\ConfigServiceFixture.cs" />
<Compile Include="TvTests\EpisodeProviderTests\EpisodeProviderTest.cs" />
<Compile Include="Framework\TestDbHelper.cs" />
<Compile Include="ParserTests\ParserFixture.cs" />
@@ -1,35 +0,0 @@
using System.Collections.Generic;
using System.Linq;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Test.Framework;
using PetaPoco;
namespace NzbDrone.Core.Test.ProviderTests.ConfigProviderTests
{
[TestFixture]
public class ConfigCachingFixture : CoreTest
{
[SetUp]
public void Setup()
{
Mocker.GetMock<IDatabase>().Setup(c => c.Fetch<Config>())
.Returns(new List<Config> { new Config { Key = "Key1", Value = "Value1" } });
}
[Test]
public void getting_value_more_than_once_should_hit_db_once()
{
Mocker.Resolve<ConfigProvider>().GetValue("Key1", null).Should().Be("Value1");
Mocker.Resolve<ConfigProvider>().GetValue("Key1", null).Should().Be("Value1");
Mocker.Resolve<ConfigProvider>().GetValue("Key1", null).Should().Be("Value1");
Mocker.GetMock<IDatabase>().Verify(c => c.Fetch<Config>(), Times.Once());
}
}
}
@@ -1,192 +0,0 @@
using System;
using System.Linq;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.ProviderTests.ConfigProviderTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class ConfigProviderFixture : SqlCeTest
{
[SetUp]
public void SetUp()
{
WithRealDb();
}
[Test]
public void Add_new_value_to_database()
{
const string key = "MY_KEY";
const string value = "MY_VALUE";
Mocker.Resolve<ConfigProvider>().SetValue(key, value);
Mocker.Resolve<ConfigProvider>().GetValue(key, "").Should().Be(value);
}
[Test]
public void Get_value_from_database()
{
const string key = "MY_KEY";
const string value = "MY_VALUE";
Db.Insert(new Config { Key = key, Value = value });
Db.Insert(new Config { Key = "Other Key", Value = "OtherValue" });
//Act
var result = Mocker.Resolve<ConfigProvider>().GetValue(key, "");
//Assert
result.Should().Be(value);
}
[Test]
public void Get_value_should_return_default_when_no_value()
{
const string key = "MY_KEY";
const string value = "MY_VALUE";
//Act
var result = Mocker.Resolve<ConfigProvider>().GetValue(key, value);
//Assert
result.Should().Be(value);
}
[Test]
public void New_value_should_update_old_value_new_value()
{
const string key = "MY_KEY";
const string originalValue = "OLD_VALUE";
const string newValue = "NEW_VALUE";
Db.Insert(new Config { Key = key, Value = originalValue });
//Act
Mocker.Resolve<ConfigProvider>().SetValue(key, newValue);
var result = Mocker.Resolve<ConfigProvider>().GetValue(key, "");
//Assert
result.Should().Be(newValue);
Db.Fetch<Config>().Should().HaveCount(1);
}
[Test]
public void New_value_should_update_old_value_same_value()
{
const string key = "MY_KEY";
const string value = "OLD_VALUE";
//Act
Mocker.Resolve<ConfigProvider>().SetValue(key, value);
Mocker.Resolve<ConfigProvider>().SetValue(key, value);
var result = Mocker.Resolve<ConfigProvider>().GetValue(key, "");
//Assert
result.Should().Be(value);
Db.Fetch<Config>().Should().HaveCount(1);
}
[Test]
public void get_value_with_persist_should_store_default_value()
{
const string key = "MY_KEY";
string value = Guid.NewGuid().ToString();
//Act
Mocker.Resolve<ConfigProvider>().GetValue(key, value, persist: true).Should().Be(value);
Mocker.Resolve<ConfigProvider>().GetValue(key, string.Empty).Should().Be(value);
}
[Test]
public void get_value_with_out_persist_should_not_store_default_value()
{
const string key = "MY_KEY";
string value1 = Guid.NewGuid().ToString();
string value2 = Guid.NewGuid().ToString();
//Act
Mocker.Resolve<ConfigProvider>().GetValue(key, value1).Should().Be(value1);
Mocker.Resolve<ConfigProvider>().GetValue(key, value2).Should().Be(value2);
}
[Test]
public void uguid_should_only_be_set_once()
{
var guid1 = Mocker.Resolve<ConfigProvider>().UGuid;
var guid2 = Mocker.Resolve<ConfigProvider>().UGuid;
guid1.Should().Be(guid2);
}
[Test]
public void uguid_should_return_valid_result_on_first_call()
{
var guid = Mocker.Resolve<ConfigProvider>().UGuid;
guid.Should().NotBeEmpty();
}
[Test]
public void updating_a_vakye_should_update_its_value()
{
Mocker.Resolve<ConfigProvider>().SabHost = "Test";
Mocker.Resolve<ConfigProvider>().SabHost.Should().Be("Test");
Mocker.Resolve<ConfigProvider>().SabHost = "Test2";
Mocker.Resolve<ConfigProvider>().SabHost.Should().Be("Test2");
}
[Test]
[Description("This test will use reflection to ensure each config property read/writes to a unique key")]
public void config_properties_should_write_and_read_using_same_key()
{
var configProvider = Mocker.Resolve<ConfigProvider>();
var allProperties = typeof(ConfigProvider).GetProperties().Where(p => p.GetSetMethod() != null);
//Act
foreach (var propertyInfo in allProperties)
{
object value = null;
if (propertyInfo.PropertyType == typeof(string))
{
value = new Guid().ToString();
}
else if (propertyInfo.PropertyType == typeof(int))
{
value = DateTime.Now.Millisecond;
}
else if (propertyInfo.PropertyType == typeof(bool))
{
value = true;
}
else if (propertyInfo.PropertyType.BaseType == typeof(Enum))
{
value = 0;
}
propertyInfo.GetSetMethod().Invoke(configProvider, new[] { value });
var returnValue = propertyInfo.GetGetMethod().Invoke(configProvider, null);
if (propertyInfo.PropertyType.BaseType == typeof(Enum))
{
returnValue = (int)returnValue;
}
returnValue.Should().Be(value, propertyInfo.Name);
}
Db.Fetch<Config>().Should()
.HaveSameCount(allProperties, "two different properties are writing to the same key in db. Copy/Past fail.");
}
}
}
@@ -8,6 +8,7 @@ using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
@@ -90,7 +91,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
Mocker.GetMock<MediaFileProvider>()
.Setup(e => e.Delete(It.IsAny<int>()));
Mocker.GetMock<ConfigProvider>()
Mocker.GetMock<ConfigService>()
.SetupGet(s => s.AutoIgnorePreviouslyDownloadedEpisodes)
.Returns(true);
@@ -8,6 +8,7 @@ using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.DownloadClients;
using NzbDrone.Core.Test.Framework;
@@ -26,7 +27,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests
[SetUp]
public void Setup()
{
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.BlackholeDirectory).Returns(blackHoleFolder);
Mocker.GetMock<ConfigService>().SetupGet(c => c.BlackholeDirectory).Returns(blackHoleFolder);
}
@@ -7,6 +7,7 @@ using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Model.Nzbget;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.DownloadClients;
@@ -19,7 +20,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.NzbgetProviderTes
[SetUp]
public void Setup()
{
var fakeConfig = Mocker.GetMock<ConfigProvider>();
var fakeConfig = Mocker.GetMock<ConfigService>();
fakeConfig.SetupGet(c => c.NzbgetHost).Returns("192.168.5.55");
fakeConfig.SetupGet(c => c.NzbgetPort).Returns(6789);
fakeConfig.SetupGet(c => c.NzbgetUsername).Returns("nzbget");
@@ -7,6 +7,7 @@ using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Model.Nzbget;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.DownloadClients;
@@ -19,7 +20,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.NzbgetProviderTes
[SetUp]
public void Setup()
{
var fakeConfig = Mocker.GetMock<ConfigProvider>();
var fakeConfig = Mocker.GetMock<ConfigService>();
fakeConfig.SetupGet(c => c.NzbgetHost).Returns("192.168.5.55");
fakeConfig.SetupGet(c => c.NzbgetPort).Returns(6789);
fakeConfig.SetupGet(c => c.NzbgetUsername).Returns("nzbget");
@@ -8,6 +8,7 @@ using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.DownloadClients;
using NzbDrone.Core.Test.Framework;
@@ -29,8 +30,8 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests
{
nzbPath = pneumaticFolder + title + ".nzb";
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.PneumaticDirectory).Returns(pneumaticFolder);
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.DownloadClientTvDirectory).Returns(sabDrop);
Mocker.GetMock<ConfigService>().SetupGet(c => c.PneumaticDirectory).Returns(pneumaticFolder);
Mocker.GetMock<ConfigService>().SetupGet(c => c.DownloadClientTvDirectory).Returns(sabDrop);
}
private void WithExistingFile()
@@ -8,6 +8,7 @@ using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Sabnzbd;
@@ -35,7 +36,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests
string password = "pass";
string cat = "tv";
var fakeConfig = Mocker.GetMock<ConfigProvider>();
var fakeConfig = Mocker.GetMock<ConfigService>();
fakeConfig.SetupGet(c => c.SabHost).Returns(sabHost);
fakeConfig.SetupGet(c => c.SabPort).Returns(sabPort);
fakeConfig.SetupGet(c => c.SabApiKey).Returns(apikey);
@@ -10,6 +10,7 @@ using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Sabnzbd;
using NzbDrone.Core.Providers.Core;
@@ -31,7 +32,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests
[SetUp]
public void Setup()
{
var fakeConfig = Mocker.GetMock<ConfigProvider>();
var fakeConfig = Mocker.GetMock<ConfigService>();
fakeConfig.SetupGet(c => c.SabHost).Returns("192.168.5.55");
fakeConfig.SetupGet(c => c.SabPort).Returns(2222);
@@ -209,11 +210,11 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests
[Test]
public void downloadNzb_should_use_sabRecentTvPriority_when_recentEpisode_is_true()
{
Mocker.GetMock<ConfigProvider>()
Mocker.GetMock<ConfigService>()
.SetupGet(s => s.SabRecentTvPriority)
.Returns(SabPriorityType.High);
Mocker.GetMock<ConfigProvider>()
Mocker.GetMock<ConfigService>()
.SetupGet(s => s.SabBacklogTvPriority)
.Returns(SabPriorityType.Low);
@@ -231,11 +232,11 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.SabProviderTests
[Test]
public void downloadNzb_should_use_sabBackogTvPriority_when_recentEpisode_is_false()
{
Mocker.GetMock<ConfigProvider>()
Mocker.GetMock<ConfigService>()
.SetupGet(s => s.SabRecentTvPriority)
.Returns(SabPriorityType.High);
Mocker.GetMock<ConfigProvider>()
Mocker.GetMock<ConfigService>()
.SetupGet(s => s.SabBacklogTvPriority)
.Returns(SabPriorityType.Low);
@@ -5,6 +5,7 @@ using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.History;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
@@ -33,7 +34,7 @@ namespace NzbDrone.Core.Test.ProviderTests.DownloadProviderTests
private void SetDownloadClient(DownloadClientType clientType)
{
Mocker.GetMock<ConfigProvider>()
Mocker.GetMock<ConfigService>()
.Setup(c => c.DownloadClient)
.Returns(clientType);
}
@@ -8,6 +8,7 @@ using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
@@ -133,7 +134,7 @@ namespace NzbDrone.Core.Test.ProviderTests
.Build();
Mocker.GetMock<ConfigProvider>().Setup(e => e.SortingSeasonFolderFormat).Returns(seasonFolderFormat);
Mocker.GetMock<ConfigService>().Setup(e => e.SortingSeasonFolderFormat).Returns(seasonFolderFormat);
//Act
var result = Mocker.Resolve<MediaFileProvider>().CalculateFilePath(fakeSeries, 1, filename, ".mkv");
@@ -8,6 +8,7 @@ using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers;
@@ -93,7 +94,7 @@ namespace NzbDrone.Core.Test.ProviderTests.Metadata
private void WithUseBanners()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.MetadataUseBanners).Returns(true);
Mocker.GetMock<ConfigService>().SetupGet(s => s.MetadataUseBanners).Returns(true);
}
private void WithSingleEpisodeFile()
@@ -7,6 +7,7 @@ using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers;
@@ -75,7 +76,7 @@ namespace NzbDrone.Core.Test.ProviderTests.Metadata
private void WithUseBanners()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.MetadataUseBanners).Returns(true);
Mocker.GetMock<ConfigService>().SetupGet(s => s.MetadataUseBanners).Returns(true);
}
private void WithSpecials()
@@ -10,6 +10,7 @@ using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Model.Xbmc;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
@@ -26,22 +27,22 @@ namespace NzbDrone.Core.Test.ProviderTests
{
private void WithSingleClient()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.PlexClientHosts)
Mocker.GetMock<ConfigService>().SetupGet(s => s.PlexClientHosts)
.Returns("localhost:3000");
}
private void WithMultipleClients()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.PlexClientHosts)
Mocker.GetMock<ConfigService>().SetupGet(s => s.PlexClientHosts)
.Returns("localhost:3000, 192.168.0.10:3000");
}
public void WithClientCredentials()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.PlexUsername)
Mocker.GetMock<ConfigService>().SetupGet(s => s.PlexUsername)
.Returns("plex");
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.PlexPassword)
Mocker.GetMock<ConfigService>().SetupGet(s => s.PlexPassword)
.Returns("plex");
}
@@ -10,6 +10,7 @@ using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
@@ -49,7 +50,7 @@ namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests
[SetUp]
public void Setup()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.RecycleBin).Returns(RecycleBin);
Mocker.GetMock<ConfigService>().SetupGet(s => s.RecycleBin).Returns(RecycleBin);
Mocker.GetMock<DiskProvider>().Setup(s => s.GetDirectories(RecycleBin))
.Returns(new [] { @"C:\Test\RecycleBin\Folder1", @"C:\Test\RecycleBin\Folder2", @"C:\Test\RecycleBin\Folder3" });
@@ -61,7 +62,7 @@ namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests
[Test]
public void should_return_if_recycleBin_not_configured()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.RecycleBin).Returns(String.Empty);
Mocker.GetMock<ConfigService>().SetupGet(s => s.RecycleBin).Returns(String.Empty);
Mocker.Resolve<RecycleBinProvider>().Cleanup();
@@ -10,6 +10,7 @@ using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
@@ -28,12 +29,12 @@ namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests
{
private void WithRecycleBin()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.RecycleBin).Returns(@"C:\Test\Recycle Bin");
Mocker.GetMock<ConfigService>().SetupGet(s => s.RecycleBin).Returns(@"C:\Test\Recycle Bin");
}
private void WithoutRecycleBin()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.RecycleBin).Returns(String.Empty);
Mocker.GetMock<ConfigService>().SetupGet(s => s.RecycleBin).Returns(String.Empty);
}
[Test]
@@ -10,6 +10,7 @@ using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
@@ -28,12 +29,12 @@ namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests
{
private void WithRecycleBin()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.RecycleBin).Returns(@"C:\Test\Recycle Bin");
Mocker.GetMock<ConfigService>().SetupGet(s => s.RecycleBin).Returns(@"C:\Test\Recycle Bin");
}
private void WithoutRecycleBin()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.RecycleBin).Returns(String.Empty);
Mocker.GetMock<ConfigService>().SetupGet(s => s.RecycleBin).Returns(String.Empty);
}
[Test]
@@ -10,6 +10,7 @@ using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
@@ -31,7 +32,7 @@ namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests
[SetUp]
public void Setup()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.RecycleBin).Returns(RecycleBin);
Mocker.GetMock<ConfigService>().SetupGet(s => s.RecycleBin).Returns(RecycleBin);
Mocker.GetMock<DiskProvider>().Setup(s => s.GetDirectories(RecycleBin))
.Returns(new [] { @"C:\Test\RecycleBin\Folder1", @"C:\Test\RecycleBin\Folder2", @"C:\Test\RecycleBin\Folder3" });
@@ -43,7 +44,7 @@ namespace NzbDrone.Core.Test.ProviderTests.RecycleBinProviderTests
[Test]
public void should_return_if_recycleBin_not_configured()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.RecycleBin).Returns(String.Empty);
Mocker.GetMock<ConfigService>().SetupGet(s => s.RecycleBin).Returns(String.Empty);
Mocker.Resolve<RecycleBinProvider>().Empty();
@@ -6,10 +6,10 @@ 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.Repository;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common;
@@ -27,7 +27,7 @@ namespace NzbDrone.Core.Test.ProviderTests
[SetUp]
public void Setup()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.ServiceRootUrl)
Mocker.GetMock<ConfigService>().SetupGet(s => s.ServiceRootUrl)
.Returns("http://services.nzbdrone.com");
}
@@ -6,6 +6,7 @@ using FluentAssertions;
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;
@@ -23,7 +24,7 @@ namespace NzbDrone.Core.Test.ProviderTests
[SetUp]
public void Setup()
{
Mocker.GetMock<ConfigProvider>().SetupGet(s => s.ServiceRootUrl)
Mocker.GetMock<ConfigService>().SetupGet(s => s.ServiceRootUrl)
.Returns("http://services.nzbdrone.com");
WithRealDb();
@@ -4,6 +4,7 @@ using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Test.Framework;
@@ -22,7 +23,7 @@ namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests
{
WithStrictMocker();
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.UpdateUrl).Returns("http://update.nzbdrone.com/_test/");
Mocker.GetMock<ConfigService>().SetupGet(c => c.UpdateUrl).Returns("http://update.nzbdrone.com/_test/");
Mocker.Resolve<HttpProvider>();
}
@@ -7,6 +7,7 @@ using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model.Xbmc;
using NzbDrone.Core.Providers;
@@ -296,7 +297,7 @@ namespace NzbDrone.Core.Test.ProviderTests
var header = "NzbDrone Test";
var message = "Test Message!";
var fakeConfig = Mocker.GetMock<ConfigProvider>();
var fakeConfig = Mocker.GetMock<ConfigService>();
fakeConfig.SetupGet(s => s.XbmcHosts).Returns("localhost:8080");
//var fakeUdpProvider = Mocker.GetMock<EventClient>();
@@ -440,7 +441,7 @@ namespace NzbDrone.Core.Test.ProviderTests
//Setup
WithStrictMocker();
var fakeConfig = Mocker.GetMock<ConfigProvider>();
var fakeConfig = Mocker.GetMock<ConfigService>();
fakeConfig.SetupGet(s => s.XbmcHosts).Returns("localhost:8080");
var fakeEventClient = Mocker.GetMock<EventClientProvider>();
@@ -7,6 +7,7 @@ using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
@@ -814,7 +815,7 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeProviderTests
WithRealDb();
Mocker.Resolve<TvDbProvider>();
Mocker.GetMock<ConfigProvider>()
Mocker.GetMock<ConfigService>()
.Setup(e => e.DefaultQualityProfile).Returns(1);
Db.Insert(Builder<QualityProfile>.CreateNew().Build());
Binary file not shown.