Parser refactoring. Now tries to parse full path if file name didn't work.

This commit is contained in:
kay.one 2011-11-23 23:35:37 -08:00
commit d0d9c44124
2 changed files with 100 additions and 91 deletions

View file

@ -1,10 +1,12 @@
// ReSharper disable RedundantUsingDirective
using System;
using System.Linq;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Model;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test
{
@ -52,10 +54,10 @@ namespace NzbDrone.Core.Test
public void ParseTitle_single(string postTitle, string title, int seasonNumber, int episodeNumber)
{
var result = Parser.ParseTitle(postTitle);
result.EpisodeNumbers.Should().HaveCount(1);
result.SeasonNumber.Should().Be(seasonNumber);
result.EpisodeNumbers[0].Should().Be(episodeNumber);
result.EpisodeNumbers.First().Should().Be(episodeNumber);
result.CleanTitle.Should().Be(Parser.NormalizeTitle(title));
result.EpisodeNumbers.Count.Should().Be(1);
}
[Test]
@ -68,12 +70,15 @@ namespace NzbDrone.Core.Test
[TestCase(@"P:\TV Shows\House\Season 6\S06E13 - 5 to 9 - 720p BluRay.mkv", 6, 13)]
[TestCase(@"S:\TV Drop\House - 10x11 - Title [SDTV]\1011 - Title.avi", 10, 11)]
[TestCase(@"S:\TV Drop\King of the Hill - 10x12 - 24 Hour Propane People [SDTV]\1012 - 24 Hour Propane People.avi", 10, 12)]
[TestCase(@"S:\TV Drop\King of the Hill - 10x12 - 24 Hour Propane People [SDTV]\Hour Propane People.avi", 10, 12)]
public void PathParse_tests(string path, int season, int episode)
{
var result = Parser.ParsePath(path);
result.EpisodeNumbers.Should().HaveCount(1);
result.SeasonNumber.Should().Be(season);
result.EpisodeNumbers[0].Should().Be(episode);
ExceptionVerification.IgnoreWarns();
}
[TestCase("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD", QualityTypes.DVD)]
@ -345,6 +350,7 @@ namespace NzbDrone.Core.Test
var result = Parser.ParseTitle(postTitle);
result.Should().BeNull();
ExceptionVerification.ExcpectedWarns(1);
}
[TestCase("Lie.to.Me.S03.SUBPACK.DVDRip.XviD-REWARD")]
@ -355,6 +361,8 @@ namespace NzbDrone.Core.Test
var result = Parser.ParseTitle(postTitle);
result.Should().BeNull();
ExceptionVerification.ExcpectedWarns(1);
}
}
}