You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jellyfin/tests/Jellyfin.Naming.Tests/EpisodePathParserTest.cs

56 lines
2.1 KiB

5 years ago
using Emby.Naming.Common;
using Emby.Naming.TV;
using Xunit;
5 years ago
namespace Jellyfin.Naming.Tests
{
public class EpisodePathParserTest
{
[Theory]
[InlineData("/media/Foo/Foo-S01E01", "Foo", 1, 1)]
[InlineData("/media/Foo - S04E011", "Foo", 4, 11)]
[InlineData("/media/Foo/Foo s01x01", "Foo", 1, 1)]
[InlineData("/media/Foo (2019)/Season 4/Foo (2019).S04E03", "Foo (2019)", 4, 3)]
public void ParseEpisodesCorrectly(string path, string name, int season, int episode)
{
NamingOptions o = new NamingOptions();
EpisodePathParser p = new EpisodePathParser(o);
var res = p.Parse(path, false);
Assert.True(res.Success);
Assert.Equal(name, res.SeriesName);
Assert.Equal(season, res.SeasonNumber);
Assert.Equal(episode, res.EpisodeNumber);
5 years ago
// testing other paths delimeter
var res2 = p.Parse(path.Replace('/', '\\'), false);
Assert.True(res2.Success);
Assert.Equal(name, res2.SeriesName);
Assert.Equal(season, res2.SeasonNumber);
Assert.Equal(episode, res2.EpisodeNumber);
}
[Theory]
[InlineData("/media/Foo/Foo 889", "Foo", 889)]
5 years ago
[InlineData("/media/Foo/[Bar] Foo Baz - 11 [1080p]", "Foo Baz", 11)]
public void ParseEpisodeWithoutSeason(string path, string name, int episode)
{
NamingOptions o = new NamingOptions();
EpisodePathParser p = new EpisodePathParser(o);
5 years ago
var res = p.Parse(path, true, fillExtendedInfo: true);
Assert.True(res.Success);
Assert.Equal(name, res.SeriesName);
5 years ago
Assert.Null(res.SeasonNumber);
Assert.Equal(episode, res.EpisodeNumber);
5 years ago
// testing other paths delimeter
var res2 = p.Parse(path.Replace('/', '\\'), false, fillExtendedInfo: false);
Assert.True(res2.Success);
Assert.Equal(name, res2.SeriesName);
5 years ago
Assert.Null(res2.SeasonNumber);
Assert.Equal(episode, res2.EpisodeNumber);
}
}
5 years ago
}