From 6d1cb907232ca5618c87f676e073d8aabbb7fbcf Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sat, 22 Feb 2014 15:33:11 -0800 Subject: [PATCH] Possible special is less aggressive, with tests --- .../NzbDrone.Core.Test.csproj | 1 + .../IsPossibleSpecialEpisodeFixture.cs | 39 +++++++++++++++++++ .../Parser/Model/ParsedEpisodeInfo.cs | 9 ++--- 3 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 src/NzbDrone.Core.Test/ParserTests/IsPossibleSpecialEpisodeFixture.cs diff --git a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index 8e2770fc7..fe5a842f8 100644 --- a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -181,6 +181,7 @@ + diff --git a/src/NzbDrone.Core.Test/ParserTests/IsPossibleSpecialEpisodeFixture.cs b/src/NzbDrone.Core.Test/ParserTests/IsPossibleSpecialEpisodeFixture.cs new file mode 100644 index 000000000..5d0cc3829 --- /dev/null +++ b/src/NzbDrone.Core.Test/ParserTests/IsPossibleSpecialEpisodeFixture.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using FluentAssertions; +using NUnit.Framework; +using NzbDrone.Core.Parser.Model; + +namespace NzbDrone.Core.Test.ParserTests +{ + [TestFixture] + public class IsPossibleSpecialEpisodeFixture + { + [Test] + public void should_not_treat_files_without_a_series_title_as_a_special() + { + var parsedEpisodeInfo = new ParsedEpisodeInfo + { + EpisodeNumbers = new[]{ 7 }, + SeasonNumber = 1, + SeriesTitle = "" + }; + + parsedEpisodeInfo.IsPossibleSpecialEpisode().Should().BeFalse(); + } + + [Test] + public void should_return_true_when_episode_numbers_is_empty() + { + var parsedEpisodeInfo = new ParsedEpisodeInfo + { + SeasonNumber = 1, + SeriesTitle = "" + }; + + parsedEpisodeInfo.IsPossibleSpecialEpisode().Should().BeTrue(); + } + } +} diff --git a/src/NzbDrone.Core/Parser/Model/ParsedEpisodeInfo.cs b/src/NzbDrone.Core/Parser/Model/ParsedEpisodeInfo.cs index beea7b190..47adfe26b 100644 --- a/src/NzbDrone.Core/Parser/Model/ParsedEpisodeInfo.cs +++ b/src/NzbDrone.Core/Parser/Model/ParsedEpisodeInfo.cs @@ -37,12 +37,9 @@ public bool IsAbsoluteNumbering() public bool IsPossibleSpecialEpisode() { // if we dont have eny episode numbers we are likely a special episode and need to do a search by episode title - return string.IsNullOrEmpty(AirDate) && - ( - EpisodeNumbers.Length == 0 || - SeasonNumber == 0 || - String.IsNullOrWhiteSpace(SeriesTitle) - ); + return String.IsNullOrWhiteSpace(AirDate) && + (EpisodeNumbers.Length == 0 || SeasonNumber == 0) && + String.IsNullOrWhiteSpace(SeriesTitle); } public override string ToString()