aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBond-009 <bond.009@outlook.com>2023-08-26 17:28:34 +0200
committerGitHub <noreply@github.com>2023-08-26 17:28:34 +0200
commit9ae429b6f64531a2f063a04d0fdd31cceb16a9b5 (patch)
treeaf2dce1e454665f90ea69ef3c752680db73d2be7 /tests
parent3ee1141a06d41ac080cd5fd6b2253e1ed23d675e (diff)
parent18a311d32fd6e3cdfed466017bda46566a013106 (diff)
Merge pull request #10141 from Bond-009/nullable3
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);
+ }
+}