aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBond_009 <bond.009@outlook.com>2023-08-22 18:09:31 +0200
committerBond_009 <bond.009@outlook.com>2023-08-22 18:11:34 +0200
commitd92e9ae85e41fef981729f544bfd6df2c052a712 (patch)
tree9240510786df6f20e4570f6afc67456a15da0f80 /tests
parent84643e328df6b194eb4de893b8b5e232af5e2a0c (diff)
Enable nullable for more files and add tests
Adds basic tests for FFProbeVideoInfo.CreateDummyChapters Fixed error message CreateDummyChapters instead of reporting the total minutes it only reported the minute component
Diffstat (limited to 'tests')
-rw-r--r--tests/Jellyfin.Providers.Tests/Jellyfin.Providers.Tests.csproj3
-rw-r--r--tests/Jellyfin.Providers.Tests/MediaInfo/FFProbeVideoInfoTests.cs61
2 files changed, 64 insertions, 0 deletions
diff --git a/tests/Jellyfin.Providers.Tests/Jellyfin.Providers.Tests.csproj b/tests/Jellyfin.Providers.Tests/Jellyfin.Providers.Tests.csproj
index c12f0cd68..1263043a5 100644
--- a/tests/Jellyfin.Providers.Tests/Jellyfin.Providers.Tests.csproj
+++ b/tests/Jellyfin.Providers.Tests/Jellyfin.Providers.Tests.csproj
@@ -7,6 +7,9 @@
</ItemGroup>
<ItemGroup>
+ <PackageReference Include="AutoFixture" />
+ <PackageReference Include="AutoFixture.AutoMoq" />
+ <PackageReference Include="AutoFixture.Xunit2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Moq" />
<PackageReference Include="xunit" />
diff --git a/tests/Jellyfin.Providers.Tests/MediaInfo/FFProbeVideoInfoTests.cs b/tests/Jellyfin.Providers.Tests/MediaInfo/FFProbeVideoInfoTests.cs
new file mode 100644
index 000000000..76922af8d
--- /dev/null
+++ b/tests/Jellyfin.Providers.Tests/MediaInfo/FFProbeVideoInfoTests.cs
@@ -0,0 +1,61 @@
+using System;
+using AutoFixture;
+using AutoFixture.AutoMoq;
+using MediaBrowser.Controller.Configuration;
+using MediaBrowser.Controller.Entities;
+using MediaBrowser.Model.Configuration;
+using MediaBrowser.Providers.MediaInfo;
+using Moq;
+using Xunit;
+
+namespace Jellyfin.Providers.Tests.MediaInfo;
+
+public class FFProbeVideoInfoTests
+{
+ private readonly FFProbeVideoInfo _fFProbeVideoInfo;
+
+ public FFProbeVideoInfoTests()
+ {
+ var serverConfiguration = new ServerConfiguration()
+ {
+ DummyChapterDuration = (int)TimeSpan.FromMinutes(5).TotalSeconds
+ };
+ var serverConfig = new Mock<IServerConfigurationManager>();
+ serverConfig.Setup(c => c.Configuration)
+ .Returns(serverConfiguration);
+
+ IFixture fixture = new Fixture().Customize(new AutoMoqCustomization { ConfigureMembers = true });
+ fixture.Inject(serverConfig);
+ _fFProbeVideoInfo = fixture.Create<FFProbeVideoInfo>();
+ }
+
+ [Theory]
+ [InlineData(-1L)]
+ [InlineData(long.MinValue)]
+ [InlineData(long.MaxValue)]
+ public void CreateDummyChapters_InvalidRuntime_ThrowsArgumentException(long? runtime)
+ {
+ Assert.Throws<ArgumentException>(
+ () => _fFProbeVideoInfo.CreateDummyChapters(new Video()
+ {
+ RunTimeTicks = runtime
+ }));
+ }
+
+ [Theory]
+ [InlineData(null, 0)]
+ [InlineData(0L, 0)]
+ [InlineData(1L, 0)]
+ [InlineData(TimeSpan.TicksPerMinute * 5, 0)]
+ [InlineData((TimeSpan.TicksPerMinute * 5) + 1, 1)]
+ [InlineData(TimeSpan.TicksPerMinute * 50, 10)]
+ public void CreateDummyChapters_ValidRuntime_CorrectChaptersCount(long? runtime, int chaptersCount)
+ {
+ var chapters = _fFProbeVideoInfo.CreateDummyChapters(new Video()
+ {
+ RunTimeTicks = runtime
+ });
+
+ Assert.Equal(chaptersCount, chapters.Length);
+ }
+}