From f22c506f4666a3e5144c6d8db726385c4fecbe38 Mon Sep 17 00:00:00 2001 From: Malte Rosenbjerg Date: Mon, 11 May 2020 00:02:35 +0200 Subject: [PATCH] Fix tests --- FFMpegCore.Test/VideoTest.cs | 32 +++++++++++---------- FFMpegCore/FFMpeg/Arguments/PipeArgument.cs | 8 +++++- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/FFMpegCore.Test/VideoTest.cs b/FFMpegCore.Test/VideoTest.cs index 0393b06..3ad2b84 100644 --- a/FFMpegCore.Test/VideoTest.cs +++ b/FFMpegCore.Test/VideoTest.cs @@ -285,26 +285,28 @@ public void Video_ToMP4_Args_StreamPipe() [TestMethod, Timeout(45000)] public void Video_ToMP4_Args_StreamOutputPipe_Async_Failure() { - Assert.ThrowsException(() => - { - using var ms = new MemoryStream(); - var pipeSource = new StreamPipeDataReader(ms); - FFMpegArguments - .FromInputFiles(VideoLibrary.LocalVideo) - .ForceFormat("mkv") - .OutputToPipe(pipeSource) - .ProcessAsynchronously() - .WaitForResult(); - }); + using var ms = new MemoryStream(); + var pipeSource = new StreamPipeDataReader(ms); + var result = FFMpegArguments + .FromInputFiles(VideoLibrary.LocalVideo) + .ForceFormat("mkv") + .OutputToPipe(pipeSource) + .ProcessAsynchronously() + .WaitForResult(); + Assert.IsFalse(result); } [TestMethod, Timeout(45000)] public void Video_ToMP4_Args_StreamOutputPipe_Failure() { - Assert.ThrowsException(() => - { - ConvertToStreamPipe(new ForceFormatArgument("mkv")); - }); + using var ms = new MemoryStream(); + var pipeSource = new StreamPipeDataReader(ms); + var result = FFMpegArguments + .FromInputFiles(VideoLibrary.LocalVideo) + .ForceFormat("mkv") + .OutputToPipe(pipeSource) + .ProcessSynchronously(); + Assert.IsFalse(result); } diff --git a/FFMpegCore/FFMpeg/Arguments/PipeArgument.cs b/FFMpegCore/FFMpeg/Arguments/PipeArgument.cs index cc8ffab..e762ce9 100644 --- a/FFMpegCore/FFMpeg/Arguments/PipeArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/PipeArgument.cs @@ -36,7 +36,13 @@ public void Post() public async Task During(CancellationToken? cancellationToken = null) { - await ProcessDataAsync(cancellationToken ?? CancellationToken.None).ConfigureAwait(false); + try + { + await ProcessDataAsync(cancellationToken ?? CancellationToken.None).ConfigureAwait(false); + } + catch (TaskCanceledException) + { + } Post(); }