aboutsummaryrefslogtreecommitdiff
path: root/tests/Jellyfin.Controller.Tests/MediaEncoding/EncodingHelperInferAudioCodecTests.cs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Jellyfin.Controller.Tests/MediaEncoding/EncodingHelperInferAudioCodecTests.cs')
-rw-r--r--tests/Jellyfin.Controller.Tests/MediaEncoding/EncodingHelperInferAudioCodecTests.cs40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/Jellyfin.Controller.Tests/MediaEncoding/EncodingHelperInferAudioCodecTests.cs b/tests/Jellyfin.Controller.Tests/MediaEncoding/EncodingHelperInferAudioCodecTests.cs
new file mode 100644
index 0000000000..586db2dd50
--- /dev/null
+++ b/tests/Jellyfin.Controller.Tests/MediaEncoding/EncodingHelperInferAudioCodecTests.cs
@@ -0,0 +1,40 @@
+using MediaBrowser.Common.Configuration;
+using MediaBrowser.Controller.IO;
+using MediaBrowser.Controller.MediaEncoding;
+using Moq;
+using Xunit;
+using IConfiguration = Microsoft.Extensions.Configuration.IConfiguration;
+
+namespace Jellyfin.Controller.Tests.MediaEncoding;
+
+public class EncodingHelperInferAudioCodecTests
+{
+ [Theory]
+ // Manifests and other containers that carry no inferable audio codec.
+ [InlineData("m3u8", "aac")]
+ [InlineData("mpd", "aac")]
+ [InlineData("wtv", "aac")]
+ [InlineData("", "aac")]
+ // Containers with a well known audio codec.
+ [InlineData("mp4", "aac")]
+ [InlineData("mkv", "aac")]
+ [InlineData("webm", "opus")]
+ [InlineData("ts", "mp3")]
+ // Containers named after the codec they carry.
+ [InlineData("flac", "flac")]
+ [InlineData("opus", "opus")]
+ [InlineData("ac3", "ac3")]
+ public void InferAudioCodec_ReturnsAnAudioCodec(string container, string expected)
+ {
+ Assert.Equal(expected, Create().InferAudioCodec(container));
+ }
+
+ private static EncodingHelper Create()
+ => new(
+ Mock.Of<IApplicationPaths>(),
+ Mock.Of<IMediaEncoder>(),
+ Mock.Of<ISubtitleEncoder>(),
+ Mock.Of<IConfiguration>(),
+ Mock.Of<IConfigurationManager>(),
+ Mock.Of<IPathManager>());
+}