using System.Collections.Generic; using System.Linq; using FizzWare.NBuilder; using FluentAssertions; using NUnit.Framework; using NzbDrone.Core.CustomFormats; 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 CleanTitleTheFixture : CoreTest { private Series _series; private Episode _episode; private EpisodeFile _episodeFile; private NamingConfig _namingConfig; [SetUp] public void Setup() { _series = Builder .CreateNew() .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)); Mocker.GetMock() .Setup(v => v.All()) .Returns(new List()); } [TestCase("The Mist", "Mist, The")] [TestCase("A Place to Call Home", "Place to Call Home, A")] [TestCase("An Adventure in Space and Time", "Adventure in Space and Time, An")] [TestCase("The Flash (2010)", "Flash, The 2010")] [TestCase("A League Of Their Own (AU)", "League Of Their Own, A AU")] [TestCase("The Fixer (ZH) (2015)", "Fixer, The ZH 2015")] [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 AandE")] [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; _namingConfig.StandardEpisodeFormat = "{Series CleanTitleThe}"; Subject.BuildFileName(new List { _episode }, _series, _episodeFile) .Should().Be(expected); } [TestCase("A")] [TestCase("Anne")] [TestCase("Theodore")] [TestCase("3%")] public void should_not_change_title(string title) { _series.Title = title; _namingConfig.StandardEpisodeFormat = "{Series CleanTitleThe}"; Subject.BuildFileName(new List { _episode }, _series, _episodeFile) .Should().Be(title); } } }