mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-22 08:45:23 +03:00
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
This commit is contained in:
39
tests/Jellyfin.MediaEncoding.Tests/EncoderValidatorTests.cs
Normal file
39
tests/Jellyfin.MediaEncoding.Tests/EncoderValidatorTests.cs
Normal file
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user