mirror of
https://github.com/Radarr/Radarr.git
synced 2024-08-18 16:29:41 +02:00
Simplified regex a bit.
(cherry picked from commit f107ea5678a6a3153113fd6a87a0ef77c20ab216)
This commit is contained in:
parent
34c545d932
commit
8d1a9f98af
@ -1,19 +1,14 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.CustomFormats;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.MediaFiles.MediaInfo;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.Organizer;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests
|
||||
{
|
||||
@ -43,26 +38,32 @@ public void Setup()
|
||||
Mocker.GetMock<IQualityDefinitionService>()
|
||||
.Setup(v => v.Get(Moq.It.IsAny<Quality>()))
|
||||
.Returns<Quality>(v => Quality.DefaultQualityDefinitions.First(c => c.Quality == v));
|
||||
|
||||
Mocker.GetMock<ICustomFormatService>()
|
||||
.Setup(v => v.All())
|
||||
.Returns(new List<CustomFormat>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_replace_reserved_device_name_in_movies_folder()
|
||||
[TestCase("Con Game", 2021, "Con_Game (2021)")]
|
||||
[TestCase("Com1 Sat", 2021, "Com1_Sat (2021)")]
|
||||
public void should_replace_reserved_device_name_in_movies_folder(string title, int year, string expected)
|
||||
{
|
||||
_movie.Title = "Con Man";
|
||||
_movie.Year = 2021;
|
||||
_movie.Title = title;
|
||||
_movie.Year = year;
|
||||
_namingConfig.MovieFolderFormat = "{Movie.Title} ({Release Year})";
|
||||
|
||||
Subject.GetMovieFolder(_movie).Should().Be("Con_Man (2021)");
|
||||
Subject.GetMovieFolder(_movie).Should().Be($"{expected}");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_replace_reserved_device_name_in_file_name()
|
||||
[TestCase("Con Game", 2021, "Con_Game (2021)")]
|
||||
[TestCase("Com1 Sat", 2021, "Com1_Sat (2021)")]
|
||||
public void should_replace_reserved_device_name_in_file_name(string title, int year, string expected)
|
||||
{
|
||||
_movie.Title = "Con Man";
|
||||
_movie.Year = 2021;
|
||||
_movie.Title = title;
|
||||
_movie.Year = year;
|
||||
_namingConfig.StandardMovieFormat = "{Movie.Title} ({Release Year})";
|
||||
|
||||
Subject.BuildFileName(_movie, _movieFile).Should().Be("Con_Man (2021)");
|
||||
Subject.BuildFileName(_movie, _movieFile).Should().Be($"{expected}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public class FileNameBuilder : IBuildFileNames
|
||||
|
||||
private static readonly Regex TitlePrefixRegex = new Regex(@"^(The|An|A) (.*?)((?: *\([^)]+\))*)$", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
|
||||
private static readonly Regex ReservedDeviceNamesRegex = new Regex(@"^(?:aux|com1|com2|com3|com4|com5|com6|com7|com8|com9|con|lpt1|lpt2|lpt3|lpt4|lpt5|lpt6|lpt7|lpt8|lpt9|nul|prn)\.", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
private static readonly Regex ReservedDeviceNamesRegex = new Regex(@"^(?:aux|com[1-9]|con|lpt[1-9]|nul|prn)\.", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
|
||||
public FileNameBuilder(INamingConfigService namingConfigService,
|
||||
IQualityDefinitionService qualityDefinitionService,
|
||||
|
Loading…
Reference in New Issue
Block a user