2011-05-22 19:53:21 +03:00
// ReSharper disable RedundantUsingDirective
using System ;
2011-06-03 00:06:46 +03:00
using FluentAssertions ;
using NUnit.Framework ;
2011-06-23 03:19:19 +03:00
using NzbDrone.Core.Model ;
2010-10-24 10:46:58 +03:00
using NzbDrone.Core.Repository.Quality ;
2011-05-19 06:55:35 +03:00
using NzbDrone.Core.Test.Framework ;
2010-10-24 10:46:58 +03:00
namespace NzbDrone.Core.Test
{
[TestFixture]
// ReSharper disable InconsistentNaming
2011-05-19 06:55:35 +03:00
public class ParserTest : TestBase
2010-10-24 10:46:58 +03:00
{
2011-04-05 09:33:24 +03:00
/ * Fucked - up hall of shame ,
* WWE . Wrestlemania . 27. PPV . HDTV . XviD - KYR
* The . Kennedys . Part . 2.D SR . XviD - SYS
2011-04-23 01:23:29 +03:00
* Unreported . World . Chinas . Lost . Sons . WS . PDTV . XviD - FTP
2011-04-05 09:33:24 +03:00
* /
2011-06-03 00:06:46 +03:00
[TestCase("Sonny.With.a.Chance.S02E15", "Sonny.With.a.Chance", 2, 15)]
[TestCase("Two.and.a.Half.Me.103.720p.HDTV.X264-DIMENSION", "Two.and.a.Half.Me", 1, 3)]
[TestCase("Two.and.a.Half.Me.113.720p.HDTV.X264-DIMENSION", "Two.and.a.Half.Me", 1, 13)]
[TestCase("Two.and.a.Half.Me.1013.720p.HDTV.X264-DIMENSION", "Two.and.a.Half.Me", 10, 13)]
[TestCase("Chuck.4x05.HDTV.XviD-LOL", "Chuck", 4, 5)]
[TestCase("The.Girls.Next.Door.S03E06.DVDRip.XviD-WiDE", "The.Girls.Next.Door", 3, 6)]
[TestCase("Degrassi.S10E27.WS.DSR.XviD-2HD", "Degrassi", 10, 27)]
[TestCase("Parenthood.2010.S02E14.HDTV.XviD-LOL", "Parenthood 2010", 2, 14)]
[TestCase("Hawaii Five 0 S01E19 720p WEB DL DD5 1 H 264 NT", "Hawaii Five", 1, 19)]
[TestCase("The Event S01E14 A Message Back 720p WEB DL DD5 1 H264 SURFER", "The Event", 1, 14)]
[TestCase("Adam Hills In Gordon St Tonight S01E07 WS PDTV XviD FUtV", "Adam Hills In Gordon St Tonight", 1, 7)]
[TestCase("Adam Hills In Gordon St Tonight S01E07 WS PDTV XviD FUtV", "Adam Hills In Gordon St Tonight", 1, 7)]
[TestCase("Adventure.Inc.S03E19.DVDRip.XviD-OSiTV", "Adventure.Inc", 3, 19)]
[TestCase("S03E09 WS PDTV XviD FUtV", "", 3, 9)]
[TestCase("5x10 WS PDTV XviD FUtV", "", 5, 10)]
[TestCase("Castle.2009.S01E14.HDTV.XviD-LOL", "Castle 2009", 1, 14)]
[TestCase("Pride.and.Prejudice.1995.S03E20.HDTV.XviD-LOL", "Pride and Prejudice 1995", 3, 20)]
[TestCase("The.Office.S03E115.DVDRip.XviD-OSiTV", "The.Office", 3, 115)]
[TestCase(@"Parks and Recreation - S02E21 - 94 Meetings - 720p TV.mkv", "Parks and Recreation", 2, 21)]
[TestCase(@"24-7 Penguins-Capitals- Road to the NHL Winter Classic - S01E03 - Episode 3.mkv", "24-7 Penguins-Capitals- Road to the NHL Winter Classic", 1, 3)]
2011-06-18 06:11:04 +03:00
[TestCase("Adventure.Inc.S03E19.DVDRip.\"XviD\"-OSiTV", "Adventure.Inc", 3, 19)]
2011-06-25 04:20:52 +03:00
[TestCase("Hawaii Five-0 (2010) - 1x05 - Nalowale (Forgotten/Missing)", "Hawaii Five-0 (2010)", 1, 5)]
[TestCase("Hawaii Five-0 (2010) - 1x05 - Title", "Hawaii Five-0 (2010)", 1, 5)]
2011-08-02 08:10:05 +03:00
[TestCase("House - S06E13 - 5 to 9 [DVD] ", " House ", 6, 13)]
2011-08-06 07:51:36 +03:00
[TestCase("The Mentalist - S02E21 - 18-5-4", "The Mentalist", 2, 21)]
2011-06-30 02:31:16 +03:00
public void ParseTitle_single ( string postTitle , string title , int seasonNumber , int episodeNumber )
2011-04-23 01:23:29 +03:00
{
2011-06-30 02:31:16 +03:00
var result = Parser . ParseTitle ( postTitle ) ;
result . SeasonNumber . Should ( ) . Be ( seasonNumber ) ;
result . EpisodeNumbers [ 0 ] . Should ( ) . Be ( episodeNumber ) ;
result . CleanTitle . Should ( ) . Be ( Parser . NormalizeTitle ( title ) ) ;
result . EpisodeNumbers . Count . Should ( ) . Be ( 1 ) ;
2011-04-23 01:23:29 +03:00
}
[Test]
2011-06-03 00:06:46 +03:00
[TestCase(@"z:\tv shows\battlestar galactica (2003)\Season 3\S03E05 - Collaborators.mkv", 3, 5)]
[TestCase(@"z:\tv shows\modern marvels\Season 16\S16E03 - The Potato.mkv", 16, 3)]
[TestCase(@"z:\tv shows\robot chicken\Specials\S00E16 - Dear Consumer - SD TV.avi", 0, 16)]
[TestCase(@"D:\shares\TV Shows\Parks And Recreation\Season 2\S02E21 - 94 Meetings - 720p TV.mkv", 2, 21)]
[TestCase(@"D:\shares\TV Shows\Battlestar Galactica (2003)\Season 2\S02E21.avi", 2, 21)]
2011-07-06 10:36:49 +03:00
[TestCase("C:/Test/TV/Chuck.4x05.HDTV.XviD-LOL", 4, 5)]
2011-06-30 02:31:16 +03:00
public void PathParse_tests ( string path , int season , int episode )
2010-10-24 10:46:58 +03:00
{
2011-06-30 02:31:16 +03:00
var result = Parser . ParsePath ( path ) ;
2011-06-03 00:06:46 +03:00
result . EpisodeNumbers . Should ( ) . HaveCount ( 1 ) ;
2011-06-30 02:31:16 +03:00
result . SeasonNumber . Should ( ) . Be ( season ) ;
result . EpisodeNumbers [ 0 ] . Should ( ) . Be ( episode ) ;
2010-10-24 10:46:58 +03:00
}
2011-06-03 00:06:46 +03:00
[TestCase("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD", QualityTypes.DVD)]
[TestCase("WEEDS.S03E01-06.DUAL.BDRip.X-viD.AC3.-HELLYWOOD", QualityTypes.DVD)]
[TestCase("WEEDS.S03E01-06.DUAL.BDRip.AC3.-HELLYWOOD", QualityTypes.DVD)]
[TestCase("Two.and.a.Half.Men.S08E05.720p.HDTV.X264-DIMENSION", QualityTypes.HDTV)]
[TestCase("this has no extention or periods HDTV", QualityTypes.SDTV)]
[TestCase("Chuck.S04E05.HDTV.XviD-LOL", QualityTypes.SDTV)]
[TestCase("The.Girls.Next.Door.S03E06.DVDRip.XviD-WiDE", QualityTypes.DVD)]
[TestCase("The.Girls.Next.Door.S03E06.DVD.Rip.XviD-WiDE", QualityTypes.DVD)]
[TestCase("The.Girls.Next.Door.S03E06.HDTV-WiDE", QualityTypes.SDTV)]
[TestCase("Degrassi.S10E27.WS.DSR.XviD-2HD", QualityTypes.SDTV)]
[TestCase("Sonny.With.a.Chance.S02E15.720p.WEB-DL.DD5.1.H.264-SURFER", QualityTypes.WEBDL)]
[TestCase("Sonny.With.a.Chance.S02E15.720p", QualityTypes.HDTV)]
[TestCase("Sonny.With.a.Chance.S02E15.mkv", QualityTypes.HDTV)]
[TestCase("Sonny.With.a.Chance.S02E15.avi", QualityTypes.SDTV)]
[TestCase("Sonny.With.a.Chance.S02E15.xvid", QualityTypes.SDTV)]
[TestCase("Sonny.With.a.Chance.S02E15.divx", QualityTypes.SDTV)]
[TestCase("Sonny.With.a.Chance.S02E15", QualityTypes.Unknown)]
[TestCase("Chuck - S01E04 - So Old - Playdate - 720p TV.mkv", QualityTypes.HDTV)]
[TestCase("Chuck - S22E03 - MoneyBART - HD TV.mkv", QualityTypes.HDTV)]
[TestCase("Chuck - S01E03 - Come Fly With Me - 720p BluRay.mkv", QualityTypes.Bluray720p)]
[TestCase("Chuck - S01E03 - Come Fly With Me - 1080p BluRay.mkv", QualityTypes.Bluray1080p)]
[TestCase("Chuck - S11E06 - D-Yikes! - 720p WEB-DL.mkv", QualityTypes.WEBDL)]
[TestCase("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD.avi", QualityTypes.DVD)]
[TestCase("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD.avi", QualityTypes.DVD)]
[TestCase("Law & Order: Special Victims Unit - 11x11 - Quickie", QualityTypes.Unknown)]
[TestCase("(<a href=\"http://www.newzbin.com/browse/post/6076286/nzb/\">NZB</a>)", QualityTypes.Unknown)]
[TestCase("S07E23 - [HDTV] . mkv ", QualityTypes.HDTV)]
[TestCase("S07E23 - [WEBDL] . mkv ", QualityTypes.WEBDL)]
[TestCase("S07E23.mkv ", QualityTypes.HDTV)]
[TestCase("S07E23 .avi ", QualityTypes.SDTV)]
2011-06-23 03:19:19 +03:00
[TestCase("WEEDS.S03E01-06.DUAL.XviD.Bluray.AC3.-HELLYWOOD.avi", QualityTypes.DVD)]
[TestCase("WEEDS.S03E01-06.DUAL.Bluray.AC3.-HELLYWOOD.avi", QualityTypes.Bluray720p)]
2011-04-23 01:23:29 +03:00
public void quality_parse ( string postTitle , object quality )
2010-10-24 10:46:58 +03:00
{
2011-05-23 09:48:52 +03:00
var result = Parser . ParseQuality ( postTitle ) ;
2011-06-30 02:31:16 +03:00
result . QualityType . Should ( ) . Be ( quality ) ;
2010-10-24 10:46:58 +03:00
}
2011-05-26 06:13:39 +03:00
[Test]
public void parsing_our_own_quality_enum ( )
{
var qualityEnums = Enum . GetValues ( typeof ( QualityTypes ) ) ;
2011-05-28 22:23:35 +03:00
2011-05-26 06:13:39 +03:00
foreach ( var qualityEnum in qualityEnums )
{
if ( qualityEnum . ToString ( ) = = QualityTypes . Unknown . ToString ( ) ) continue ;
var extention = "mkv" ;
2011-05-28 22:23:35 +03:00
if ( qualityEnum . ToString ( ) = = QualityTypes . SDTV . ToString ( ) | | qualityEnum . ToString ( ) = = QualityTypes . DVD . ToString ( ) )
2011-05-26 06:13:39 +03:00
{
extention = "avi" ;
}
2011-05-28 22:23:35 +03:00
var fileName = String . Format ( "My series S01E01 [{0}].{1}" , qualityEnum , extention ) ;
2011-05-26 06:13:39 +03:00
var result = Parser . ParseQuality ( fileName ) ;
2011-06-30 02:31:16 +03:00
result . QualityType . Should ( ) . Be ( qualityEnum ) ;
2011-05-26 06:13:39 +03:00
}
}
2011-07-06 10:36:49 +03:00
2011-06-03 00:06:46 +03:00
[Timeout(1000)]
[TestCase("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD", "WEEDS", 3, new[] { 1 , 2 , 3 , 4 , 5 , 6 } , 6 ) ]
[TestCase("Two.and.a.Half.Men.103.104.720p.HDTV.X264-DIMENSION", "Two.and.a.Half.Men", 1, new[] { 3 , 4 } , 2 ) ]
[TestCase("Weeds.S03E01.S03E02.720p.HDTV.X264-DIMENSION", "Weeds", 3, new[] { 1 , 2 } , 2 ) ]
[TestCase("The Borgias S01e01 e02 ShoHD On Demand 1080i DD5 1 ALANiS", "The Borgias", 1, new[] { 1 , 2 } , 2 ) ]
2011-08-06 07:51:36 +03:00
[TestCase("Big Time Rush 1x01 to 10 480i DD2 0 Sianto", "Big Time Rush", 1, new[] { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 } , 10 ) ]
2011-06-03 00:06:46 +03:00
[TestCase("White.Collar.2x04.2x05.720p.BluRay-FUTV", "White.Collar", 2, new[] { 4 , 5 } , 2 ) ]
2011-06-13 07:20:29 +03:00
[TestCase("Desperate.Housewives.S07E22E23.720p.HDTV.X264-DIMENSION", "Desperate.Housewives", 7, new[] { 22 , 23 } , 2 ) ]
2011-06-13 21:25:40 +03:00
[TestCase("S07E22 - 7x23 - And Lots of Security.. [HDTV] . mkv ", " ", 7, new[] { 22, 23 }, 2)]
[TestCase("Desparate Housewives - S07E22 - 7x23 - And Lots of Security.. [HDTV] . mkv ", " Desparate Housewives ", 7, new[] { 22, 23 }, 2)]
[TestCase("Desparate Housewives - S07E22 - S07E23 - And Lots of Security.. [HDTV] . mkv ", " Desparate Housewives ", 7, new[] { 22, 23 }, 2)]
[TestCase("S03E01.S03E02.720p.HDTV.X264-DIMENSION", "", 3, new[] { 1 , 2 } , 2 ) ]
2011-06-30 02:31:16 +03:00
public void TitleParse_multi ( string postTitle , string title , int season , int [ ] episodes , int count )
2011-04-05 09:33:24 +03:00
{
2011-06-30 02:31:16 +03:00
var result = Parser . ParseTitle ( postTitle ) ;
result . SeasonNumber . Should ( ) . Be ( season ) ;
2011-06-03 00:06:46 +03:00
result . EpisodeNumbers . Should ( ) . HaveSameCount ( episodes ) ;
result . EpisodeNumbers . Should ( ) . BeEquivalentTo ( result . EpisodeNumbers ) ;
2011-06-30 02:31:16 +03:00
result . CleanTitle . Should ( ) . Be ( Parser . NormalizeTitle ( title ) ) ;
result . EpisodeNumbers . Count . Should ( ) . Be ( count ) ;
2011-04-05 09:33:24 +03:00
}
2011-07-06 10:36:49 +03:00
2011-06-03 00:06:46 +03:00
[TestCase("Conan 2011 04 18 Emma Roberts HDTV XviD BFF", "Conan", 2011, 04, 18)]
[TestCase("The Tonight Show With Jay Leno 2011 04 15 1080i HDTV DD5 1 MPEG2 TrollHD", "The Tonight Show With Jay Leno", 2011, 04, 15)]
[TestCase("The.Daily.Show.2010.10.11.Johnny.Knoxville.iTouch-MW", "The.Daily.Show", 2010, 10, 11)]
[TestCase("The Daily Show - 2011-04-12 - Gov. Deval Patrick", "The.Daily.Show", 2011, 04, 12)]
[TestCase("2011.01.10 - Denis Leary - HD TV.mkv", "", 2011, 1, 10)]
[TestCase("2011.03.13 - Denis Leary - HD TV.mkv", "", 2011, 3, 13)]
2011-06-18 09:22:54 +03:00
[TestCase("The Tonight Show with Jay Leno - 2011-06-16 - Larry David, \"Bachelorette\" Ashley Hebert, Pitbull with Ne-Yo", "The Tonight Show with Jay Leno", 2011, 6, 16)]
2011-04-23 01:23:29 +03:00
public void episode_daily_parse ( string postTitle , string title , int year , int month , int day )
2011-04-20 05:59:28 +03:00
{
2011-06-30 02:31:16 +03:00
var result = Parser . ParseTitle ( postTitle ) ;
2011-04-20 05:59:28 +03:00
var airDate = new DateTime ( year , month , day ) ;
2011-06-30 02:31:16 +03:00
result . CleanTitle . Should ( ) . Be ( Parser . NormalizeTitle ( title ) ) ;
result . AirDate . Should ( ) . Be ( airDate ) ;
2011-05-24 07:12:54 +03:00
Assert . IsNull ( result . EpisodeNumbers ) ;
2011-04-20 05:59:28 +03:00
}
2011-04-05 09:33:24 +03:00
2011-07-06 10:36:49 +03:00
2011-06-03 00:06:46 +03:00
[TestCase("30.Rock.Season.04.HDTV.XviD-DIMENSION", "30.Rock", 4)]
[TestCase("Parks.and.Recreation.S02.720p.x264-DIMENSION", "Parks.and.Recreation", 2)]
[TestCase("The.Office.US.S03.720p.x264-DIMENSION", "The.Office.US", 3)]
2011-04-26 18:26:41 +03:00
public void full_season_release_parse ( string postTitle , string title , int season )
{
2011-06-30 02:31:16 +03:00
var result = Parser . ParseTitle ( postTitle ) ;
result . SeasonNumber . Should ( ) . Be ( season ) ;
result . CleanTitle . Should ( ) . Be ( Parser . NormalizeTitle ( title ) ) ;
result . EpisodeNumbers . Count . Should ( ) . Be ( 0 ) ;
2011-04-26 18:26:41 +03:00
}
2011-07-06 10:36:49 +03:00
2011-06-03 00:06:46 +03:00
[TestCase("Conan", "conan")]
[TestCase("The Tonight Show With Jay Leno", "tonightshowwithjayleno")]
[TestCase("The.Daily.Show", "dailyshow")]
[TestCase("Castle (2009)", "castle2009")]
[TestCase("Parenthood.2010", "parenthood2010")]
2011-04-23 11:04:30 +03:00
public void series_name_normalize ( string parsedSeriesName , string seriesName )
{
var result = Parser . NormalizeTitle ( parsedSeriesName ) ;
2011-06-30 02:31:16 +03:00
result . Should ( ) . Be ( seriesName ) ;
2011-04-23 11:04:30 +03:00
}
2011-06-03 00:06:46 +03:00
[TestCase(@"c:\test\", @"c:\test")]
[TestCase(@"c:\\test\\", @"c:\test")]
[TestCase(@"C:\\Test\\", @"C:\Test")]
[TestCase(@"C:\\Test\\Test\", @"C:\Test\Test")]
[TestCase(@"\\Testserver\Test\", @"\\Testserver\Test")]
2010-10-24 10:46:58 +03:00
public void Normalize_Path ( string dirty , string clean )
{
var result = Parser . NormalizePath ( dirty ) ;
2011-06-30 02:31:16 +03:00
result . Should ( ) . Be ( clean ) ;
2010-10-24 10:46:58 +03:00
}
2011-07-06 10:36:49 +03:00
2011-06-03 00:06:46 +03:00
[TestCase("CaPitAl", "capital")]
[TestCase("peri.od", "period")]
[TestCase("this.^&%^**$%@#$!That", "thisthat")]
2011-06-25 04:20:52 +03:00
[TestCase("test/test", "testtest")]
2011-08-02 08:10:05 +03:00
[TestCase("90210", "90210")]
[TestCase("24", "24")]
2011-04-23 01:23:29 +03:00
public void Normalize_Title ( string dirty , string clean )
{
var result = Parser . NormalizeTitle ( dirty ) ;
2011-06-30 02:31:16 +03:00
result . Should ( ) . Be ( clean ) ;
2011-04-23 01:23:29 +03:00
}
2011-07-06 10:36:49 +03:00
2011-06-03 00:06:46 +03:00
[TestCase("the")]
[TestCase("and")]
[TestCase("or")]
[TestCase("a")]
[TestCase("an")]
[TestCase("of")]
2011-04-23 01:23:29 +03:00
public void Normalize_removed_common_words ( string word )
{
var dirtyFormat = new [ ]
{
"word.{0}.word" ,
"word {0} word" ,
"word-{0}-word" ,
"{0}.word.word" ,
"{0}-word-word" ,
"{0} word word" ,
"word.word.{0}" ,
"word-word-{0}" ,
"word-word {0}" ,
} ;
foreach ( var s in dirtyFormat )
{
var dirty = String . Format ( s , word ) ;
2011-06-30 02:31:16 +03:00
Parser . NormalizeTitle ( dirty ) . Should ( ) . Be ( "wordword" ) ;
2011-04-23 01:23:29 +03:00
}
}
2011-06-03 00:06:46 +03:00
[TestCase("the")]
[TestCase("and")]
[TestCase("or")]
[TestCase("a")]
[TestCase("an")]
[TestCase("of")]
2011-04-23 01:23:29 +03:00
public void Normalize_not_removed_common_words_in_the_middle ( string word )
{
var dirtyFormat = new [ ]
{
"word.{0}word" ,
"word {0}word" ,
"word-{0}word" ,
"word{0}.word" ,
"word{0}-word" ,
"word{0}-word" ,
} ;
foreach ( var s in dirtyFormat )
{
var dirty = String . Format ( s , word ) ;
2011-06-30 02:31:16 +03:00
Parser . NormalizeTitle ( dirty ) . Should ( ) . Be ( ( "word" + word . ToLower ( ) + "word" ) ) ;
2011-04-23 01:23:29 +03:00
}
}
2011-06-23 03:19:19 +03:00
[TestCase("Chuck - 4x05 - Title", "Chuck")]
[TestCase("Law & Order - 4x05 - Title", "laworder")]
2011-06-23 04:17:42 +03:00
[TestCase("This Isn't a Valid Post", "")]
2011-06-23 03:19:19 +03:00
public void parse_series_name ( string postTitle , string title )
{
var result = Parser . ParseSeriesName ( postTitle ) ;
2011-06-30 02:31:16 +03:00
result . Should ( ) . Be ( Parser . NormalizeTitle ( title ) ) ;
2011-06-23 03:19:19 +03:00
}
[TestCase("Castle.2009.S01E14.English.HDTV.XviD-LOL", LanguageType.English)]
[TestCase("Castle.2009.S01E14.French.HDTV.XviD-LOL", LanguageType.French)]
[TestCase("Castle.2009.S01E14.Spanish.HDTV.XviD-LOL", LanguageType.Spanish)]
[TestCase("Castle.2009.S01E14.German.HDTV.XviD-LOL", LanguageType.German)]
[TestCase("Castle.2009.S01E14.Germany.HDTV.XviD-LOL", LanguageType.English)]
2011-06-23 04:17:42 +03:00
[TestCase("Castle.2009.S01E14.Italian.HDTV.XviD-LOL", LanguageType.Italian)]
2011-06-23 03:19:19 +03:00
[TestCase("Castle.2009.S01E14.Danish.HDTV.XviD-LOL", LanguageType.Danish)]
[TestCase("Castle.2009.S01E14.Dutch.HDTV.XviD-LOL", LanguageType.Dutch)]
[TestCase("Castle.2009.S01E14.Japanese.HDTV.XviD-LOL", LanguageType.Japanese)]
[TestCase("Castle.2009.S01E14.Cantonese.HDTV.XviD-LOL", LanguageType.Cantonese)]
[TestCase("Castle.2009.S01E14.Mandarin.HDTV.XviD-LOL", LanguageType.Mandarin)]
[TestCase("Castle.2009.S01E14.Korean.HDTV.XviD-LOL", LanguageType.Korean)]
[TestCase("Castle.2009.S01E14.Russian.HDTV.XviD-LOL", LanguageType.Russian)]
[TestCase("Castle.2009.S01E14.Polish.HDTV.XviD-LOL", LanguageType.Polish)]
[TestCase("Castle.2009.S01E14.Vietnamese.HDTV.XviD-LOL", LanguageType.Vietnamese)]
[TestCase("Castle.2009.S01E14.Swedish.HDTV.XviD-LOL", LanguageType.Swedish)]
[TestCase("Castle.2009.S01E14.Norwegian.HDTV.XviD-LOL", LanguageType.Norwegian)]
[TestCase("Castle.2009.S01E14.Finnish.HDTV.XviD-LOL", LanguageType.Finnish)]
[TestCase("Castle.2009.S01E14.Turkish.HDTV.XviD-LOL", LanguageType.Turkish)]
[TestCase("Castle.2009.S01E14.Portuguese.HDTV.XviD-LOL", LanguageType.Portuguese)]
2011-06-23 04:17:42 +03:00
[TestCase("Castle.2009.S01E14.HDTV.XviD-LOL", LanguageType.English)]
2011-06-23 03:19:19 +03:00
public void parse_language ( string postTitle , LanguageType language )
{
var result = Parser . ParseLanguage ( postTitle ) ;
2011-06-30 02:31:16 +03:00
result . Should ( ) . Be ( language ) ;
2011-06-23 03:19:19 +03:00
}
[Test]
[ExpectedException(typeof(ArgumentException), ExpectedMessage = "Path can not be null or empty")]
public void normalize_path_exception_empty ( )
{
Parser . NormalizePath ( "" ) ;
}
[Test]
[ExpectedException(typeof(ArgumentException), ExpectedMessage = "Path can not be null or empty")]
public void normalize_path_exception_null ( )
{
Parser . NormalizePath ( null ) ;
}
[TestCase("Hawaii Five 0 S01E19 720p WEB DL DD5 1 H 264 NT", "Hawaii Five", 1)]
[TestCase("Chuck.4x05.HDTV.XviD-LOL", "Chuck", 4)]
[TestCase("S03E09 WS PDTV XviD FUtV", "", 3)]
[TestCase("5x10 WS PDTV XviD FUtV", "", 5)]
public void parse_season_info ( string postTitle , string seriesName , int seasonNumber )
{
var result = Parser . ParseSeasonInfo ( postTitle ) ;
2011-06-30 02:31:16 +03:00
result . SeriesTitle . Should ( ) . Be ( Parser . NormalizeTitle ( seriesName ) ) ;
result . SeasonNumber . Should ( ) . Be ( seasonNumber ) ;
2011-06-23 03:19:19 +03:00
}
2011-06-23 04:17:42 +03:00
[Test]
public void parse_season_info_null ( )
{
var result = Parser . ParseSeasonInfo ( "This is not a valid post" ) ;
2011-06-30 02:31:16 +03:00
result . Should ( ) . BeNull ( ) ;
2011-06-23 04:17:42 +03:00
}
2010-10-24 10:46:58 +03:00
}
2011-04-05 05:48:46 +03:00
}