Radarr/NzbDrone.Core.Test/IndexerSearchTests/EpisodeSearchTests/IndexerEpisodeSearch_Episod...

117 lines
3.8 KiB
C#
Raw Normal View History

2013-03-07 03:45:36 +00:00
using System.Collections.Generic;
2013-01-13 08:24:48 +00:00
using FizzWare.NBuilder;
using FluentAssertions;
using NUnit.Framework;
2013-03-07 03:45:36 +00:00
using NzbDrone.Core.IndexerSearch;
2013-01-13 08:24:48 +00:00
using NzbDrone.Core.Model;
2013-03-07 03:45:36 +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 IndexerEpisodeSearch_EpisodeMatch : TestBase
2013-01-13 08:24:48 +00:00
{
private Series _series;
private Episode _episode;
private EpisodeParseResult _episodeParseResult;
[SetUp]
public void Setup()
{
_series = Builder<Series>
.CreateNew()
.Build();
_episode = Builder<Episode>
.CreateNew()
.With(e => e.SeriesId = _series.Id)
2013-01-13 08:24:48 +00:00
.With(e => e.Series = _series)
.Build();
_episodeParseResult = Builder<EpisodeParseResult>
.CreateNew()
.With(p => p.SeasonNumber = 1)
.With(p => p.EpisodeNumbers = new List<int>{ _episode.EpisodeNumber })
.With(p => p.Episodes = new List<Episode> { _episode })
.With(p => p.Series = _series)
.Build();
}
[Test]
public void should_return_WrongSeason_when_season_doesnt_match()
{
_episode.SeasonNumber = 10;
Mocker.Resolve<EpisodeSearch>()
2013-03-07 01:51:47 +00:00
.IsEpisodeMatch(_series, new {Episode = _episode}, _episodeParseResult)
2013-01-13 08:24:48 +00:00
.Should()
2013-03-07 01:51:47 +00:00
.BeFalse();
2013-01-13 08:24:48 +00:00
}
[Test]
public void should_return_WrongEpisode_when_episode_doesnt_match()
{
_episode.EpisodeNumber = 10;
Mocker.Resolve<EpisodeSearch>()
2013-03-07 01:51:47 +00:00
.IsEpisodeMatch(_series, new { Episode = _episode }, _episodeParseResult)
2013-01-13 08:24:48 +00:00
.Should()
2013-03-07 01:51:47 +00:00
.BeFalse();
2013-01-13 08:24:48 +00:00
}
[Test]
public void should_not_return_error_when_season_and_episode_match()
{
Mocker.Resolve<EpisodeSearch>()
2013-03-07 01:51:47 +00:00
.IsEpisodeMatch(_series, new { Episode = _episode }, _episodeParseResult)
2013-01-13 08:24:48 +00:00
.Should()
2013-03-07 03:45:36 +00:00
.BeTrue();
2013-01-13 08:24:48 +00:00
}
[Test]
public void should_return_WrongSeason_when_season_doesnt_match_for_scene_series()
{
_series.UseSceneNumbering = true;
_episode.SceneSeasonNumber = 10;
_episode.SeasonNumber = 10;
_episode.EpisodeNumber = 10;
Mocker.Resolve<EpisodeSearch>()
2013-03-07 01:51:47 +00:00
.IsEpisodeMatch(_series, new { Episode = _episode }, _episodeParseResult)
.Should()
.BeFalse();
2013-01-13 08:24:48 +00:00
}
[Test]
public void should_return_WrongEpisode_when_episode_doesnt_match_for_scene_series()
{
_series.UseSceneNumbering = true;
_episode.SceneEpisodeNumber = 10;
_episode.SeasonNumber = 10;
_episode.EpisodeNumber = 10;
Mocker.Resolve<EpisodeSearch>()
2013-03-07 01:51:47 +00:00
.IsEpisodeMatch(_series, new { Episode = _episode }, _episodeParseResult)
.Should()
.BeFalse();
2013-01-13 08:24:48 +00:00
}
[Test]
public void should_not_return_error_when_season_and_episode_match_for_scene_series()
{
_series.UseSceneNumbering = true;
_episode.SceneSeasonNumber = _episode.SeasonNumber;
_episode.SceneEpisodeNumber = _episode.EpisodeNumber;
_episode.SeasonNumber = 10;
_episode.EpisodeNumber = 10;
Mocker.Resolve<EpisodeSearch>()
2013-03-07 01:51:47 +00:00
.IsEpisodeMatch(_series, new { Episode = _episode }, _episodeParseResult)
2013-01-13 08:24:48 +00:00
.Should()
2013-03-07 01:51:47 +00:00
.BeTrue();
2013-01-13 08:24:48 +00:00
}
}
}