diff --git a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index dbb7a8e11..fe4ed9e77 100644 --- a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -335,6 +335,7 @@ + diff --git a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/ReplaceCharacterFixure.cs b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/ReplaceCharacterFixure.cs new file mode 100644 index 000000000..d0a727e31 --- /dev/null +++ b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/ReplaceCharacterFixure.cs @@ -0,0 +1,73 @@ +using System.Collections.Generic; +using System.Linq; +using FizzWare.NBuilder; +using FluentAssertions; +using NUnit.Framework; +using NzbDrone.Core.MediaFiles; +using NzbDrone.Core.Organizer; +using NzbDrone.Core.Qualities; +using NzbDrone.Core.Test.Framework; +using NzbDrone.Core.Tv; + +namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests +{ + [TestFixture] + public class ReplaceCharacterFixture : CoreTest + { + private Series _series; + private Episode _episode; + private EpisodeFile _episodeFile; + private NamingConfig _namingConfig; + + [SetUp] + public void Setup() + { + _series = Builder + .CreateNew() + .With(s => s.Title = "South Park") + .Build(); + + _episode = Builder.CreateNew() + .With(e => e.Title = "City Sushi") + .With(e => e.SeasonNumber = 15) + .With(e => e.EpisodeNumber = 6) + .With(e => e.AbsoluteEpisodeNumber = 100) + .Build(); + + _episodeFile = new EpisodeFile { Quality = new QualityModel(Quality.HDTV720p), ReleaseGroup = "SonarrTest" }; + + _namingConfig = NamingConfig.Default; + _namingConfig.RenameEpisodes = true; + + Mocker.GetMock() + .Setup(c => c.GetConfig()).Returns(_namingConfig); + + Mocker.GetMock() + .Setup(v => v.Get(Moq.It.IsAny())) + .Returns(v => Quality.DefaultQualityDefinitions.First(c => c.Quality == v)); + } + +// { "\\", "/", "<", ">", "?", "*", ":", "|", "\"" }; +// { "+", "+", "", "", "!", "-", " -", "", "" }; + + + [TestCase("CSI: Crime Scene Investigation", "CSI - Crime Scene Investigation")] + [TestCase("Back Slash\\", "Back Slash+")] + [TestCase("Forward Slash\\", "Forward Slash+")] + [TestCase("Greater Than>", "Greater Than")] + [TestCase("Less Than<", "Less Than")] + [TestCase("Question Mark?", "Question Mark!")] + [TestCase("Aster*sk", "Aster-sk")] + [TestCase("Colon: Two Periods", "Colon - Two Periods")] + [TestCase("Pipe|", "Pipe")] + [TestCase("Quotes\"", "Quotes")] + public void should_replace_illegal_characters(string title, string expected) + { + _series.Title = title; + _namingConfig.StandardEpisodeFormat = "{Series Title}"; + + Subject.BuildFileName(new List { _episode }, _series, _episodeFile) + .Should().Be(expected); + } + } +} diff --git a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/TitleTheFixture.cs b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/TitleTheFixture.cs index dcdded4eb..8d19911bd 100644 --- a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/TitleTheFixture.cs +++ b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/TitleTheFixture.cs @@ -55,7 +55,7 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests [TestCase("The Sixth Sense 2 (Thai)", "Sixth Sense 2, The (Thai)")] [TestCase("The Amazing Race (Latin America)", "Amazing Race, The (Latin America)")] [TestCase("The Rat Pack (A&E)", "Rat Pack, The (A&E)")] - [TestCase("The Climax: I (Almost) Got Away With It (2016)", "Climax- I (Almost) Got Away With It, The (2016)")] + [TestCase("The Climax: I (Almost) Got Away With It (2016)", "Climax - I (Almost) Got Away With It, The (2016)")] public void should_get_expected_title_back(string title, string expected) { _series.Title = title; diff --git a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/TitleTheYearFixture.cs b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/TitleTheYearFixture.cs index f55ebacdc..d79401f1b 100644 --- a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/TitleTheYearFixture.cs +++ b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/TitleTheYearFixture.cs @@ -48,7 +48,7 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests [TestCase("The Mist", 2018, "Mist, The (2018)")] [TestCase("The Rat Pack (A&E)", 1999, "Rat Pack, The (A&E) (1999)")] - [TestCase("The Climax: I (Almost) Got Away With It (2016)", 2016, "Climax- I (Almost) Got Away With It, The (2016)")] + [TestCase("The Climax: I (Almost) Got Away With It (2016)", 2016, "Climax - I (Almost) Got Away With It, The (2016)")] [TestCase("A", 2017, "A (2017)")] public void should_get_expected_title_back(string title, int year, string expected) { diff --git a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/TitleYearFixture.cs b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/TitleYearFixture.cs index 1c2f03a94..bb8c7fa7a 100644 --- a/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/TitleYearFixture.cs +++ b/src/NzbDrone.Core.Test/OrganizerTests/FileNameBuilderTests/TitleYearFixture.cs @@ -48,7 +48,7 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests [TestCase("The Mist", 2018, "The Mist (2018)")] [TestCase("The Rat Pack (A&E)", 1999, "The Rat Pack (A&E) (1999)")] - [TestCase("The Climax: I (Almost) Got Away With It (2016)", 2016, "The Climax- I (Almost) Got Away With It (2016)")] + [TestCase("The Climax: I (Almost) Got Away With It (2016)", 2016, "The Climax - I (Almost) Got Away With It (2016)")] public void should_get_expected_title_back(string title, int year, string expected) { _series.Title = title; diff --git a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs index ea5f69284..6a34ce05e 100644 --- a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs +++ b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs @@ -299,7 +299,7 @@ namespace NzbDrone.Core.Organizer { string result = name; string[] badCharacters = { "\\", "/", "<", ">", "?", "*", ":", "|", "\"" }; - string[] goodCharacters = { "+", "+", "", "", "!", "-", "-", "", "" }; + string[] goodCharacters = { "+", "+", "", "", "!", "-", " -", "", "" }; for (int i = 0; i < badCharacters.Length; i++) {