aboutsummaryrefslogtreecommitdiff
path: root/tests/Jellyfin.MediaEncoding.Hls.Tests
diff options
context:
space:
mode:
authorcvium <clausvium@gmail.com>2021-09-25 11:17:16 +0200
committercvium <clausvium@gmail.com>2021-09-25 11:17:16 +0200
commitc7b25a9fe466083a761dc768169e09f68313f862 (patch)
tree0ed4152e8726c29279731e010cccdf89b2afc889 /tests/Jellyfin.MediaEncoding.Hls.Tests
parentfa38b741ce2b3438f5ae29273b423bd7fe2b25f6 (diff)
Add first test
Diffstat (limited to 'tests/Jellyfin.MediaEncoding.Hls.Tests')
-rw-r--r--tests/Jellyfin.MediaEncoding.Hls.Tests/Jellyfin.MediaEncoding.Hls.Tests.csproj32
-rw-r--r--tests/Jellyfin.MediaEncoding.Hls.Tests/Playlist/DynamicHlsPlaylistGeneratorTests.cs25
2 files changed, 57 insertions, 0 deletions
diff --git a/tests/Jellyfin.MediaEncoding.Hls.Tests/Jellyfin.MediaEncoding.Hls.Tests.csproj b/tests/Jellyfin.MediaEncoding.Hls.Tests/Jellyfin.MediaEncoding.Hls.Tests.csproj
new file mode 100644
index 000000000..1b53d670f
--- /dev/null
+++ b/tests/Jellyfin.MediaEncoding.Hls.Tests/Jellyfin.MediaEncoding.Hls.Tests.csproj
@@ -0,0 +1,32 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <TargetFramework>net5.0</TargetFramework>
+ <IsPackable>false</IsPackable>
+ <CodeAnalysisRuleSet>../jellyfin-tests.ruleset</CodeAnalysisRuleSet>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
+ <PackageReference Include="xunit" Version="2.4.1" />
+ <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
+ <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
+ <PrivateAssets>all</PrivateAssets>
+ </PackageReference>
+ <PackageReference Include="coverlet.collector" Version="3.0.2">
+ <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
+ <PrivateAssets>all</PrivateAssets>
+ </PackageReference>
+ </ItemGroup>
+
+ <!-- Code Analyzers -->
+ <ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
+ <PackageReference Include="SerilogAnalyzer" Version="0.15.0" PrivateAssets="All" />
+ <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="All" />
+ <PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" PrivateAssets="All" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\src\Jellyfin.MediaEncoding.Hls\Jellyfin.MediaEncoding.Hls.csproj" />
+ </ItemGroup>
+
+</Project>
diff --git a/tests/Jellyfin.MediaEncoding.Hls.Tests/Playlist/DynamicHlsPlaylistGeneratorTests.cs b/tests/Jellyfin.MediaEncoding.Hls.Tests/Playlist/DynamicHlsPlaylistGeneratorTests.cs
new file mode 100644
index 000000000..c55b7e304
--- /dev/null
+++ b/tests/Jellyfin.MediaEncoding.Hls.Tests/Playlist/DynamicHlsPlaylistGeneratorTests.cs
@@ -0,0 +1,25 @@
+using Jellyfin.MediaEncoding.Hls.Playlist;
+using Xunit;
+
+namespace Jellyfin.MediaEncoding.Hls.Tests.Playlist
+{
+ public class DynamicHlsPlaylistGeneratorTests
+ {
+ [Theory]
+ [InlineData("testfile.mkv", new string[0], false)]
+ [InlineData("testfile.flv", new[] { "mp4", "mkv", "ts" }, false)]
+ [InlineData("testfile.flv", new[] { "mp4", "mkv", "ts", "flv" }, true)]
+ [InlineData("/some/arbitrarily/long/path/testfile.mkv", new[] { "mkv" }, true)]
+ public void IsExtractionAllowedForFile_Valid_Success(string filePath, string[] allowedExtensions, bool isAllowed)
+ {
+ Assert.Equal(isAllowed, DynamicHlsPlaylistGenerator.IsExtractionAllowedForFile(filePath, allowedExtensions));
+ }
+
+ [Theory]
+ [InlineData("testfile", new[] { "mp4" })]
+ public void IsExtractionAllowedForFile_Invalid_ReturnsFalse(string filePath, string[] allowedExtensions)
+ {
+ Assert.False(DynamicHlsPlaylistGenerator.IsExtractionAllowedForFile(filePath, allowedExtensions));
+ }
+ }
+}