jellyfin-server/tests/Jellyfin.MediaEncoding.Tests/EncoderValidatorTests.cs

57 lines
2.9 KiB
C#
Raw Normal View History

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 readonly EncoderValidator _encoderValidator = new EncoderValidator(new NullLogger<EncoderValidatorTests>(), "ffmpeg");
[Theory]
[ClassData(typeof(GetFFmpegVersionTestData))]
public void GetFFmpegVersionTest(string versionOutput, Version? version)
{
Assert.Equal(version, _encoderValidator.GetFFmpegVersionInternal(versionOutput));
}
[Theory]
2021-07-24 16:52:03 +00:00
[InlineData(EncoderValidatorTestsData.FFmpegV44Output, true)]
[InlineData(EncoderValidatorTestsData.FFmpegV432Output, true)]
2020-08-20 15:16:09 +00:00
[InlineData(EncoderValidatorTestsData.FFmpegV431Output, true)]
2020-07-04 11:14:49 +00:00
[InlineData(EncoderValidatorTestsData.FFmpegV43Output, true)]
[InlineData(EncoderValidatorTestsData.FFmpegV421Output, true)]
[InlineData(EncoderValidatorTestsData.FFmpegV42Output, true)]
2019-09-28 17:49:41 +00:00
[InlineData(EncoderValidatorTestsData.FFmpegV414Output, true)]
[InlineData(EncoderValidatorTestsData.FFmpegV404Output, true)]
[InlineData(EncoderValidatorTestsData.FFmpegGitUnknownOutput2, true)]
[InlineData(EncoderValidatorTestsData.FFmpegGitUnknownOutput, false)]
public void ValidateVersionInternalTest(string versionOutput, bool valid)
{
Assert.Equal(valid, _encoderValidator.ValidateVersionInternal(versionOutput));
}
2020-06-15 10:15:05 +00:00
private class GetFFmpegVersionTestData : IEnumerable<object?[]>
{
public IEnumerator<object?[]> GetEnumerator()
{
2021-07-24 16:52:03 +00:00
yield return new object?[] { EncoderValidatorTestsData.FFmpegV44Output, new Version(4, 4) };
yield return new object?[] { EncoderValidatorTestsData.FFmpegV432Output, new Version(4, 3, 2) };
2020-08-20 15:16:09 +00:00
yield return new object?[] { EncoderValidatorTestsData.FFmpegV431Output, new Version(4, 3, 1) };
2020-07-04 11:14:49 +00:00
yield return new object?[] { EncoderValidatorTestsData.FFmpegV43Output, new Version(4, 3) };
2020-06-15 10:15:05 +00:00
yield return new object?[] { EncoderValidatorTestsData.FFmpegV421Output, new Version(4, 2, 1) };
yield return new object?[] { EncoderValidatorTestsData.FFmpegV42Output, new Version(4, 2) };
yield return new object?[] { EncoderValidatorTestsData.FFmpegV414Output, new Version(4, 1, 4) };
yield return new object?[] { EncoderValidatorTestsData.FFmpegV404Output, new Version(4, 0, 4) };
yield return new object?[] { EncoderValidatorTestsData.FFmpegGitUnknownOutput2, new Version(4, 0) };
yield return new object?[] { EncoderValidatorTestsData.FFmpegGitUnknownOutput, null };
2020-06-15 10:15:05 +00:00
}
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
}
}