Fixed: Search failure is more friendly.

Womble's Index is enabled by default.
This commit is contained in:
Mark McDowall 2012-04-14 15:33:58 -07:00
parent 8fa145b2c3
commit 55cbc59887
5 changed files with 103 additions and 3 deletions

View File

@ -60,6 +60,38 @@ namespace NzbDrone.Core.Test.ProviderTests
indexerProvider.All().Should().HaveCount(1); indexerProvider.All().Should().HaveCount(1);
indexerProvider.GetEnabledIndexers().Should().BeEmpty(); indexerProvider.GetEnabledIndexers().Should().BeEmpty();
} }
[Test]
public void Init_indexer_should_enable_indexer_that_is_enabled_by_default()
{
Mocker.SetConstant(TestDbHelper.GetEmptyDatabase());
//Act
var indexerProvider = Mocker.Resolve<IndexerProvider>();
indexerProvider.InitializeIndexers(new List<IndexerBase> { Mocker.Resolve<DefaultEnabledIndexer>() });
//Assert
indexerProvider.All();
indexerProvider.All().Should().HaveCount(1);
indexerProvider.GetEnabledIndexers().Should().HaveCount(1);
indexerProvider.GetSettings(typeof(DefaultEnabledIndexer)).Enable.Should().BeTrue();
}
[Test]
public void Init_indexer_should_not_enable_indexer_that_is_not_enabled_by_default()
{
Mocker.SetConstant(TestDbHelper.GetEmptyDatabase());
//Act
var indexerProvider = Mocker.Resolve<IndexerProvider>();
indexerProvider.InitializeIndexers(new List<IndexerBase> { Mocker.Resolve<MockIndexer>() });
//Assert
indexerProvider.All();
indexerProvider.All().Should().HaveCount(1);
indexerProvider.GetEnabledIndexers().Should().HaveCount(0);
indexerProvider.GetSettings(typeof(MockIndexer)).Enable.Should().BeFalse();
}
} }
public class MockIndexer : IndexerBase public class MockIndexer : IndexerBase
@ -267,4 +299,61 @@ namespace NzbDrone.Core.Test.ProviderTests
} }
} }
public class DefaultEnabledIndexer : IndexerBase
{
public DefaultEnabledIndexer(HttpProvider httpProvider, ConfigProvider configProvider)
: base(httpProvider, configProvider)
{
}
protected override string[] Urls
{
get { return new[] { "www.google.com" }; }
}
public override bool IsConfigured
{
get { return true; }
}
protected override NetworkCredential Credentials
{
get { return null; }
}
protected override IList<string> GetEpisodeSearchUrls(string seriesTitle, int seasonNumber, int episodeNumber)
{
throw new NotImplementedException();
}
protected override IList<string> GetDailyEpisodeSearchUrls(string seriesTitle, DateTime date)
{
throw new NotImplementedException();
}
protected override IList<string> GetSeasonSearchUrls(string seriesTitle, int seasonNumber)
{
throw new NotImplementedException();
}
protected override IList<string> GetPartialSeasonSearchUrls(string seriesTitle, int seasonNumber, int episodeWildcard)
{
throw new NotImplementedException();
}
public override string Name
{
get { return "Mocked Indexer"; }
}
protected override string NzbDownloadUrl(SyndicationItem item)
{
return item.Links[0].Uri.ToString();
}
public override bool EnabledByDefault
{
get { return true; }
}
}
} }

View File

@ -45,9 +45,15 @@ namespace NzbDrone.Core.Providers.Indexer
/// </summary> /// </summary>
protected abstract string[] Urls { get; } protected abstract string[] Urls { get; }
public abstract bool IsConfigured { get; } public abstract bool IsConfigured { get; }
/// <summary>
/// Should the indexer be enabled by default?
/// </summary>
public virtual bool EnabledByDefault
{
get { return false; }
}
/// <summary> /// <summary>
/// Gets the credential. /// Gets the credential.

View File

@ -75,5 +75,10 @@ namespace NzbDrone.Core.Providers.Indexer
return currentResult; return currentResult;
} }
public override bool EnabledByDefault
{
get { return true; }
}
} }
} }

View File

@ -73,7 +73,7 @@ namespace NzbDrone.Core.Providers
{ {
var settings = new IndexerDefinition var settings = new IndexerDefinition
{ {
Enable = false, Enable = indexerLocal.EnabledByDefault,
IndexProviderType = indexerLocal.GetType().ToString(), IndexProviderType = indexerLocal.GetType().ToString(),
Name = indexerLocal.Name Name = indexerLocal.Name
}; };

View File

@ -163,7 +163,7 @@ namespace NzbDrone.Core.Providers
if (reports.Any()) if (reports.Any())
{ {
notification.CurrentMessage = String.Format("Sorry, couldn't find {0} in a non-sucky quality. (by your standards)", episode); notification.CurrentMessage = String.Format("Sorry, couldn't find {0}, that matches your preferences.", episode);
} }
else else
{ {