aboutsummaryrefslogtreecommitdiff
path: root/tests/Jellyfin.MediaEncoding.Tests/EncoderValidatorTests.cs
diff options
context:
space:
mode:
authorBond_009 <bond.009@outlook.com>2019-09-28 01:29:54 +0200
committerBond_009 <bond.009@outlook.com>2019-09-28 19:41:34 +0200
commit1b01a6ece1c60ed5b767f825265de17f78a2770a (patch)
tree1469c0b183bdedf892f8e61a425f97ab8c51b342 /tests/Jellyfin.MediaEncoding.Tests/EncoderValidatorTests.cs
parente4d5e5bf91ca3129b4701463ed5c6bdce5b2115b (diff)
Add tests for EncoderValidator
* Add support for ffmpeg 4.2 * Parse the complete ffmpeg version instead of only the first 2 digits * Make max and min version optional * Remove max limitation (for now) * Style improvements
Diffstat (limited to 'tests/Jellyfin.MediaEncoding.Tests/EncoderValidatorTests.cs')
-rw-r--r--tests/Jellyfin.MediaEncoding.Tests/EncoderValidatorTests.cs39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/Jellyfin.MediaEncoding.Tests/EncoderValidatorTests.cs b/tests/Jellyfin.MediaEncoding.Tests/EncoderValidatorTests.cs
new file mode 100644
index 000000000..9fa1e4f7e
--- /dev/null
+++ b/tests/Jellyfin.MediaEncoding.Tests/EncoderValidatorTests.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using MediaBrowser.MediaEncoding.Encoder;
+using Microsoft.Extensions.Logging.Abstractions;
+using Xunit;
+
+namespace Jellyfin.MediaEncoding.Tests
+{
+ public class EncoderValidatorTests
+ {
+ private class GetFFmpegVersionTestData : IEnumerable<object[]>
+ {
+ public IEnumerator<object[]> GetEnumerator()
+ {
+ yield return new object[] { EncoderValidatorTestsData.FFmpegV42Output, new Version(4, 2) };
+ yield return new object[] { EncoderValidatorTestsData.FFmpegV404Output, new Version(4, 0, 4) };
+ }
+
+ IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
+ }
+
+ [Theory]
+ [ClassData(typeof(GetFFmpegVersionTestData))]
+ public void GetFFmpegVersionTest(string versionOutput, Version version)
+ {
+ Assert.Equal(version, EncoderValidator.GetFFmpegVersion(versionOutput));
+ }
+
+ [Theory]
+ [InlineData(EncoderValidatorTestsData.FFmpegV42Output, true)]
+ [InlineData(EncoderValidatorTestsData.FFmpegV404Output, true)]
+ public void ValidateVersionInternalTest(string versionOutput, bool valid)
+ {
+ var val = new EncoderValidator(new NullLogger<EncoderValidatorTests>());
+ Assert.Equal(valid, val.ValidateVersionInternal(versionOutput));
+ }
+ }
+}