2013-01-13 08:24:48 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using FluentAssertions;
|
|
|
|
using Moq;
|
|
|
|
using NUnit.Framework;
|
2013-03-07 03:45:36 +00:00
|
|
|
using NzbDrone.Core.IndexerSearch;
|
2013-02-19 06:01:03 +00:00
|
|
|
using NzbDrone.Core.Tv;
|
2013-01-13 08:24:48 +00:00
|
|
|
using NzbDrone.Test.Common;
|
|
|
|
|
2013-03-07 03:45:36 +00:00
|
|
|
namespace NzbDrone.Core.Test.IndexerSearchTests.EpisodeSearchTests
|
2013-01-13 08:24:48 +00:00
|
|
|
{
|
|
|
|
[TestFixture]
|
2013-03-07 03:45:36 +00:00
|
|
|
public class IndexerEpisodeSearchFixture : IndexerSearchTestBase<EpisodeSearch>
|
2013-01-13 08:24:48 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void should_fetch_results_from_indexers()
|
|
|
|
{
|
|
|
|
WithValidIndexers();
|
|
|
|
|
2013-03-07 03:45:36 +00:00
|
|
|
Subject
|
|
|
|
.PerformSearch(_series, new List<Episode> { _episode }, notification)
|
|
|
|
.Should()
|
|
|
|
.HaveCount(20);
|
2013-01-13 08:24:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void should_log_error_when_fetching_from_indexer_fails()
|
|
|
|
{
|
2013-03-07 03:45:36 +00:00
|
|
|
WithBrokenIndexers();
|
2013-01-13 08:24:48 +00:00
|
|
|
|
2013-03-07 03:45:36 +00:00
|
|
|
Subject
|
|
|
|
.PerformSearch(_series, new List<Episode> { _episode }, notification)
|
|
|
|
.Should()
|
|
|
|
.HaveCount(0);
|
2013-01-13 08:24:48 +00:00
|
|
|
|
|
|
|
ExceptionVerification.ExpectedErrors(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void should_use_scene_numbering_when_available()
|
|
|
|
{
|
|
|
|
_series.UseSceneNumbering = true;
|
|
|
|
_episode.SceneEpisodeNumber = 5;
|
|
|
|
_episode.SceneSeasonNumber = 10;
|
|
|
|
|
|
|
|
WithValidIndexers();
|
|
|
|
|
2013-03-07 03:45:36 +00:00
|
|
|
Subject
|
|
|
|
.PerformSearch(_series, new List<Episode> { _episode }, notification)
|
|
|
|
.Should()
|
|
|
|
.HaveCount(20);
|
2013-01-13 08:24:48 +00:00
|
|
|
|
|
|
|
_indexer1.Verify(v => v.FetchEpisode(_series.Title, 10, 5), Times.Once());
|
|
|
|
_indexer2.Verify(v => v.FetchEpisode(_series.Title, 10, 5), Times.Once());
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void should_use_standard_numbering_when_scene_series_set_but_info_is_not_available()
|
|
|
|
{
|
|
|
|
_series.UseSceneNumbering = true;
|
|
|
|
_episode.SceneEpisodeNumber = 0;
|
|
|
|
_episode.SceneSeasonNumber = 0;
|
|
|
|
|
|
|
|
WithValidIndexers();
|
|
|
|
|
2013-03-07 03:45:36 +00:00
|
|
|
Subject
|
|
|
|
.PerformSearch(_series, new List<Episode> { _episode }, notification)
|
|
|
|
.Should()
|
|
|
|
.HaveCount(20);
|
2013-01-13 08:24:48 +00:00
|
|
|
|
|
|
|
_indexer1.Verify(v => v.FetchEpisode(_series.Title, _episode.SeasonNumber, _episode.EpisodeNumber), Times.Once());
|
|
|
|
_indexer2.Verify(v => v.FetchEpisode(_series.Title, _episode.SeasonNumber, _episode.EpisodeNumber), Times.Once());
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void should_use_standard_numbering_when_not_scene_series()
|
|
|
|
{
|
|
|
|
_series.UseSceneNumbering = false;
|
|
|
|
|
|
|
|
WithValidIndexers();
|
|
|
|
|
2013-03-07 03:45:36 +00:00
|
|
|
Subject
|
|
|
|
.PerformSearch(_series, new List<Episode> { _episode }, notification)
|
|
|
|
.Should()
|
|
|
|
.HaveCount(20);
|
2013-01-13 08:24:48 +00:00
|
|
|
|
|
|
|
_indexer1.Verify(v => v.FetchEpisode(_series.Title, _episode.SeasonNumber, _episode.EpisodeNumber), Times.Once());
|
|
|
|
_indexer2.Verify(v => v.FetchEpisode(_series.Title, _episode.SeasonNumber, _episode.EpisodeNumber), Times.Once());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|