Add test verifying cancellation before processing starts

This commit is contained in:
Malte Rosenbjerg 2025-10-17 21:51:11 +02:00
parent e01b73787d
commit 4baddaab7f

View file

@ -1043,6 +1043,28 @@ public class VideoTest
Assert.ThrowsExactly<OperationCanceledException>(() => task.ProcessSynchronously()); Assert.ThrowsExactly<OperationCanceledException>(() => task.ProcessSynchronously());
} }
[TestMethod]
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
public void Video_Cancel_CancellationToken_Before_Throws()
{
using var outputFile = new TemporaryFile("out.mp4");
var cts = new CancellationTokenSource();
cts.Cancel();
var task = FFMpegArguments
.FromFileInput("testsrc2=size=320x240[out0]; sine[out1]", false, args => args
.WithCustomArgument("-re")
.ForceFormat("lavfi"))
.OutputToFile(outputFile, false, opt => opt
.WithAudioCodec(AudioCodec.Aac)
.WithVideoCodec(VideoCodec.LibX264)
.WithSpeedPreset(Speed.VeryFast))
.CancellableThrough(cts.Token);
Assert.ThrowsExactly<OperationCanceledException>(() => task.ProcessSynchronously());
}
[TestMethod] [TestMethod]
[Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)] [Timeout(BaseTimeoutMilliseconds, CooperativeCancellation = true)]
public async Task Video_Cancel_CancellationToken_Async_With_Timeout() public async Task Video_Cancel_CancellationToken_Async_With_Timeout()