mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-28 04:51:45 +02:00
Cleaned up parser tests, 1103/1113 parsing is less greedy
Fixed: Importing of hashed releases
This commit is contained in:
96
src/NzbDrone.Core.Test/ParserTests/NormalizeTitleFixture.cs
Normal file
96
src/NzbDrone.Core.Test/ParserTests/NormalizeTitleFixture.cs
Normal file
@@ -0,0 +1,96 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Expansive;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.ParserTests
|
||||
{
|
||||
|
||||
[TestFixture]
|
||||
public class NormalizeTitleFixture : CoreTest
|
||||
{
|
||||
[TestCase("Conan", "conan")]
|
||||
[TestCase("The Tonight Show With Jay Leno", "tonightshowwithjayleno")]
|
||||
[TestCase("The.Daily.Show", "dailyshow")]
|
||||
[TestCase("Castle (2009)", "castle2009")]
|
||||
[TestCase("Parenthood.2010", "parenthood2010")]
|
||||
[TestCase("Law_and_Order_SVU", "lawordersvu")]
|
||||
public void should_normalize_series_title(string parsedSeriesName, string seriesName)
|
||||
{
|
||||
var result = parsedSeriesName.CleanSeriesTitle();
|
||||
result.Should().Be(seriesName);
|
||||
}
|
||||
|
||||
[TestCase("CaPitAl", "capital")]
|
||||
[TestCase("peri.od", "period")]
|
||||
[TestCase("this.^&%^**$%@#$!That", "thisthat")]
|
||||
[TestCase("test/test", "testtest")]
|
||||
[TestCase("90210", "90210")]
|
||||
[TestCase("24", "24")]
|
||||
public void should_remove_special_characters_and_casing(string dirty, string clean)
|
||||
{
|
||||
var result = dirty.CleanSeriesTitle();
|
||||
result.Should().Be(clean);
|
||||
}
|
||||
|
||||
[TestCase("the")]
|
||||
[TestCase("and")]
|
||||
[TestCase("or")]
|
||||
[TestCase("a")]
|
||||
[TestCase("an")]
|
||||
[TestCase("of")]
|
||||
public void should_remove_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);
|
||||
dirty.CleanSeriesTitle().Should().Be("wordword");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[TestCase("the")]
|
||||
[TestCase("and")]
|
||||
[TestCase("or")]
|
||||
[TestCase("a")]
|
||||
[TestCase("an")]
|
||||
[TestCase("of")]
|
||||
public void should_not_remove_common_words_in_the_middle_of_word(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);
|
||||
dirty.CleanSeriesTitle().Should().Be(("word" + word.ToLower() + "word"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user