@ -8,116 +8,85 @@ using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.HealthCheck.Checks
{
[TestFixture]
public class Indexer CheckFixture : CoreTest < Indexer Check>
public class Indexer Search CheckFixture : CoreTest < Indexer Search Check>
{
private Mock < IIndexer > _indexerMock ;
private void GivenIndexer ( bool supportsRss , bool supportsSearch )
[SetUp]
public void SetUp ( )
{
_indexerMock = Mocker . GetMock < IIndexer > ( ) ;
_indexerMock . SetupGet ( s = > s . SupportsRss ) . Returns ( supportsRss ) ;
_indexerMock . SetupGet ( s = > s . SupportsSearch ) . Returns ( supportsSearch ) ;
Mocker . GetMock < IIndexerFactory > ( )
. Setup ( s = > s . GetAvailableProviders ( ) )
. Returns ( new List < IIndexer > { _indexerMock . Object } ) ;
Mocker . GetMock < IIndexerFactory > ( )
. Setup ( s = > s . RssEnabled ( true ) )
. Returns ( new List < IIndexer > ( ) ) ;
Mocker . GetMock < IIndexerFactory > ( )
. Setup ( s = > s . SearchEnabled ( true ) )
. Setup ( s = > s . SearchEnabled ( It . IsAny < bool > ( ) ) )
. Returns ( new List < IIndexer > ( ) ) ;
}
private void Given RssEnabled( )
private void Given Indexer( bool supportsRss , bool supportsSearch )
{
_indexerMock = Mocker . GetMock < IIndexer > ( ) ;
_indexerMock . SetupGet ( s = > s . SupportsRss ) . Returns ( supportsRss ) ;
_indexerMock . SetupGet ( s = > s . SupportsSearch ) . Returns ( supportsSearch ) ;
Mocker . GetMock < IIndexerFactory > ( )
. Setup ( s = > s . RssEnabled ( true ) )
. Setup ( s = > s . GetAvailableProviders( ) )
. Returns ( new List < IIndexer > { _indexerMock . Object } ) ;
}
private void GivenSearchEnabled ( )
{
Mocker . GetMock < IIndexerFactory > ( )
. Setup ( s = > s . SearchEnabled ( true ) )
. Setup ( s = > s . SearchEnabled ( It . IsAny < bool > ( ) ) )
. Returns ( new List < IIndexer > { _indexerMock . Object } ) ;
}
[Test]
public void should_return_error_when_not_indexers_are_enabled ( )
private void GivenSearchFiltered ( )
{
Mocker . GetMock < IIndexerFactory > ( )
. Setup ( s = > s . GetAvailableProviders ( ) )
. Returns ( new List < IIndexer > ( ) ) ;
Subject . Check ( ) . ShouldBeError ( ) ;
. Setup ( s = > s . SearchEnabled ( false ) )
. Returns ( new List < IIndexer > { _indexerMock . Object } ) ;
}
[Test]
public void should_return_warning_when_ only_enabled_indexer_doesnt_support_search ( )
public void should_return_warning_when_ no_indexer_present ( )
{
GivenIndexer ( true , false ) ;
Subject . Check ( ) . ShouldBeWarning ( ) ;
}
[Test]
public void should_return_warning_when_ only_enabled_indexer_doesnt_support_rss ( )
public void should_return_warning_when_ no_search_supported_indexer_present ( )
{
GivenIndexer ( false, tru e) ;
GivenIndexer ( true, fals e) ;
Subject . Check ( ) . ShouldBeWarning ( ) ;
}
[Test]
public void should_return_ok_when_ multiple_indexers_are _enabled( )
public void should_return_ok_when_ search_is _enabled( )
{
GivenRssEnabled ( ) ;
GivenSearchEnabled ( ) ;
var indexer1 = Mocker . GetMock < IIndexer > ( ) ;
indexer1 . SetupGet ( s = > s . SupportsRss ) . Returns ( true ) ;
indexer1 . SetupGet ( s = > s . SupportsSearch ) . Returns ( true ) ;
var indexer2 = new Moq . Mock < IIndexer > ( ) ;
indexer2 . SetupGet ( s = > s . SupportsRss ) . Returns ( true ) ;
indexer2 . SetupGet ( s = > s . SupportsSearch ) . Returns ( false ) ;
Mocker . GetMock < IIndexerFactory > ( )
. Setup ( s = > s . GetAvailableProviders ( ) )
. Returns ( new List < IIndexer > { indexer1 . Object , indexer2 . Object } ) ;
Subject . Check ( ) . ShouldBeOk ( ) ;
}
[Test]
public void should_return_ok_when_indexer_supports_rss_and_search ( )
{
GivenIndexer ( true , true ) ;
GivenRssEnabled ( ) ;
GivenIndexer ( false , true ) ;
GivenSearchEnabled ( ) ;
Subject . Check ( ) . ShouldBeOk ( ) ;
}
[Test]
public void should_return_warning_if_ rss _is_supported_but_disabled( )
public void should_return_warning_if_search_is_supported_but_disabled ( )
{
GivenIndexer ( true , true ) ;
GivenSearchEnabled ( ) ;
GivenIndexer ( false , true ) ;
Subject . Check ( ) . ShouldBeWarning ( ) ;
}
[Test]
public void should_return_ warning_if_search_is_supported_but_disabl ed( )
public void should_return_filter_warning_if_search_is_enabled_but_filtered ( )
{
GivenIndexer ( tru e, true ) ;
Given RssEnabl ed( ) ;
GivenIndexer ( false , true ) ;
GivenSearchFiltered ( ) ;
Subject . Check ( ) . ShouldBeWarning ( ) ;
Subject . Check ( ) . ShouldBeWarning ( "recent indexer errors" ) ;
}
}
}