@ -15,6 +15,41 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
[TestFixture]
public class IndexerCheckFixture : CoreTest < IndexerCheck >
{
private IIndexer _indexer ;
private void GivenIndexer ( Boolean supportsRss , Boolean supportsSearch )
{
var _indexer = Mocker . GetMock < IIndexer > ( ) ;
_indexer . SetupGet ( s = > s . SupportsRss ) . Returns ( supportsRss ) ;
_indexer . SetupGet ( s = > s . SupportsSearch ) . Returns ( supportsSearch ) ;
Mocker . GetMock < IIndexerFactory > ( )
. Setup ( s = > s . GetAvailableProviders ( ) )
. Returns ( new List < IIndexer > { _indexer . Object } ) ;
Mocker . GetMock < IIndexerFactory > ( )
. Setup ( s = > s . RssEnabled ( ) )
. Returns ( new List < IIndexer > ( ) ) ;
Mocker . GetMock < IIndexerFactory > ( )
. Setup ( s = > s . SearchEnabled ( ) )
. Returns ( new List < IIndexer > ( ) ) ;
}
private void GivenRssEnabled ( )
{
Mocker . GetMock < IIndexerFactory > ( )
. Setup ( s = > s . RssEnabled ( ) )
. Returns ( new List < IIndexer > { _indexer } ) ;
}
private void GivenSearchEnabled ( )
{
Mocker . GetMock < IIndexerFactory > ( )
. Setup ( s = > s . SearchEnabled ( ) )
. Returns ( new List < IIndexer > { _indexer } ) ;
}
[Test]
public void should_return_error_when_not_indexers_are_enabled ( )
{
@ -26,14 +61,17 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
}
[Test]
public void should_return_warning_when_only_enabled_indexer_ is_wombles ( )
public void should_return_warning_when_only_enabled_indexer_ doesnt_support_search ( )
{
var indexer = Mocker . GetMock < IIndexer > ( ) ;
indexer . SetupGet ( s = > s . SupportsSearching ) . Returns ( false ) ;
GivenIndexer ( true , false ) ;
Mocker . GetMock < IIndexerFactory > ( )
. Setup ( s = > s . GetAvailableProviders ( ) )
. Returns ( new List < IIndexer > { indexer . Object } ) ;
Subject . Check ( ) . ShouldBeWarning ( ) ;
}
[Test]
public void should_return_warning_when_only_enabled_indexer_doesnt_support_rss ( )
{
GivenIndexer ( false , true ) ;
Subject . Check ( ) . ShouldBeWarning ( ) ;
}
@ -41,11 +79,16 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
[Test]
public void should_return_ok_when_multiple_indexers_are_enabled ( )
{
GivenRssEnabled ( ) ;
GivenSearchEnabled ( ) ;
var indexer1 = Mocker . GetMock < IIndexer > ( ) ;
indexer1 . SetupGet ( s = > s . SupportsSearching ) . Returns ( true ) ;
indexer1 . SetupGet ( s = > s . SupportsRss ) . Returns ( true ) ;
indexer1 . SetupGet ( s = > s . SupportsSearch ) . Returns ( true ) ;
var indexer2 = Mocker . GetMock < Wombles > ( ) ;
indexer2 . SetupGet ( s = > s . SupportsSearching ) . Returns ( false ) ;
indexer2 . SetupGet ( s = > s . SupportsRss ) . Returns ( true ) ;
indexer2 . SetupGet ( s = > s . SupportsSearch ) . Returns ( false ) ;
Mocker . GetMock < IIndexerFactory > ( )
. Setup ( s = > s . GetAvailableProviders ( ) )
@ -55,16 +98,31 @@ namespace NzbDrone.Core.Test.HealthCheck.Checks
}
[Test]
public void should_return_ok_when_indexer_supports_ searching ( )
public void should_return_ok_when_indexer_supports_ rss_and_ search( )
{
var indexer1 = Mocker . GetMock < IIndexer > ( ) ;
indexer1 . SetupGet ( s = > s . SupportsSearching ) . Returns ( true ) ;
Mocker . GetMock < IIndexerFactory > ( )
. Setup ( s = > s . GetAvailableProviders ( ) )
. Returns ( new List < IIndexer > { indexer1 . Object } ) ;
GivenIndexer ( true , true ) ;
GivenRssEnabled ( ) ;
GivenSearchEnabled ( ) ;
Subject . Check ( ) . ShouldBeOk ( ) ;
}
[Test]
public void should_return_warning_if_rss_is_supported_but_disabled ( )
{
GivenIndexer ( true , true ) ;
GivenSearchEnabled ( ) ;
Subject . Check ( ) . ShouldBeWarning ( ) ;
}
[Test]
public void should_return_warning_if_search_is_supported_but_disabled ( )
{
GivenIndexer ( true , true ) ;
GivenRssEnabled ( ) ;
Subject . Check ( ) . ShouldBeWarning ( ) ;
}
}
}