From 73aecc0796c4d82e6022722eed0adda321a90efa Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Mon, 4 Apr 2011 23:33:24 -0700 Subject: [PATCH] added test for basic FeedProviderBase, fixed some issues with it. --- NzbDrone.Core.Test/Files/RSS/nzbsorg.xml | 366 ++++++++++++++++++ NzbDrone.Core.Test/NzbDrone.Core.Test.csproj | 5 + NzbDrone.Core.Test/ParserTest.cs | 22 ++ NzbDrone.Core.Test/RssProviderTest.cs | 69 ++++ NzbDrone.Core.Test/log.config | 8 + NzbDrone.Core/NzbDrone.Core.csproj | 3 - NzbDrone.Core/Parser.cs | 2 +- .../Providers/Feed/FeedProviderBase.cs | 41 +- 8 files changed, 494 insertions(+), 22 deletions(-) create mode 100644 NzbDrone.Core.Test/Files/RSS/nzbsorg.xml create mode 100644 NzbDrone.Core.Test/RssProviderTest.cs diff --git a/NzbDrone.Core.Test/Files/RSS/nzbsorg.xml b/NzbDrone.Core.Test/Files/RSS/nzbsorg.xml new file mode 100644 index 000000000..91046fb74 --- /dev/null +++ b/NzbDrone.Core.Test/Files/RSS/nzbsorg.xml @@ -0,0 +1,366 @@ + + + +TV - NZBs(dot)ORG RSS Feed +http://nzbs.org/index.php?&catid=&type=1 +TV feed for NZBs(dot)ORG +en-us + + Kings.S01E03.Prosperity.720p.HDTV.x264.PROPER-dH + Tue, 05 Apr 2011 07:16:52 +0000 + TV-x264 + http://nzbs.org/index.php?action=view&nzbid=605571 + Category: TV-x264
Size: 922.1 MB
Files: 21 (9 pars)
Group: a.b.multimedia
.NFO: None
Posted: Tue April 5th 05:08:26 UTC
Add to My NZBs
Download NZB
]]>
+ http://nzbs.org/index.php?action=view&nzbid=605571 + 605571 + TV-x264 + http://nzbs.org/index.php?action=getnzb&nzbid=605571&i=43516&h=bc8edb4cc49d4ae440775adec5ac001f + + 966876952 + Tue, 05 Apr 2011 05:08:26 +0000 +
+ + Relapse.S01E01.David.and.Brooke.HDTV.XviD-MOMENTUM + Tue, 05 Apr 2011 07:07:19 +0000 + TV-XviD + http://nzbs.org/index.php?action=view&nzbid=605569 + Category: TV-XviD
Size: 396.9 MB
Files: 36 (7 pars)
Group: a.b.teevee
.NFO: View NFO
Ext. Link: http://www.aetv.com/relapse/
Posted: Tue April 5th 05:05:21 UTC
Add to My NZBs
Download NZB
]]>
+ http://nzbs.org/index.php?action=view&nzbid=605569 + 605569 + TV-XviD + http://nzbs.org/index.php?action=getnzb&nzbid=605569&i=43516&h=bc8edb4cc49d4ae440775adec5ac001f + + 416155248 + Tue, 05 Apr 2011 05:05:21 +0000 + http://www.aetv.com/relapse/ +
+ + WWE.Monday.Night.Raw.2011.04.04.HDTV.XviD-W4F + Tue, 05 Apr 2011 07:07:15 +0000 + TV-XviD + http://nzbs.org/index.php?action=view&nzbid=605566 + Category: TV-XviD
Size: 1.27 GB
Files: 41 (13 pars)
Group: a.b.multimedia
.NFO: View NFO
Posted: Tue April 5th 05:00:31 UTC
Add to My NZBs
Download NZB
]]>
+ http://nzbs.org/index.php?action=view&nzbid=605566 + 605566 + TV-XviD + http://nzbs.org/index.php?action=getnzb&nzbid=605566&i=43516&h=bc8edb4cc49d4ae440775adec5ac001f + + 1363050400 + Tue, 05 Apr 2011 05:00:31 +0000 +
+ + Endgame.S01E04.HDTV.XviD-2HD + Tue, 05 Apr 2011 07:07:14 +0000 + TV-XviD + http://nzbs.org/index.php?action=view&nzbid=605565 + Category: TV-XviD
Size: 415.7 MB
Files: 34 (10 pars)
Group: a.b.teevee
.NFO: View NFO
Posted: Tue April 5th 04:59:21 UTC
Add to My NZBs
Download NZB
]]>
+ http://nzbs.org/index.php?action=view&nzbid=605565 + 605565 + TV-XviD + http://nzbs.org/index.php?action=getnzb&nzbid=605565&i=43516&h=bc8edb4cc49d4ae440775adec5ac001f + + 435883204 + Tue, 05 Apr 2011 04:59:21 +0000 +
+ + NCAA.Basketball.2011.Tournament.Championship.Butler.vs.UConn.HDTV.XviD-FQM + Tue, 05 Apr 2011 07:07:12 +0000 + TV-XviD + http://nzbs.org/index.php?action=view&nzbid=605564 + Category: TV-XviD
Size: 1.26 GB
Files: 76 (13 pars)
Group: a.b.multimedia
.NFO: View NFO
Ext. Link: http://www.ncaa.com/
Posted: Tue April 5th 04:57:22 UTC
Add to My NZBs
Download NZB
]]>
+ http://nzbs.org/index.php?action=view&nzbid=605564 + 605564 + TV-XviD + http://nzbs.org/index.php?action=getnzb&nzbid=605564&i=43516&h=bc8edb4cc49d4ae440775adec5ac001f + + 1349676970 + Tue, 05 Apr 2011 04:57:22 +0000 + http://www.ncaa.com/ +
+ + WWE.Hall.of.Fame.Induction.Ceremony.2011.720p.HDTV.x264-KYR + Tue, 05 Apr 2011 06:47:51 +0000 + TV-x264 + http://nzbs.org/index.php?action=view&nzbid=605553 + Category: TV-x264
Size: 1.27 GB
Files: 43 (14 pars)
Group: a.b.multimedia
.NFO: View NFO
Posted: Tue April 5th 04:45:59 UTC
Add to My NZBs
Download NZB
]]>
+ http://nzbs.org/index.php?action=view&nzbid=605553 + 605553 + TV-x264 + http://nzbs.org/index.php?action=getnzb&nzbid=605553&i=43516&h=bc8edb4cc49d4ae440775adec5ac001f + + 1365699871 + Tue, 05 Apr 2011 04:45:59 +0000 +
+ + Inside.the.Vault.S01E09.HDTV.XviD-MOMENTUM + Tue, 05 Apr 2011 06:47:49 +0000 + TV-XviD + http://nzbs.org/index.php?action=view&nzbid=605552 + Category: TV-XviD
Size: 197.7 MB
Files: 23 (6 pars)
Group: a.b.teevee
.NFO: View NFO
Posted: Tue April 5th 04:42:36 UTC
Add to My NZBs
Download NZB
]]>
+ http://nzbs.org/index.php?action=view&nzbid=605552 + 605552 + TV-XviD + http://nzbs.org/index.php?action=getnzb&nzbid=605552&i=43516&h=bc8edb4cc49d4ae440775adec5ac001f + + 207259060 + Tue, 05 Apr 2011 04:42:36 +0000 +
+ + American.Pickers.S03E03.Franks.Big.Shot.HDTV.XviD-MOMENTUM + Tue, 05 Apr 2011 06:38:23 +0000 + TV-XviD + http://nzbs.org/index.php?action=view&nzbid=605551 + Category: TV-XviD
Size: 395.8 MB
Files: 36 (7 pars)
Group: a.b.teevee
.NFO: View NFO
Posted: Tue April 5th 04:37:39 UTC
Add to My NZBs
Download NZB
]]>
+ http://nzbs.org/index.php?action=view&nzbid=605551 + 605551 + TV-XviD + http://nzbs.org/index.php?action=getnzb&nzbid=605551&i=43516&h=bc8edb4cc49d4ae440775adec5ac001f + + 414999248 + Tue, 05 Apr 2011 04:37:39 +0000 +
+ + The.Colbert.Report.2011.04.04.Andrew.Chaikin.HDTV.XviD-FQM + Tue, 05 Apr 2011 06:10:21 +0000 + TV-XviD + http://nzbs.org/index.php?action=view&nzbid=605538 + Category: TV-XviD
Size: 198.9 MB
Files: 20 (6 pars)
Group: a.b.teevee
.NFO: View NFO
Posted: Tue April 5th 04:09:27 UTC
Add to My NZBs
Download NZB
]]>
+ http://nzbs.org/index.php?action=view&nzbid=605538 + 605538 + TV-XviD + http://nzbs.org/index.php?action=getnzb&nzbid=605538&i=43516&h=bc8edb4cc49d4ae440775adec5ac001f + + 208534960 + Tue, 05 Apr 2011 04:09:27 +0000 +
+ + Pawn.Stars.S03E44.Pablo.Pawncasso.HDTV.XviD-MOMENTUM + Tue, 05 Apr 2011 06:10:15 +0000 + TV-XviD + http://nzbs.org/index.php?action=view&nzbid=605537 + Category: TV-XviD
Size: 198.5 MB
Files: 23 (6 pars)
Group: a.b.teevee
.NFO: View NFO
Posted: Tue April 5th 04:02:34 UTC
Add to My NZBs
Download NZB
]]>
+ http://nzbs.org/index.php?action=view&nzbid=605537 + 605537 + TV-XviD + http://nzbs.org/index.php?action=getnzb&nzbid=605537&i=43516&h=bc8edb4cc49d4ae440775adec5ac001f + + 208139732 + Tue, 05 Apr 2011 04:02:34 +0000 +
+ + The.Kennedys.Part.1.and.Part.2.DSR.XviD-SYS + Tue, 05 Apr 2011 06:10:06 +0000 + TV-XviD + http://nzbs.org/index.php?action=view&nzbid=605536 + Category: TV-XviD
Size: 792.6 MB
Files: 61 (8 pars)
Group: a.b.teevee
.NFO: View NFO
Ext. Link: http://www.reelzchannel.com/kennedys/
Posted: Tue April 5th 04:02:00 UTC
Add to My NZBs
Download NZB
]]>
+ http://nzbs.org/index.php?action=view&nzbid=605536 + 605536 + TV-XviD + http://nzbs.org/index.php?action=getnzb&nzbid=605536&i=43516&h=bc8edb4cc49d4ae440775adec5ac001f + + 831055164 + Tue, 05 Apr 2011 04:02:00 +0000 + http://www.reelzchannel.com/kennedys/ +
+ + Nurse.Jackie.S03E02.720p.HDTV.x264-ORENJI + Tue, 05 Apr 2011 06:00:44 +0000 + TV-x264 + http://nzbs.org/index.php?action=view&nzbid=605535 + Category: TV-x264
Size: 849.3 MB
Files: 26 (6 pars)
Group: a.b.teevee
.NFO: View NFO
Posted: Tue April 5th 03:58:06 UTC
Add to My NZBs
Download NZB
]]>
+ http://nzbs.org/index.php?action=view&nzbid=605535 + 605535 + TV-x264 + http://nzbs.org/index.php?action=getnzb&nzbid=605535&i=43516&h=bc8edb4cc49d4ae440775adec5ac001f + + 890553088 + Tue, 05 Apr 2011 03:58:06 +0000 +
+ + The Killing S01E01-02 1080i HDTV DD5.1 MPEG2-TrollHD + Tue, 05 Apr 2011 06:00:43 +0000 + TV-Other + http://nzbs.org/index.php?action=view&nzbid=605534 + Category: TV-Other
Size: 6.77 GB
Files: 77 (12 pars)
Group: a.b.hdtv
.NFO: None
Posted: Tue April 5th 03:50:44 UTC
Add to My NZBs
Download NZB
]]>
+ http://nzbs.org/index.php?action=view&nzbid=605534 + 605534 + TV-Other + http://nzbs.org/index.php?action=getnzb&nzbid=605534&i=43516&h=bc8edb4cc49d4ae440775adec5ac001f + + 7271142303 + Tue, 05 Apr 2011 03:50:44 +0000 +
+ + Pawn.Stars.S03E43.Evel.Genius.HDTV.XviD-MOMENTUM + Tue, 05 Apr 2011 05:51:18 +0000 + TV-XviD + http://nzbs.org/index.php?action=view&nzbid=605533 + Category: TV-XviD
Size: 206.3 MB
Files: 26 (8 pars)
Group: a.b.teevee
.NFO: View NFO
Posted: Tue April 5th 03:49:24 UTC
Add to My NZBs
Download NZB
]]>
+ http://nzbs.org/index.php?action=view&nzbid=605533 + 605533 + TV-XviD + http://nzbs.org/index.php?action=getnzb&nzbid=605533&i=43516&h=bc8edb4cc49d4ae440775adec5ac001f + + 216304268 + Tue, 05 Apr 2011 03:49:24 +0000 +
+ + United.States.of.Tara.S03E02.720p.HDTV.x264-ORENJI + Tue, 05 Apr 2011 05:51:16 +0000 + TV-x264 + http://nzbs.org/index.php?action=view&nzbid=605532 + Category: TV-x264
Size: 846.9 MB
Files: 26 (6 pars)
Group: a.b.teevee
.NFO: View NFO
Posted: Tue April 5th 03:42:42 UTC
Add to My NZBs
Download NZB
]]>
+ http://nzbs.org/index.php?action=view&nzbid=605532 + 605532 + TV-x264 + http://nzbs.org/index.php?action=getnzb&nzbid=605532&i=43516&h=bc8edb4cc49d4ae440775adec5ac001f + + 888024966 + Tue, 05 Apr 2011 03:42:42 +0000 +
+ + WWE.Wrestlemania.27.PPV.HDTV.XviD-KYR + Tue, 05 Apr 2011 05:41:55 +0000 + TV-XviD + http://nzbs.org/index.php?action=view&nzbid=605528 + Category: TV-XviD
Size: 2.51 GB
Files: 66 (14 pars)
Group: a.b.multimedia
.NFO: View NFO
Posted: Tue April 5th 03:38:30 UTC
Add to My NZBs
Download NZB
]]>
+ http://nzbs.org/index.php?action=view&nzbid=605528 + 605528 + TV-XviD + http://nzbs.org/index.php?action=getnzb&nzbid=605528&i=43516&h=bc8edb4cc49d4ae440775adec5ac001f + + 2690082009 + Tue, 05 Apr 2011 03:38:30 +0000 +
+ + The.Daily.Show.2011.04.04.Billy.Crystal.HDTV.XviD-FQM + Tue, 05 Apr 2011 05:41:54 +0000 + TV-XviD + http://nzbs.org/index.php?action=view&nzbid=605527 + Category: TV-XviD
Size: 199.0 MB
Files: 20 (6 pars)
Group: a.b.teevee
.NFO: View NFO
Ext. Link: http://www.thedailyshow.com/
Posted: Tue April 5th 03:37:59 UTC
Add to My NZBs
Download NZB
]]>
+ http://nzbs.org/index.php?action=view&nzbid=605527 + 605527 + TV-XviD + http://nzbs.org/index.php?action=getnzb&nzbid=605527&i=43516&h=bc8edb4cc49d4ae440775adec5ac001f + + 208686256 + Tue, 05 Apr 2011 03:37:59 +0000 + http://www.thedailyshow.com/ +
+ + The.Event.S01E16.720p.HDTV.X264-DIMENSION REPOST + Tue, 05 Apr 2011 05:32:29 +0000 + TV-x264 + http://nzbs.org/index.php?action=view&nzbid=605519 + Category: TV-x264
Size: 1.28 GB
Files: 42 (14 pars)
Group: a.b.multimedia
.NFO: View NFO
Posted: Tue April 5th 03:24:05 UTC
Add to My NZBs
Download NZB
]]>
+ http://nzbs.org/index.php?action=view&nzbid=605519 + 605519 + TV-x264 + http://nzbs.org/index.php?action=getnzb&nzbid=605519&i=43516&h=bc8edb4cc49d4ae440775adec5ac001f + + 1369823254 + Tue, 05 Apr 2011 03:24:05 +0000 +
+ + United.States.of.Tara.S03E02.Crackerjack.HDTV.XviD-FQM + Tue, 05 Apr 2011 05:13:44 +0000 + TV-XviD + http://nzbs.org/index.php?action=view&nzbid=605506 + Category: TV-XviD
Size: 265.2 MB
Files: 24 (7 pars)
Group: a.b.teevee
.NFO: View NFO
Ext. Link: http://www.sho.com/site/tara/
Posted: Tue April 5th 03:08:58 UTC
Add to My NZBs
Download NZB
]]>
+ http://nzbs.org/index.php?action=view&nzbid=605506 + 605506 + TV-XviD + http://nzbs.org/index.php?action=getnzb&nzbid=605506&i=43516&h=bc8edb4cc49d4ae440775adec5ac001f + + 278057587 + Tue, 05 Apr 2011 03:08:58 +0000 + http://www.sho.com/site/tara/ +
+ + Harrys.Law.S01E12.HDTV.XviD-2HD + Tue, 05 Apr 2011 05:13:41 +0000 + TV-XviD + http://nzbs.org/index.php?action=view&nzbid=605505 + Category: TV-XviD
Size: 397.8 MB
Files: 30 (7 pars)
Group: a.b.teevee
.NFO: View NFO
Posted: Tue April 5th 03:07:39 UTC
Add to My NZBs
Download NZB
]]>
+ http://nzbs.org/index.php?action=view&nzbid=605505 + 605505 + TV-XviD + http://nzbs.org/index.php?action=getnzb&nzbid=605505&i=43516&h=bc8edb4cc49d4ae440775adec5ac001f + + 417156038 + Tue, 05 Apr 2011 03:07:39 +0000 +
+ + Castle.2009.S03E20.720p.HDTV.X264-DIMENSION + Tue, 05 Apr 2011 05:13:36 +0000 + TV-x264 + http://nzbs.org/index.php?action=view&nzbid=605504 + Category: TV-x264
Size: 1.24 GB
Files: 35 (7 pars)
Group: a.b.teevee
.NFO: View NFO
Posted: Tue April 5th 03:07:21 UTC
Add to My NZBs
Download NZB
]]>
+ http://nzbs.org/index.php?action=view&nzbid=605504 + 605504 + TV-x264 + http://nzbs.org/index.php?action=getnzb&nzbid=605504&i=43516&h=bc8edb4cc49d4ae440775adec5ac001f + + 1333441054 + Tue, 05 Apr 2011 03:07:21 +0000 +
+ + Stargate.Universe.S02E15.720p.HDTV.X264-DIMENSION + Tue, 05 Apr 2011 05:13:28 +0000 + TV-x264 + http://nzbs.org/index.php?action=view&nzbid=605503 + Category: TV-x264
Size: 1.25 GB
Files: 35 (7 pars)
Group: a.b.teevee
.NFO: View NFO
Posted: Tue April 5th 03:05:25 UTC
Add to My NZBs
Download NZB
]]>
+ http://nzbs.org/index.php?action=view&nzbid=605503 + 605503 + TV-x264 + http://nzbs.org/index.php?action=getnzb&nzbid=605503&i=43516&h=bc8edb4cc49d4ae440775adec5ac001f + + 1337316693 + Tue, 05 Apr 2011 03:05:25 +0000 +
+ + Harrys.Law.S01E12.720p.HDTV.X264-DIMENSION + Tue, 05 Apr 2011 05:13:18 +0000 + TV-x264 + http://nzbs.org/index.php?action=view&nzbid=605502 + Category: TV-x264
Size: 1.24 GB
Files: 35 (7 pars)
Group: a.b.teevee
.NFO: View NFO
Posted: Tue April 5th 03:03:36 UTC
Add to My NZBs
Download NZB
]]>
+ http://nzbs.org/index.php?action=view&nzbid=605502 + 605502 + TV-x264 + http://nzbs.org/index.php?action=getnzb&nzbid=605502&i=43516&h=bc8edb4cc49d4ae440775adec5ac001f + + 1334867450 + Tue, 05 Apr 2011 03:03:36 +0000 +
+ + Castle.2009.S03E20.HDTV.XviD-LOL + Tue, 05 Apr 2011 05:13:08 +0000 + TV-XviD + http://nzbs.org/index.php?action=view&nzbid=605500 + Category: TV-XviD
Size: 396.7 MB
Files: 36 (7 pars)
Group: a.b.teevee
.NFO: View NFO
Ext. Link: http://www.tvrage.com/Castle
Posted: Tue April 5th 03:02:22 UTC
Add to My NZBs
Download NZB
]]>
+ http://nzbs.org/index.php?action=view&nzbid=605500 + 605500 + TV-XviD + http://nzbs.org/index.php?action=getnzb&nzbid=605500&i=43516&h=bc8edb4cc49d4ae440775adec5ac001f + + 415952872 + Tue, 05 Apr 2011 03:02:22 +0000 + http://www.tvrage.com/Castle +
+ + Stargate.Universe.S02E15.HDTV.XviD-LOL + Tue, 05 Apr 2011 05:03:36 +0000 + TV-XviD + http://nzbs.org/index.php?action=view&nzbid=605499 + Category: TV-XviD
Size: 397.4 MB
Files: 36 (7 pars)
Group: a.b.teevee
.NFO: View NFO
Ext. Link: http://tvrage.com/Stargate_Universe
Posted: Tue April 5th 03:01:16 UTC
Add to My NZBs
Download NZB
]]>
+ http://nzbs.org/index.php?action=view&nzbid=605499 + 605499 + TV-XviD + http://nzbs.org/index.php?action=getnzb&nzbid=605499&i=43516&h=bc8edb4cc49d4ae440775adec5ac001f + + 416749161 + Tue, 05 Apr 2011 03:01:16 +0000 + http://tvrage.com/Stargate_Universe +
+
+
\ No newline at end of file diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index 88db4a0eb..d6db61970 100644 --- a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -67,12 +67,14 @@ Libs\System.Data.SQLite.DLL True + ..\NzbDrone.Core\Libraries\TvdbLib.dll + @@ -101,6 +103,9 @@ Always + + Always + Always diff --git a/NzbDrone.Core.Test/ParserTest.cs b/NzbDrone.Core.Test/ParserTest.cs index 4b718ac9e..dad4cf4b1 100644 --- a/NzbDrone.Core.Test/ParserTest.cs +++ b/NzbDrone.Core.Test/ParserTest.cs @@ -12,6 +12,12 @@ namespace NzbDrone.Core.Test // ReSharper disable InconsistentNaming public class ParserTest { + /*Fucked-up hall of shame, + * WWE.Wrestlemania.27.PPV.HDTV.XviD-KYR + * The.Kennedys.Part.2.DSR.XviD-SYS + */ + + [Test] [Row("Sonny.With.a.Chance.S02E15", 2, 15)] [Row("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD", 3, 1)] @@ -28,6 +34,8 @@ namespace NzbDrone.Core.Test [Row(@"Hawaii Five 0 S01E19 720p WEB DL DD5 1 H 264 NT", 1, 19)] [Row(@"The Event S01E14 A Message Back 720p WEB DL DD5 1 H264 SURFER", 1, 14)] [Row(@"Adam Hills In Gordon St Tonight S01E07 WS PDTV XviD FUtV", 1, 7)] + [Row(@"Adam Hills In Gordon St Tonight S01E07 WS PDTV XviD FUtV", 1, 7)] + [Row("The.Kennedys.Part.2.DSR.XviD-SYS", 1, 2)] public void episode_parse(string path, int season, int episode) { var result = Parser.ParseEpisodeInfo(path); @@ -61,6 +69,20 @@ namespace NzbDrone.Core.Test Assert.AreEqual(quality, result); } + [Test] + [Row("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD", 3, 1, 2, 3, 4, 5, 6)] + [Row("Two.and.a.Half.Me.103.104.720p.HDTV.X264-DIMENSION", 1, 3, 4)] + [Row("The.Kennedys.Part.1.and.Part.2.DSR.XviD-SYS", 1, 1, 2)] + public void episode_multipart_parse(string path, int season, params int[] episodes) + { + var result = Parser.ParseEpisodeInfo(path); + Assert.AreEqual(season, result.SeasonNumber); + Assert.Count(episodes.Length, result.Episodes); + Assert.AreElementsEqualIgnoringOrder(episodes, result.Episodes); + } + + + [Test] [Row(@"c:\test\", @"c:\test")] [Row(@"c:\\test\\", @"c:\test")] diff --git a/NzbDrone.Core.Test/RssProviderTest.cs b/NzbDrone.Core.Test/RssProviderTest.cs new file mode 100644 index 000000000..f7977ed8b --- /dev/null +++ b/NzbDrone.Core.Test/RssProviderTest.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.ServiceModel.Syndication; +using System.Text; +using System.Xml; +using Gallio.Framework; +using MbUnit.Framework; +using MbUnit.Framework.ContractVerifiers; +using Moq; +using Ninject; +using Ninject.Moq; +using NzbDrone.Core.Providers; +using NzbDrone.Core.Providers.Core; +using NzbDrone.Core.Providers.Feed; +using NzbDrone.Core.Repository; +using SubSonic.Repository; + +namespace NzbDrone.Core.Test +{ + [TestFixture] + public class RssProviderTest + // ReSharper disable InconsistentNaming + { + [Test] + + public void Download_feed_test() + { + var kernel = new MockingKernel(); + + var xmlReader = XmlReader.Create(File.OpenRead(".\\Files\\Rss\\nzbsorg.xml")); + var httpMock = new Mock(MockBehavior.Strict); + httpMock.Setup(h => + h.DownloadXml(It.Is(c => c == "www.google.com" || c == "www.yahoo.com"))) + .Returns(xmlReader); + + kernel.Bind().ToConstant(httpMock.Object); + kernel.Bind().To(); + + kernel.Get().Fetch(); + + } + + } + + public class MockFeedProvider : FeedProviderBase + { + public MockFeedProvider(ISeriesProvider seriesProvider, ISeasonProvider seasonProvider, IEpisodeProvider episodeProvider, IConfigProvider configProvider, IHttpProvider httpProvider) + : base(seriesProvider, seasonProvider, episodeProvider, configProvider, httpProvider) + { + } + + protected override string[] URL + { + get { return new[] { "www.google.com" }; } + } + + protected override string Name + { + get { return "MyName"; } + } + + protected override string NzbDownloadUrl(SyndicationItem item) + { + return item.Links[0].Uri.ToString(); + } + } +} diff --git a/NzbDrone.Core.Test/log.config b/NzbDrone.Core.Test/log.config index 698a94c0a..5b8212b5d 100644 --- a/NzbDrone.Core.Test/log.config +++ b/NzbDrone.Core.Test/log.config @@ -1,8 +1,16 @@  + + + + + + + \ No newline at end of file diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index 856d95c98..10e39166d 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -134,9 +134,6 @@ False ..\packages\Ninject.2.2.1.0\lib\.NetFramework 4.0\Ninject.dll - - Libraries\Ninject.Extensions.Conventions.dll - False diff --git a/NzbDrone.Core/Parser.cs b/NzbDrone.Core/Parser.cs index 757eb546f..312be2c62 100644 --- a/NzbDrone.Core/Parser.cs +++ b/NzbDrone.Core/Parser.cs @@ -74,7 +74,7 @@ namespace NzbDrone.Core return parsedEpisode; } } - + Logger.Warn("Unable to parse text into episode info. {0}", title); return null; } diff --git a/NzbDrone.Core/Providers/Feed/FeedProviderBase.cs b/NzbDrone.Core/Providers/Feed/FeedProviderBase.cs index 2b1b09669..a63185714 100644 --- a/NzbDrone.Core/Providers/Feed/FeedProviderBase.cs +++ b/NzbDrone.Core/Providers/Feed/FeedProviderBase.cs @@ -6,7 +6,7 @@ using NzbDrone.Core.Providers.Core; namespace NzbDrone.Core.Providers.Feed { - abstract class FeedProviderBase + public abstract class FeedProviderBase { protected readonly ISeriesProvider _seriesProvider; protected readonly ISeasonProvider _seasonProvider; @@ -15,7 +15,7 @@ namespace NzbDrone.Core.Providers.Feed private readonly IHttpProvider _httpProvider; protected static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - protected FeedProviderBase(ISeriesProvider seriesProvider, ISeasonProvider seasonProvider, + public FeedProviderBase(ISeriesProvider seriesProvider, ISeasonProvider seasonProvider, IEpisodeProvider episodeProvider, IConfigProvider configProvider, IHttpProvider httpProvider) { _seriesProvider = seriesProvider; @@ -52,7 +52,9 @@ namespace NzbDrone.Core.Providers.Feed /// Detailed episode info protected EpisodeParseResult ParseFeed(SyndicationItem item) { - var episodeParseResult = Parser.ParseEpisodeInfo(item.Title.ToString()); + var episodeParseResult = Parser.ParseEpisodeInfo(item.Title.Text); + if (episodeParseResult == null) return null; + var seriesInfo = _seriesProvider.FindSeries(episodeParseResult.SeriesTitle); if (seriesInfo != null) @@ -92,28 +94,31 @@ namespace NzbDrone.Core.Providers.Feed private void ProcessItem(SyndicationItem feedItem) { - Logger.Info("Processing RSS feed item " + feedItem.Title); + Logger.Info("Processing RSS feed item " + feedItem.Title.Text); var parseResult = ParseFeed(feedItem); - if (!_seriesProvider.IsMonitored(parseResult.SeriesId)) + if (parseResult != null) { - Logger.Debug("{0} is present in the DB but not tracked. skipping.", parseResult.SeriesTitle); - } + if (!_seriesProvider.IsMonitored(parseResult.SeriesId)) + { + Logger.Debug("{0} is present in the DB but not tracked. skipping.", parseResult.SeriesTitle); + } - if (!_seriesProvider.QualityWanted(parseResult.SeriesId, parseResult.Quality)) - { - Logger.Debug("Post doesn't meet the quality requirements [{0}]. skipping.", parseResult.Quality); - } + if (!_seriesProvider.QualityWanted(parseResult.SeriesId, parseResult.Quality)) + { + Logger.Debug("Post doesn't meet the quality requirements [{0}]. skipping.", parseResult.Quality); + } - if (_seasonProvider.IsIgnored(parseResult.SeriesId, parseResult.SeasonNumber)) - { - Logger.Debug("Season {0} is currently set to ignore. skipping.", parseResult.SeasonNumber); - } + if (_seasonProvider.IsIgnored(parseResult.SeriesId, parseResult.SeasonNumber)) + { + Logger.Debug("Season {0} is currently set to ignore. skipping.", parseResult.SeasonNumber); + } - if (!_episodeProvider.IsNeeded(parseResult)) - { - Logger.Debug("Episode {0} is not needed. skipping.", parseResult); + if (!_episodeProvider.IsNeeded(parseResult)) + { + Logger.Debug("Episode {0} is not needed. skipping.", parseResult); + } } } }