nullconfig indexers are enabled by default.

This commit is contained in:
kayone 2013-10-01 12:32:08 -07:00
parent 1b234f40df
commit 27bd59268d
5 changed files with 34 additions and 7 deletions

View File

@ -182,6 +182,7 @@
<Compile Include="ProviderTests\RecycleBinProviderTests\DeleteDirectoryFixture.cs" /> <Compile Include="ProviderTests\RecycleBinProviderTests\DeleteDirectoryFixture.cs" />
<Compile Include="NotificationTests\PlexProviderTest.cs" /> <Compile Include="NotificationTests\PlexProviderTest.cs" />
<Compile Include="Housekeeping\Housekeepers\CleanupOrphanedEpisodesFixture.cs" /> <Compile Include="Housekeeping\Housekeepers\CleanupOrphanedEpisodesFixture.cs" />
<Compile Include="ThingiProviderTests\NullConfigFixture.cs" />
<Compile Include="ThingiProvider\ProviderBaseFixture.cs" /> <Compile Include="ThingiProvider\ProviderBaseFixture.cs" />
<Compile Include="TvTests\RefreshEpisodeServiceFixture.cs" /> <Compile Include="TvTests\RefreshEpisodeServiceFixture.cs" />
<Compile Include="TvTests\EpisodeProviderTests\HandleEpisodeFileDeletedFixture.cs" /> <Compile Include="TvTests\EpisodeProviderTests\HandleEpisodeFileDeletedFixture.cs" />

View File

@ -0,0 +1,17 @@
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.ThingiProvider;
namespace NzbDrone.Core.Test.ThingiProviderTests
{
[TestFixture]
public class NullConfigFixture : CoreTest<NullConfig>
{
[Test]
public void should_be_valid()
{
Subject.Validate().IsValid.Should().BeTrue();
}
}
}

View File

@ -4,7 +4,7 @@ using NzbDrone.Core.ThingiProvider;
namespace NzbDrone.Core.Indexers namespace NzbDrone.Core.Indexers
{ {
public abstract class IndexerBase<TSettings> : IIndexer public abstract class IndexerBase<TSettings> : IIndexer where TSettings : IProviderConfig, new()
{ {
public Type ConfigContract public Type ConfigContract
{ {
@ -18,12 +18,14 @@ namespace NzbDrone.Core.Indexers
{ {
get get
{ {
var config = (IProviderConfig)new TSettings();
yield return new IndexerDefinition yield return new IndexerDefinition
{ {
Name = this.GetType().Name, Name = GetType().Name,
Enable = false, Enable = config.Validate().IsValid,
Implementation = GetType().Name, Implementation = GetType().Name,
Settings = NullConfig.Instance Settings = config
}; };
} }
} }

View File

@ -1,5 +1,7 @@
using FluentAssertions; using System.Linq;
using FluentAssertions;
using NUnit.Framework; using NUnit.Framework;
using NzbDrone.Core.ThingiProvider;
namespace NzbDrone.Integration.Test namespace NzbDrone.Integration.Test
{ {
@ -13,6 +15,7 @@ namespace NzbDrone.Integration.Test
indexers.Should().NotBeEmpty(); indexers.Should().NotBeEmpty();
indexers.Should().NotContain(c => string.IsNullOrWhiteSpace(c.Name)); indexers.Should().NotContain(c => string.IsNullOrWhiteSpace(c.Name));
indexers.Where(c => c.ConfigContract == typeof(NullConfig).Name).Should().OnlyContain(c => c.Enable);
} }
} }
} }

View File

@ -1,4 +1,5 @@
using FluentAssertions; using System.Threading;
using FluentAssertions;
using NUnit.Framework; using NUnit.Framework;
using NzbDrone.Api.Indexers; using NzbDrone.Api.Indexers;
@ -10,10 +11,13 @@ namespace NzbDrone.Integration.Test
[Test] [Test]
public void should_only_have_unknown_series_releases() public void should_only_have_unknown_series_releases()
{ {
var releases = Releases.All(); var releases = Releases.All();
var indexers = Indexers.All();
releases.Should().OnlyContain(c => c.Rejections.Contains("Unknown Series")); releases.Should().OnlyContain(c => c.Rejections.Contains("Unknown Series"));
releases.Should().OnlyContain(c=>BeValidRelease(c)); releases.Should().OnlyContain(c => BeValidRelease(c));
} }