From 42554b815ab921851dc7a9f44d58cca105118203 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Thu, 12 Jan 2012 15:50:04 -0800 Subject: [PATCH] Fixed broken tests. --- NzbDrone.Core.Test/IndexerTests.cs | 2 +- .../ProviderTests/SabProviderTest.cs | 2 - .../Relators/EpisodeFileEpisodeRelator.cs | 48 +++++++++++++++++++ 3 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 NzbDrone.Core/Datastore/Relators/EpisodeFileEpisodeRelator.cs diff --git a/NzbDrone.Core.Test/IndexerTests.cs b/NzbDrone.Core.Test/IndexerTests.cs index 44c8cbb72..bb11233b0 100644 --- a/NzbDrone.Core.Test/IndexerTests.cs +++ b/NzbDrone.Core.Test/IndexerTests.cs @@ -27,7 +27,7 @@ namespace NzbDrone.Core.Test { [TestCase("nzbsorg.xml", 1)] - [TestCase("nzbsrus.xml", 6)] + [TestCase("nzbsrus.xml", 8)] [TestCase("newzbin.xml", 1)] [TestCase("nzbmatrix.xml", 2)] public void parse_feed_xml(string fileName, int warns) diff --git a/NzbDrone.Core.Test/ProviderTests/SabProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/SabProviderTest.cs index e2dcd0f91..f137691f1 100644 --- a/NzbDrone.Core.Test/ProviderTests/SabProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/SabProviderTest.cs @@ -412,7 +412,6 @@ namespace NzbDrone.Core.Test.ProviderTests //Assert result.Should().NotBeNull(); result.categories.Should().HaveCount(c => c > 0); - result.categories.Should().NotContain("*"); } [Test] @@ -449,7 +448,6 @@ namespace NzbDrone.Core.Test.ProviderTests //Assert result.Should().NotBeNull(); result.categories.Should().HaveCount(c => c > 0); - result.categories.Should().NotContain("*"); } } } \ No newline at end of file diff --git a/NzbDrone.Core/Datastore/Relators/EpisodeFileEpisodeRelator.cs b/NzbDrone.Core/Datastore/Relators/EpisodeFileEpisodeRelator.cs new file mode 100644 index 000000000..6c7aa9121 --- /dev/null +++ b/NzbDrone.Core/Datastore/Relators/EpisodeFileEpisodeRelator.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using NzbDrone.Core.Repository; + +namespace NzbDrone.Core.Datastore.Relators +{ + public class EpisodeFileEpisodeRelator + { + + private EpisodeFile _current; + public EpisodeFile MapIt(EpisodeFile episodeFile, Series series, Episode episode) + { + // Terminating call. Since we can return null from this function + // we need to be ready for PetaPoco to callback later with null + // parameters + if (episodeFile == null) + return _current; + + // Is this the same EpisodeFile as the current one we're processing + if (_current != null && _current.EpisodeFileId == episodeFile.EpisodeFileId) + { + // Yes, just add this post to the current EpisodeFiles's collection of Episodes + _current.Episodes.Add(episode); + + // Return null to indicate we're not done with this EpisodeFiles yet + return null; + } + + // This is a different EpisodeFile to the current one, or this is the + // first time through and we don't have an EpisodeFile yet + + // Save the current EpisodeFile + var prev = _current; + + // Setup the new current EpisodeFile + _current = episodeFile; + _current.Episodes = new List(); + _current.Episodes.Add(episode); + _current.Series = series; + + // Return the now populated previous EpisodeFile (or null if first time through) + return prev; + } + + } +}