2021-02-17 09:38:44 +00:00
|
|
|
using System;
|
2020-11-05 15:59:15 +00:00
|
|
|
using System.Linq;
|
2019-12-06 19:40:06 +00:00
|
|
|
using Emby.Naming.Common;
|
|
|
|
using Emby.Naming.Video;
|
2021-12-07 14:18:17 +00:00
|
|
|
using MediaBrowser.Model.Entities;
|
2019-12-06 19:40:06 +00:00
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
namespace Jellyfin.Naming.Tests.Video
|
|
|
|
{
|
|
|
|
public class VideoListResolverTests
|
|
|
|
{
|
2021-05-23 22:30:41 +00:00
|
|
|
private readonly NamingOptions _namingOptions = new NamingOptions();
|
2020-05-14 17:59:10 +00:00
|
|
|
|
2021-02-17 09:38:44 +00:00
|
|
|
[Fact]
|
|
|
|
public void TestStackAndExtras()
|
2019-12-06 19:40:06 +00:00
|
|
|
{
|
|
|
|
// No stacking here because there is no part/disc/etc
|
|
|
|
var files = new[]
|
|
|
|
{
|
|
|
|
"Harry Potter and the Deathly Hallows-trailer.mkv",
|
|
|
|
"Harry Potter and the Deathly Hallows.trailer.mkv",
|
|
|
|
"Harry Potter and the Deathly Hallows part1.mkv",
|
|
|
|
"Harry Potter and the Deathly Hallows part2.mkv",
|
|
|
|
"Harry Potter and the Deathly Hallows part3.mkv",
|
|
|
|
"Harry Potter and the Deathly Hallows part4.mkv",
|
|
|
|
"Batman-deleted.mkv",
|
|
|
|
"Batman-sample.mkv",
|
|
|
|
"Batman-trailer.mkv",
|
|
|
|
"Batman part1.mkv",
|
|
|
|
"Batman part2.mkv",
|
|
|
|
"Batman part3.mkv",
|
|
|
|
"Avengers.mkv",
|
|
|
|
"Avengers-trailer.mkv",
|
|
|
|
|
|
|
|
// Despite having a keyword in the name that will return an ExtraType, there's no original video to match it to
|
|
|
|
// So this is just a standalone video
|
|
|
|
"trailer.mkv",
|
|
|
|
|
|
|
|
// Same as above
|
|
|
|
"WillyWonka-trailer.mkv"
|
|
|
|
};
|
|
|
|
|
2021-05-23 22:30:41 +00:00
|
|
|
var result = VideoListResolver.Resolve(
|
2021-12-20 11:15:20 +00:00
|
|
|
files.Select(i => VideoResolver.Resolve(i, false, _namingOptions)).OfType<VideoFileInfo>().ToList(),
|
2021-05-23 22:30:41 +00:00
|
|
|
_namingOptions).ToList();
|
2019-12-06 19:40:06 +00:00
|
|
|
|
2021-12-07 14:18:17 +00:00
|
|
|
Assert.Equal(11, result.Count);
|
2021-02-17 09:38:44 +00:00
|
|
|
var batman = result.FirstOrDefault(x => string.Equals(x.Name, "Batman", StringComparison.Ordinal));
|
|
|
|
Assert.NotNull(batman);
|
|
|
|
Assert.Equal(3, batman!.Files.Count);
|
|
|
|
|
|
|
|
var harry = result.FirstOrDefault(x => string.Equals(x.Name, "Harry Potter and the Deathly Hallows", StringComparison.Ordinal));
|
|
|
|
Assert.NotNull(harry);
|
|
|
|
Assert.Equal(4, harry!.Files.Count);
|
2021-12-07 14:18:17 +00:00
|
|
|
|
|
|
|
Assert.False(result[2].ExtraType.HasValue);
|
|
|
|
|
|
|
|
Assert.Equal(ExtraType.Trailer, result[3].ExtraType);
|
|
|
|
Assert.Equal(ExtraType.Trailer, result[4].ExtraType);
|
|
|
|
Assert.Equal(ExtraType.DeletedScene, result[5].ExtraType);
|
|
|
|
Assert.Equal(ExtraType.Sample, result[6].ExtraType);
|
|
|
|
Assert.Equal(ExtraType.Trailer, result[7].ExtraType);
|
|
|
|
Assert.Equal(ExtraType.Trailer, result[8].ExtraType);
|
|
|
|
Assert.Equal(ExtraType.Trailer, result[9].ExtraType);
|
|
|
|
Assert.Equal(ExtraType.Trailer, result[10].ExtraType);
|
2019-12-06 19:40:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void TestWithMetadata()
|
|
|
|
{
|
|
|
|
var files = new[]
|
|
|
|
{
|
|
|
|
"300.mkv",
|
|
|
|
"300.nfo"
|
|
|
|
};
|
|
|
|
|
2021-05-23 22:30:41 +00:00
|
|
|
var result = VideoListResolver.Resolve(
|
2021-12-20 11:15:20 +00:00
|
|
|
files.Select(i => VideoResolver.Resolve(i, false, _namingOptions)).OfType<VideoFileInfo>().ToList(),
|
2021-05-23 22:30:41 +00:00
|
|
|
_namingOptions).ToList();
|
2019-12-06 19:40:06 +00:00
|
|
|
|
|
|
|
Assert.Single(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void TestWithExtra()
|
|
|
|
{
|
|
|
|
var files = new[]
|
|
|
|
{
|
|
|
|
"300.mkv",
|
|
|
|
"300 trailer.mkv"
|
|
|
|
};
|
|
|
|
|
2021-05-23 22:30:41 +00:00
|
|
|
var result = VideoListResolver.Resolve(
|
2021-12-20 11:15:20 +00:00
|
|
|
files.Select(i => VideoResolver.Resolve(i, false, _namingOptions)).OfType<VideoFileInfo>().ToList(),
|
2021-05-23 22:30:41 +00:00
|
|
|
_namingOptions).ToList();
|
2019-12-06 19:40:06 +00:00
|
|
|
|
2021-12-07 18:23:30 +00:00
|
|
|
Assert.Equal(2, result.Count);
|
2021-12-07 14:18:17 +00:00
|
|
|
Assert.False(result[0].ExtraType.HasValue);
|
|
|
|
Assert.Equal(ExtraType.Trailer, result[1].ExtraType);
|
2019-12-06 19:40:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void TestVariationWithFolderName()
|
|
|
|
{
|
|
|
|
var files = new[]
|
|
|
|
{
|
|
|
|
"X-Men Days of Future Past - 1080p.mkv",
|
|
|
|
"X-Men Days of Future Past-trailer.mp4"
|
|
|
|
};
|
|
|
|
|
2021-05-23 22:30:41 +00:00
|
|
|
var result = VideoListResolver.Resolve(
|
2021-12-20 11:15:20 +00:00
|
|
|
files.Select(i => VideoResolver.Resolve(i, false, _namingOptions)).OfType<VideoFileInfo>().ToList(),
|
2021-05-23 22:30:41 +00:00
|
|
|
_namingOptions).ToList();
|
2019-12-06 19:40:06 +00:00
|
|
|
|
2021-12-07 18:23:30 +00:00
|
|
|
Assert.Equal(2, result.Count);
|
2021-12-07 14:18:17 +00:00
|
|
|
Assert.False(result[0].ExtraType.HasValue);
|
|
|
|
Assert.Equal(ExtraType.Trailer, result[1].ExtraType);
|
2019-12-06 19:40:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void TestTrailer2()
|
|
|
|
{
|
|
|
|
var files = new[]
|
|
|
|
{
|
|
|
|
"X-Men Days of Future Past - 1080p.mkv",
|
|
|
|
"X-Men Days of Future Past-trailer.mp4",
|
|
|
|
"X-Men Days of Future Past-trailer2.mp4"
|
|
|
|
};
|
|
|
|
|
2021-05-23 22:30:41 +00:00
|
|
|
var result = VideoListResolver.Resolve(
|
2021-12-20 11:15:20 +00:00
|
|
|
files.Select(i => VideoResolver.Resolve(i, false, _namingOptions)).OfType<VideoFileInfo>().ToList(),
|
2021-05-23 22:30:41 +00:00
|
|
|
_namingOptions).ToList();
|
2019-12-06 19:40:06 +00:00
|
|
|
|
2021-12-07 18:23:30 +00:00
|
|
|
Assert.Equal(3, result.Count);
|
2021-12-07 14:18:17 +00:00
|
|
|
Assert.False(result[0].ExtraType.HasValue);
|
|
|
|
Assert.Equal(ExtraType.Trailer, result[1].ExtraType);
|
|
|
|
Assert.Equal(ExtraType.Trailer, result[2].ExtraType);
|
2019-12-06 19:40:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
2021-12-07 14:18:17 +00:00
|
|
|
public void Resolve_SameNameAndYear_ReturnsSingleItem()
|
2019-12-06 19:40:06 +00:00
|
|
|
{
|
|
|
|
var files = new[]
|
|
|
|
{
|
|
|
|
"Looper (2012)-trailer.mkv",
|
2021-12-07 14:18:17 +00:00
|
|
|
"Looper 2012-trailer.mkv",
|
2019-12-06 19:40:06 +00:00
|
|
|
"Looper.2012.bluray.720p.x264.mkv"
|
|
|
|
};
|
|
|
|
|
2021-05-23 22:30:41 +00:00
|
|
|
var result = VideoListResolver.Resolve(
|
2021-12-20 11:15:20 +00:00
|
|
|
files.Select(i => VideoResolver.Resolve(i, false, _namingOptions)).OfType<VideoFileInfo>().ToList(),
|
2021-05-23 22:30:41 +00:00
|
|
|
_namingOptions).ToList();
|
2019-12-06 19:40:06 +00:00
|
|
|
|
2021-12-07 18:23:30 +00:00
|
|
|
Assert.Equal(3, result.Count);
|
2021-12-07 14:18:17 +00:00
|
|
|
Assert.False(result[0].ExtraType.HasValue);
|
|
|
|
Assert.Equal(ExtraType.Trailer, result[1].ExtraType);
|
|
|
|
Assert.Equal(ExtraType.Trailer, result[2].ExtraType);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void Resolve_TrailerMatchesFolderName_ReturnsSingleItem()
|
|
|
|
{
|
|
|
|
var files = new[]
|
|
|
|
{
|
|
|
|
"/movies/Looper (2012)/Looper (2012)-trailer.mkv",
|
|
|
|
"/movies/Looper (2012)/Looper.bluray.720p.x264.mkv"
|
|
|
|
};
|
|
|
|
|
|
|
|
var result = VideoListResolver.Resolve(
|
2021-12-20 11:15:20 +00:00
|
|
|
files.Select(i => VideoResolver.Resolve(i, false, _namingOptions)).OfType<VideoFileInfo>().ToList(),
|
2021-12-07 14:18:17 +00:00
|
|
|
_namingOptions).ToList();
|
|
|
|
|
2021-12-07 18:23:30 +00:00
|
|
|
Assert.Equal(2, result.Count);
|
2021-12-07 14:18:17 +00:00
|
|
|
Assert.False(result[0].ExtraType.HasValue);
|
|
|
|
Assert.Equal(ExtraType.Trailer, result[1].ExtraType);
|
2019-12-06 19:40:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void TestSeparateFiles()
|
|
|
|
{
|
|
|
|
// These should be considered separate, unrelated videos
|
|
|
|
var files = new[]
|
|
|
|
{
|
|
|
|
"My video 1.mkv",
|
|
|
|
"My video 2.mkv",
|
|
|
|
"My video 3.mkv",
|
|
|
|
"My video 4.mkv",
|
|
|
|
"My video 5.mkv"
|
|
|
|
};
|
|
|
|
|
2021-05-23 22:30:41 +00:00
|
|
|
var result = VideoListResolver.Resolve(
|
2021-12-20 11:15:20 +00:00
|
|
|
files.Select(i => VideoResolver.Resolve(i, false, _namingOptions)).OfType<VideoFileInfo>().ToList(),
|
2021-05-23 22:30:41 +00:00
|
|
|
_namingOptions).ToList();
|
2019-12-06 19:40:06 +00:00
|
|
|
|
|
|
|
Assert.Equal(5, result.Count);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void TestMultiDisc()
|
|
|
|
{
|
|
|
|
var files = new[]
|
|
|
|
{
|
2023-10-07 22:15:38 +00:00
|
|
|
"M:/Movies (DVD)/Movies (Musical)/Sound of Music (1965)/Sound of Music Disc 1",
|
|
|
|
"M:/Movies (DVD)/Movies (Musical)/Sound of Music (1965)/Sound of Music Disc 2"
|
2019-12-06 19:40:06 +00:00
|
|
|
};
|
|
|
|
|
2021-05-23 22:30:41 +00:00
|
|
|
var result = VideoListResolver.Resolve(
|
2021-12-20 11:15:20 +00:00
|
|
|
files.Select(i => VideoResolver.Resolve(i, true, _namingOptions)).OfType<VideoFileInfo>().ToList(),
|
2021-05-23 22:30:41 +00:00
|
|
|
_namingOptions).ToList();
|
2019-12-06 19:40:06 +00:00
|
|
|
|
|
|
|
Assert.Single(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void TestPoundSign()
|
|
|
|
{
|
|
|
|
// These should be considered separate, unrelated videos
|
|
|
|
var files = new[]
|
|
|
|
{
|
2023-10-07 22:15:38 +00:00
|
|
|
"My movie #1.mp4",
|
|
|
|
"My movie #2.mp4"
|
2019-12-06 19:40:06 +00:00
|
|
|
};
|
|
|
|
|
2021-05-23 22:30:41 +00:00
|
|
|
var result = VideoListResolver.Resolve(
|
2021-12-20 11:15:20 +00:00
|
|
|
files.Select(i => VideoResolver.Resolve(i, true, _namingOptions)).OfType<VideoFileInfo>().ToList(),
|
2021-05-23 22:30:41 +00:00
|
|
|
_namingOptions).ToList();
|
2019-12-06 19:40:06 +00:00
|
|
|
|
|
|
|
Assert.Equal(2, result.Count);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void TestStackedWithTrailer()
|
|
|
|
{
|
|
|
|
var files = new[]
|
|
|
|
{
|
2023-10-07 22:15:38 +00:00
|
|
|
"No (2012) part1.mp4",
|
|
|
|
"No (2012) part2.mp4",
|
|
|
|
"No (2012) part1-trailer.mp4",
|
|
|
|
"No (2012)-trailer.mp4"
|
2019-12-06 19:40:06 +00:00
|
|
|
};
|
|
|
|
|
2021-05-23 22:30:41 +00:00
|
|
|
var result = VideoListResolver.Resolve(
|
2021-12-20 11:15:20 +00:00
|
|
|
files.Select(i => VideoResolver.Resolve(i, false, _namingOptions)).OfType<VideoFileInfo>().ToList(),
|
2021-05-23 22:30:41 +00:00
|
|
|
_namingOptions).ToList();
|
2019-12-06 19:40:06 +00:00
|
|
|
|
2021-12-07 14:18:17 +00:00
|
|
|
Assert.Equal(3, result.Count);
|
|
|
|
Assert.False(result[0].ExtraType.HasValue);
|
|
|
|
Assert.Equal(ExtraType.Trailer, result[1].ExtraType);
|
|
|
|
Assert.Equal(ExtraType.Trailer, result[2].ExtraType);
|
2019-12-06 19:40:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void TestExtrasByFolderName()
|
|
|
|
{
|
|
|
|
var files = new[]
|
|
|
|
{
|
2023-10-07 22:15:38 +00:00
|
|
|
"/Movies/Top Gun (1984)/movie.mp4",
|
|
|
|
"/Movies/Top Gun (1984)/Top Gun (1984)-trailer.mp4",
|
|
|
|
"/Movies/Top Gun (1984)/Top Gun (1984)-trailer2.mp4",
|
|
|
|
"/Movies/trailer.mp4"
|
2019-12-06 19:40:06 +00:00
|
|
|
};
|
|
|
|
|
2021-05-23 22:30:41 +00:00
|
|
|
var result = VideoListResolver.Resolve(
|
2021-12-20 11:15:20 +00:00
|
|
|
files.Select(i => VideoResolver.Resolve(i, false, _namingOptions)).OfType<VideoFileInfo>().ToList(),
|
2021-05-23 22:30:41 +00:00
|
|
|
_namingOptions).ToList();
|
2019-12-06 19:40:06 +00:00
|
|
|
|
2021-12-07 18:23:30 +00:00
|
|
|
Assert.Equal(4, result.Count);
|
2021-12-07 14:18:17 +00:00
|
|
|
Assert.False(result[0].ExtraType.HasValue);
|
|
|
|
Assert.Equal(ExtraType.Trailer, result[1].ExtraType);
|
|
|
|
Assert.Equal(ExtraType.Trailer, result[2].ExtraType);
|
|
|
|
Assert.Equal(ExtraType.Trailer, result[3].ExtraType);
|
2019-12-06 19:40:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void TestDoubleTags()
|
|
|
|
{
|
|
|
|
var files = new[]
|
|
|
|
{
|
2023-10-07 22:15:38 +00:00
|
|
|
"/MCFAMILY-PC/Private3$/Heterosexual/Breast In Class 2 Counterfeit Racks (2011)/Breast In Class 2 Counterfeit Racks (2011) Disc 1 cd1.avi",
|
|
|
|
"/MCFAMILY-PC/Private3$/Heterosexual/Breast In Class 2 Counterfeit Racks (2011)/Breast In Class 2 Counterfeit Racks (2011) Disc 1 cd2.avi",
|
|
|
|
"/MCFAMILY-PC/Private3$/Heterosexual/Breast In Class 2 Counterfeit Racks (2011)/Breast In Class 2 Disc 2 cd1.avi",
|
|
|
|
"/MCFAMILY-PC/Private3$/Heterosexual/Breast In Class 2 Counterfeit Racks (2011)/Breast In Class 2 Disc 2 cd2.avi"
|
2019-12-06 19:40:06 +00:00
|
|
|
};
|
|
|
|
|
2021-05-23 22:30:41 +00:00
|
|
|
var result = VideoListResolver.Resolve(
|
2021-12-20 11:15:20 +00:00
|
|
|
files.Select(i => VideoResolver.Resolve(i, false, _namingOptions)).OfType<VideoFileInfo>().ToList(),
|
2021-05-23 22:30:41 +00:00
|
|
|
_namingOptions).ToList();
|
2019-12-06 19:40:06 +00:00
|
|
|
|
|
|
|
Assert.Equal(2, result.Count);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void TestArgumentOutOfRangeException()
|
|
|
|
{
|
|
|
|
var files = new[]
|
|
|
|
{
|
2023-10-07 22:15:38 +00:00
|
|
|
"/nas-markrobbo78/Videos/INDEX HTPC/Movies/Watched/3 - ACTION/Argo (2012)/movie.mkv"
|
2019-12-06 19:40:06 +00:00
|
|
|
};
|
|
|
|
|
2021-05-23 22:30:41 +00:00
|
|
|
var result = VideoListResolver.Resolve(
|
2021-12-20 11:15:20 +00:00
|
|
|
files.Select(i => VideoResolver.Resolve(i, false, _namingOptions)).OfType<VideoFileInfo>().ToList(),
|
2021-05-23 22:30:41 +00:00
|
|
|
_namingOptions).ToList();
|
2019-12-06 19:40:06 +00:00
|
|
|
|
|
|
|
Assert.Single(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void TestColony()
|
|
|
|
{
|
|
|
|
var files = new[]
|
|
|
|
{
|
2023-10-07 22:15:38 +00:00
|
|
|
"The Colony.mkv"
|
2019-12-06 19:40:06 +00:00
|
|
|
};
|
|
|
|
|
2021-05-23 22:30:41 +00:00
|
|
|
var result = VideoListResolver.Resolve(
|
2021-12-20 11:15:20 +00:00
|
|
|
files.Select(i => VideoResolver.Resolve(i, false, _namingOptions)).OfType<VideoFileInfo>().ToList(),
|
2021-05-23 22:30:41 +00:00
|
|
|
_namingOptions).ToList();
|
2019-12-06 19:40:06 +00:00
|
|
|
|
|
|
|
Assert.Single(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void TestFourSisters()
|
|
|
|
{
|
|
|
|
var files = new[]
|
|
|
|
{
|
2023-10-07 22:15:38 +00:00
|
|
|
"Four Sisters and a Wedding - A.avi",
|
|
|
|
"Four Sisters and a Wedding - B.avi"
|
2019-12-06 19:40:06 +00:00
|
|
|
};
|
|
|
|
|
2021-05-23 22:30:41 +00:00
|
|
|
var result = VideoListResolver.Resolve(
|
2021-12-20 11:15:20 +00:00
|
|
|
files.Select(i => VideoResolver.Resolve(i, false, _namingOptions)).OfType<VideoFileInfo>().ToList(),
|
2021-05-23 22:30:41 +00:00
|
|
|
_namingOptions).ToList();
|
2019-12-06 19:40:06 +00:00
|
|
|
|
2023-03-15 12:01:39 +00:00
|
|
|
// The result should contain two individual movies
|
2023-03-15 10:56:11 +00:00
|
|
|
// Version grouping should not work here, because the files are not in a directory with the name 'Four Sisters and a Wedding'
|
|
|
|
Assert.Equal(2, result.Count);
|
2019-12-06 19:40:06 +00:00
|
|
|
}
|
|
|
|
|
2020-11-05 15:59:15 +00:00
|
|
|
[Fact]
|
|
|
|
public void TestFourRooms()
|
|
|
|
{
|
|
|
|
var files = new[]
|
|
|
|
{
|
2023-10-07 22:15:38 +00:00
|
|
|
"Four Rooms - A.avi",
|
|
|
|
"Four Rooms - A.mp4"
|
2020-11-05 15:59:15 +00:00
|
|
|
};
|
|
|
|
|
2021-05-23 22:30:41 +00:00
|
|
|
var result = VideoListResolver.Resolve(
|
2021-12-20 11:15:20 +00:00
|
|
|
files.Select(i => VideoResolver.Resolve(i, false, _namingOptions)).OfType<VideoFileInfo>().ToList(),
|
2021-05-23 22:30:41 +00:00
|
|
|
_namingOptions).ToList();
|
2020-11-05 15:59:15 +00:00
|
|
|
|
|
|
|
Assert.Equal(2, result.Count);
|
|
|
|
}
|
|
|
|
|
2019-12-06 19:40:06 +00:00
|
|
|
[Fact]
|
|
|
|
public void TestMovieTrailer()
|
|
|
|
{
|
|
|
|
var files = new[]
|
|
|
|
{
|
2023-10-07 22:15:38 +00:00
|
|
|
"/Server/Despicable Me/Despicable Me (2010).mkv",
|
|
|
|
"/Server/Despicable Me/trailer.mkv"
|
2019-12-06 19:40:06 +00:00
|
|
|
};
|
|
|
|
|
2021-05-23 22:30:41 +00:00
|
|
|
var result = VideoListResolver.Resolve(
|
2021-12-20 11:15:20 +00:00
|
|
|
files.Select(i => VideoResolver.Resolve(i, false, _namingOptions)).OfType<VideoFileInfo>().ToList(),
|
2021-05-23 22:30:41 +00:00
|
|
|
_namingOptions).ToList();
|
2019-12-06 19:40:06 +00:00
|
|
|
|
2021-12-07 18:23:30 +00:00
|
|
|
Assert.Equal(2, result.Count);
|
2021-12-07 14:18:17 +00:00
|
|
|
Assert.False(result[0].ExtraType.HasValue);
|
|
|
|
Assert.Equal(ExtraType.Trailer, result[1].ExtraType);
|
2019-12-06 19:40:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
2021-12-07 14:18:17 +00:00
|
|
|
public void Resolve_TrailerInTrailersFolder_ReturnsCorrectExtraType()
|
2019-12-06 19:40:06 +00:00
|
|
|
{
|
|
|
|
var files = new[]
|
|
|
|
{
|
2023-10-07 22:15:38 +00:00
|
|
|
"/Server/Despicable Me/Despicable Me (2010).mkv",
|
|
|
|
"/Server/Despicable Me/trailers/some title.mkv"
|
2019-12-06 19:40:06 +00:00
|
|
|
};
|
|
|
|
|
2021-05-23 22:30:41 +00:00
|
|
|
var result = VideoListResolver.Resolve(
|
2021-12-20 11:15:20 +00:00
|
|
|
files.Select(i => VideoResolver.Resolve(i, false, _namingOptions)).OfType<VideoFileInfo>().ToList(),
|
2021-05-23 22:30:41 +00:00
|
|
|
_namingOptions).ToList();
|
2019-12-06 19:40:06 +00:00
|
|
|
|
2021-12-07 18:23:30 +00:00
|
|
|
Assert.Equal(2, result.Count);
|
2021-12-07 14:18:17 +00:00
|
|
|
Assert.False(result[0].ExtraType.HasValue);
|
|
|
|
Assert.Equal(ExtraType.Trailer, result[1].ExtraType);
|
2019-12-06 19:40:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void TestSubfolders()
|
|
|
|
{
|
|
|
|
var files = new[]
|
|
|
|
{
|
2023-10-07 22:15:38 +00:00
|
|
|
"/Movies/Despicable Me/Despicable Me.mkv",
|
|
|
|
"/Movies/Despicable Me/trailers/trailer.mkv"
|
2019-12-06 19:40:06 +00:00
|
|
|
};
|
|
|
|
|
2021-05-23 22:30:41 +00:00
|
|
|
var result = VideoListResolver.Resolve(
|
2021-12-20 11:15:20 +00:00
|
|
|
files.Select(i => VideoResolver.Resolve(i, false, _namingOptions)).OfType<VideoFileInfo>().ToList(),
|
2021-05-23 22:30:41 +00:00
|
|
|
_namingOptions).ToList();
|
2019-12-06 19:40:06 +00:00
|
|
|
|
2021-12-07 18:23:30 +00:00
|
|
|
Assert.Equal(2, result.Count);
|
2021-12-07 14:18:17 +00:00
|
|
|
Assert.False(result[0].ExtraType.HasValue);
|
|
|
|
Assert.Equal(ExtraType.Trailer, result[1].ExtraType);
|
2019-12-06 19:40:06 +00:00
|
|
|
}
|
|
|
|
|
2020-11-05 15:59:15 +00:00
|
|
|
[Fact]
|
|
|
|
public void TestDirectoryStack()
|
|
|
|
{
|
2021-12-10 13:23:31 +00:00
|
|
|
var stack = new FileStack(string.Empty, false, Array.Empty<string>());
|
2020-11-05 15:59:15 +00:00
|
|
|
Assert.False(stack.ContainsFile("XX", true));
|
|
|
|
}
|
2019-12-06 19:40:06 +00:00
|
|
|
}
|
|
|
|
}
|