mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2024-11-10 08:34:12 +01:00
Wrap Instances exception for expected behaviour
This commit is contained in:
parent
dc88862602
commit
349b6044d1
2 changed files with 20 additions and 2 deletions
|
@ -1,6 +1,9 @@
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using FFMpegCore.Arguments;
|
using FFMpegCore.Arguments;
|
||||||
|
using FFMpegCore.Exceptions;
|
||||||
|
using FFMpegCore.Helpers;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
|
using Instances.Exceptions;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
|
||||||
namespace FFMpegCore.Test
|
namespace FFMpegCore.Test
|
||||||
|
@ -99,5 +102,12 @@ public void Audible_Aax_Test()
|
||||||
var arg = new AudibleEncryptionKeyArgument("62689101");
|
var arg = new AudibleEncryptionKeyArgument("62689101");
|
||||||
arg.Text.Should().Be($"-activation_bytes 62689101");
|
arg.Text.Should().Be($"-activation_bytes 62689101");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void Throws_FFMpegException_when_ffmpeg_not_found()
|
||||||
|
{
|
||||||
|
var exception = Assert.ThrowsException<FFMpegException>(() => FFMpegHelper.VerifyFFMpegExists(new FFOptions { BinaryFolder = Path.GetTempPath() }));
|
||||||
|
Assert.IsInstanceOfType<InstanceFileNotFoundException>(exception.InnerException);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,8 +42,16 @@ public static void VerifyFFMpegExists(FFOptions ffMpegOptions)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = Instance.Finish(GlobalFFOptions.GetFFMpegBinaryPath(ffMpegOptions), "-version");
|
try
|
||||||
_ffmpegVerified = result.ExitCode == 0;
|
{
|
||||||
|
var result = Instance.Finish(GlobalFFOptions.GetFFMpegBinaryPath(ffMpegOptions), "-version");
|
||||||
|
_ffmpegVerified = result.ExitCode == 0;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
throw new FFMpegException(FFMpegExceptionType.Operation, "ffmpeg was not found on your system", e);
|
||||||
|
}
|
||||||
|
|
||||||
if (!_ffmpegVerified)
|
if (!_ffmpegVerified)
|
||||||
{
|
{
|
||||||
throw new FFMpegException(FFMpegExceptionType.Operation, "ffmpeg was not found on your system");
|
throw new FFMpegException(FFMpegExceptionType.Operation, "ffmpeg was not found on your system");
|
||||||
|
|
Loading…
Reference in a new issue