Simplified regex a bit.

pull/4572/head
Taloth Saldono 3 years ago
parent 59409a7e72
commit f107ea5678

@ -56,31 +56,34 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests
.Returns<Quality>(v => Quality.DefaultQualityDefinitions.First(c => c.Quality == v));
}
[Test]
public void should_replace_reserved_device_name_in_series_folder()
[TestCase("Con Game", "Con_Game")]
[TestCase("Com1 Sat", "Com1_Sat")]
public void should_replace_reserved_device_name_in_series_folder(string title, string expected)
{
_series.Title = "Con Man";
_series.Title = title;
_namingConfig.SeriesFolderFormat = "{Series.Title}";
Subject.GetSeriesFolder(_series).Should().Be("Con_Man");
Subject.GetSeriesFolder(_series).Should().Be($"{expected}");
}
[Test]
public void should_replace_reserved_device_name_in_season_folder()
[TestCase("Con Game", "Con_Game")]
[TestCase("Com1 Sat", "Com1_Sat")]
public void should_replace_reserved_device_name_in_season_folder(string title, string expected)
{
_series.Title = "Con Man";
_series.Title = title;
_namingConfig.SeasonFolderFormat = "{Series.Title} - Season {Season:00}";
Subject.GetSeasonFolder(_series, 1).Should().Be("Con_Man - Season 01");
Subject.GetSeasonFolder(_series, 1).Should().Be($"{expected} - Season 01");
}
[Test]
public void should_replace_reserved_device_name_in_file_name()
[TestCase("Con Game", "Con_Game")]
[TestCase("Com1 Sat", "Com1_Sat")]
public void should_replace_reserved_device_name_in_file_name(string title, string expected)
{
_series.Title = "Con Man";
_series.Title = title;
_namingConfig.StandardEpisodeFormat = "{Series.Title} - S{Season:00}E{Episode:00}";
Subject.BuildFileName(new List<Episode> { _episode1 }, _series, _episodeFile).Should().Be("Con_Man - S15E06");
Subject.BuildFileName(new List<Episode> { _episode1 }, _series, _episodeFile).Should().Be($"{expected} - S15E06");
}
}
}

@ -80,7 +80,7 @@ namespace NzbDrone.Core.Organizer
private static readonly Regex YearRegex = new Regex(@"\(\d{4}\)$", 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…
Cancel
Save