Update parser tests.

Leonardo Galli 8 years ago
parent a16e46cf38
commit 50ac95dec5

@ -7,6 +7,7 @@ namespace NzbDrone.Core.Test.ParserTests
{
[TestFixture]
[Ignore("Series")]
public class AbsoluteEpisodeNumberParserFixture : CoreTest
{
[TestCase("[SubDESU]_High_School_DxD_07_(1280x720_x264-AAC)_[6B7FD717]", "High School DxD", 7, 0, 0)]

@ -9,6 +9,7 @@ namespace NzbDrone.Core.Test.ParserTests
{
[TestFixture]
[Ignore("Series")]
public class DailyEpisodeParserFixture : CoreTest
{
[TestCase("Conan 2011 04 18 Emma Roberts HDTV XviD BFF", "Conan", 2011, 04, 18)]

@ -7,6 +7,7 @@ namespace NzbDrone.Core.Test.ParserTests
{
[TestFixture]
[Ignore("Series")]
public class MiniSeriesEpisodeParserFixture : CoreTest
{
[TestCase("The.Kennedys.Part.2.DSR.XviD-SYS", "The Kennedys", 2)]

@ -6,6 +6,7 @@ namespace NzbDrone.Core.Test.ParserTests
{
[TestFixture]
[Ignore("Series")]
public class MultiEpisodeParserFixture : CoreTest
{
[TestCase("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD", "WEEDS", 3, new[] { 1, 2, 3, 4, 5, 6 })]

@ -14,6 +14,7 @@ using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.ParserTests.ParsingServiceTests
{
[TestFixture]
[Ignore("Series")]
public class GetEpisodesFixture : TestBase<ParsingService>
{
private Series _series;

@ -18,6 +18,12 @@ namespace NzbDrone.Core.Test.ParserTests.ParsingServiceTests
public class MapFixture : TestBase<ParsingService>
{
private Series _series;
private Movie _movie;
private ParsedMovieInfo _parsedMovieInfo;
private ParsedMovieInfo _wrongYearInfo;
private ParsedMovieInfo _romanTitleInfo;
private ParsedMovieInfo _alternativeTitleInfo;
private MovieSearchCriteria _movieSearchCriteria;
private List<Episode> _episodes;
private ParsedEpisodeInfo _parsedEpisodeInfo;
private SingleEpisodeSearchCriteria _singleEpisodeSearchCriteria;
@ -30,6 +36,13 @@ namespace NzbDrone.Core.Test.ParserTests.ParsingServiceTests
.With(s => s.CleanTitle = "rock")
.Build();
_movie = Builder<Movie>.CreateNew()
.With(m => m.Title = "Mission Impossible 3")
.With(m => m.CleanTitle = "missionimpossible3")
.With(m => m.Year = 2006)
.With(m => m.AlternativeTitles = new List<string> { "Mission Impossible 3: Same same" })
.Build();
_episodes = Builder<Episode>.CreateListOfSize(1)
.All()
.With(e => e.AirDate = DateTime.Today.ToString(Episode.AIR_DATE_FORMAT))
@ -43,6 +56,31 @@ namespace NzbDrone.Core.Test.ParserTests.ParsingServiceTests
EpisodeNumbers = new[] { 1 }
};
_parsedMovieInfo = new ParsedMovieInfo
{
MovieTitle = _movie.Title,
Year = _movie.Year,
};
_wrongYearInfo = new ParsedMovieInfo
{
MovieTitle = _movie.Title,
Year = 1900,
};
_alternativeTitleInfo = new ParsedMovieInfo
{
MovieTitle = _movie.AlternativeTitles.First(),
Year = _movie.Year,
};
_romanTitleInfo = new ParsedMovieInfo
{
MovieTitle = "Mission Impossible III",
Year = _movie.Year,
};
_singleEpisodeSearchCriteria = new SingleEpisodeSearchCriteria
{
Series = _series,
@ -50,27 +88,18 @@ namespace NzbDrone.Core.Test.ParserTests.ParsingServiceTests
SeasonNumber = _episodes.First().SeasonNumber,
Episodes = _episodes
};
}
private void GivenMatchBySeriesTitle()
{
Mocker.GetMock<ISeriesService>()
.Setup(s => s.FindByTitle(It.IsAny<string>()))
.Returns(_series);
}
private void GivenMatchByTvdbId()
{
Mocker.GetMock<ISeriesService>()
.Setup(s => s.FindByTvdbId(It.IsAny<Int32>()))
.Returns(_series);
_movieSearchCriteria = new MovieSearchCriteria
{
Movie = _movie
};
}
private void GivenMatchByTvRageId()
private void GivenMatchByMovieTitle()
{
Mocker.GetMock<ISeriesService>()
.Setup(s => s.FindByTvRageId(It.IsAny<int>()))
.Returns(_series);
Mocker.GetMock<IMovieService>()
.Setup(s => s.FindByTitle(It.IsAny<string>()))
.Returns(_movie);
}
private void GivenParseResultSeriesDoesntMatchSearchCriteria()
@ -79,121 +108,45 @@ namespace NzbDrone.Core.Test.ParserTests.ParsingServiceTests
}
[Test]
public void should_lookup_series_by_name()
public void should_lookup_Movie_by_name()
{
GivenMatchBySeriesTitle();
GivenMatchByMovieTitle();
Subject.Map(_parsedEpisodeInfo, _series.TvdbId, _series.TvRageId);
Subject.Map(_parsedMovieInfo, "", null);
Mocker.GetMock<ISeriesService>()
Mocker.GetMock<IMovieService>()
.Verify(v => v.FindByTitle(It.IsAny<string>()), Times.Once());
}
[Test]
public void should_use_tvdbid_when_series_title_lookup_fails()
{
GivenMatchByTvdbId();
Subject.Map(_parsedEpisodeInfo, _series.TvdbId, _series.TvRageId);
Mocker.GetMock<ISeriesService>()
.Verify(v => v.FindByTvdbId(It.IsAny<Int32>()), Times.Once());
}
[Test]
public void should_use_tvrageid_when_series_title_lookup_fails()
{
GivenMatchByTvRageId();
Subject.Map(_parsedEpisodeInfo, 0, _series.TvRageId);
Mocker.GetMock<ISeriesService>()
.Verify(v => v.FindByTvRageId(It.IsAny<int>()), Times.Once());
}
[Test]
public void should_not_use_tvrageid_when_scene_naming_exception_exists()
{
GivenMatchByTvRageId();
Mocker.GetMock<ISceneMappingService>()
.Setup(v => v.FindTvdbId(It.IsAny<string>()))
.Returns(10);
var result = Subject.Map(_parsedEpisodeInfo, _series.TvdbId, _series.TvRageId);
Mocker.GetMock<ISeriesService>()
.Verify(v => v.FindByTvRageId(It.IsAny<int>()), Times.Never());
result.Series.Should().BeNull();
}
[Test]
public void should_use_search_criteria_series_title()
public void should_use_search_criteria_movie_title()
{
GivenMatchBySeriesTitle();
GivenMatchByMovieTitle();
Subject.Map(_parsedEpisodeInfo, _series.TvdbId, _series.TvRageId, _singleEpisodeSearchCriteria);
Subject.Map(_parsedMovieInfo, "", _movieSearchCriteria);
Mocker.GetMock<ISeriesService>()
.Verify(v => v.FindByTitle(It.IsAny<string>()), Times.Never());
}
[Test]
public void should_FindByTitle_when_search_criteria_matching_fails()
{
GivenParseResultSeriesDoesntMatchSearchCriteria();
Subject.Map(_parsedEpisodeInfo, 10, 10, _singleEpisodeSearchCriteria);
Mocker.GetMock<ISeriesService>()
.Verify(v => v.FindByTitle(It.IsAny<string>()), Times.Once());
}
[Test]
public void should_FindByTvdbId_when_search_criteria_and_FindByTitle_matching_fails()
{
GivenParseResultSeriesDoesntMatchSearchCriteria();
Subject.Map(_parsedEpisodeInfo, 10, 10, _singleEpisodeSearchCriteria);
Mocker.GetMock<ISeriesService>()
.Verify(v => v.FindByTvdbId(It.IsAny<Int32>()), Times.Once());
}
[Test]
public void should_FindByTvRageId_when_search_criteria_and_FindByTitle_matching_fails()
{
GivenParseResultSeriesDoesntMatchSearchCriteria();
Subject.Map(_parsedEpisodeInfo, 10, 10, _singleEpisodeSearchCriteria);
Mocker.GetMock<ISeriesService>()
.Verify(v => v.FindByTvRageId(It.IsAny<int>()), Times.Once());
}
[Test]
public void should_use_tvdbid_matching_when_alias_is_found()
{
Mocker.GetMock<ISceneMappingService>()
.Setup(s => s.FindTvdbId(It.IsAny<string>()))
.Returns(_series.TvdbId);
Subject.Map(_parsedEpisodeInfo, _series.TvdbId, _series.TvRageId, _singleEpisodeSearchCriteria);
Mocker.GetMock<ISeriesService>()
.Verify(v => v.FindByTitle(It.IsAny<string>()), Times.Never());
public void should_not_match_with_wrong_year()
{
GivenMatchByMovieTitle();
Subject.Map(_wrongYearInfo, "", _movieSearchCriteria).Movie.Should().BeNull();
}
[Test]
public void should_use_tvrageid_match_from_search_criteria_when_title_match_fails()
{
GivenParseResultSeriesDoesntMatchSearchCriteria();
[Test]
public void should_match_alternative_title()
{
Subject.Map(_alternativeTitleInfo, "", _movieSearchCriteria).Movie.Should().Be(_movieSearchCriteria.Movie);
}
Subject.Map(_parsedEpisodeInfo, _series.TvdbId, _series.TvRageId, _singleEpisodeSearchCriteria);
[Test]
public void should_match_roman_title()
{
Subject.Map(_romanTitleInfo, "", _movieSearchCriteria).Movie.Should().Be(_movieSearchCriteria.Movie);
}
Mocker.GetMock<ISeriesService>()
.Verify(v => v.FindByTitle(It.IsAny<string>()), Times.Never());
}
}
}

@ -7,6 +7,7 @@ namespace NzbDrone.Core.Test.ParserTests
{
[TestFixture]
[Ignore("Series")]//Is this really necessary with movies? I dont think so
public class PathParserFixture : CoreTest
{
[TestCase(@"z:\tv shows\battlestar galactica (2003)\Season 3\S03E05 - Collaborators.mkv", 3, 5)]

@ -6,6 +6,7 @@ namespace NzbDrone.Core.Test.ParserTests
{
[TestFixture]
[Ignore("Series")]
public class SeasonParserFixture : CoreTest
{
[TestCase("30.Rock.Season.04.HDTV.XviD-DIMENSION", "30 Rock", 4)]

@ -5,6 +5,7 @@ using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.ParserTests
{
[TestFixture]
[Ignore("Series")]
public class SeriesTitleInfoFixture : CoreTest
{
[Test]

@ -7,6 +7,7 @@ namespace NzbDrone.Core.Test.ParserTests
{
[TestFixture]
[Ignore("Series")]
public class SingleEpisodeParserFixture : CoreTest
{
[TestCase("Sonny.With.a.Chance.S02E15", "Sonny With a Chance", 2, 15)]

Loading…
Cancel
Save