2019-09-27 23:29:54 +00:00
|
|
|
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
|
|
|
|
{
|
|
|
|
[Theory]
|
|
|
|
[ClassData(typeof(GetFFmpegVersionTestData))]
|
2020-01-31 21:46:10 +00:00
|
|
|
public void GetFFmpegVersionTest(string versionOutput, Version? version)
|
2019-09-27 23:29:54 +00:00
|
|
|
{
|
|
|
|
Assert.Equal(version, EncoderValidator.GetFFmpegVersion(versionOutput));
|
|
|
|
}
|
|
|
|
|
|
|
|
[Theory]
|
2019-09-29 11:41:24 +00:00
|
|
|
[InlineData(EncoderValidatorTestsData.FFmpegV421Output, true)]
|
2019-09-27 23:29:54 +00:00
|
|
|
[InlineData(EncoderValidatorTestsData.FFmpegV42Output, true)]
|
2019-09-28 17:49:41 +00:00
|
|
|
[InlineData(EncoderValidatorTestsData.FFmpegV414Output, true)]
|
2019-09-27 23:29:54 +00:00
|
|
|
[InlineData(EncoderValidatorTestsData.FFmpegV404Output, true)]
|
2019-09-29 11:41:24 +00:00
|
|
|
[InlineData(EncoderValidatorTestsData.FFmpegGitUnknownOutput, false)]
|
2019-09-27 23:29:54 +00:00
|
|
|
public void ValidateVersionInternalTest(string versionOutput, bool valid)
|
|
|
|
{
|
|
|
|
var val = new EncoderValidator(new NullLogger<EncoderValidatorTests>());
|
|
|
|
Assert.Equal(valid, val.ValidateVersionInternal(versionOutput));
|
|
|
|
}
|
2020-06-14 06:56:47 +00:00
|
|
|
|
|
|
|
private class GetFFmpegVersionTestData : IEnumerable<object?[]>
|
|
|
|
{
|
|
|
|
public IEnumerator<object?[]> GetEnumerator()
|
|
|
|
{
|
|
|
|
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.FFmpegGitUnknownOutput, null };
|
|
|
|
}
|
|
|
|
|
|
|
|
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
|
|
|
}
|
2019-09-27 23:29:54 +00:00
|
|
|
}
|
|
|
|
}
|