|
1 | 1 | using System; |
| 2 | +using System.Diagnostics; |
2 | 3 | using System.IO; |
3 | 4 | using System.Threading.Tasks; |
4 | 5 | using Xunit; |
@@ -43,6 +44,22 @@ public void ShouldStartEncodeAsync() |
43 | 44 | AssertVeraPdfGotDisposed(); |
44 | 45 | } |
45 | 46 |
|
| 47 | + [Fact] |
| 48 | + public void ShouldDisposeWithoutExceptionWhileEncodeAsync() |
| 49 | + { |
| 50 | + using (var mencoderAsync = new MencoderSharp.MencoderAsync()) |
| 51 | + { |
| 52 | + mencoderAsync.Finished += Mencoder_Finished; |
| 53 | + mencoderAsync.ProgressChanged += Mencoder_Progress; |
| 54 | + mencoderAsync.StartEncodeAsync("./TestFiles/HelloWorld.avi", "./TestOutput.mp4"); |
| 55 | + while (Process.GetProcessesByName(Path.GetFileNameWithoutExtension(mencoderAsync.PathToExternalMencoderBin)).Length == 0) |
| 56 | + { |
| 57 | + Task.Delay(50).Wait(); |
| 58 | + } |
| 59 | + } |
| 60 | + AssertVeraPdfGotDisposed(); |
| 61 | + } |
| 62 | + |
46 | 63 | [Fact] |
47 | 64 | public void ShouldStartEncodeAsyncAndCancle() |
48 | 65 | { |
@@ -75,20 +92,21 @@ public void ShouldStartEncodeAsyncAndCancle() |
75 | 92 | [Fact] |
76 | 93 | public void ShouldStartEncodeSync() |
77 | 94 | { |
78 | | - asyncTaskRunning = false; |
79 | | - using (var mencoderAsync = new MencoderSharp.MencoderAsync()) |
| 95 | + using (var mencoderSync = new MencoderSharp.Mencoder()) |
80 | 96 | { |
81 | | - mencoderAsync.Finished += Mencoder_Finished; |
82 | | - mencoderAsync.ProgressChanged += Mencoder_Progress; |
83 | | - mencoderAsync.StartEncodeAsync("./TestFiles/small.mp4", "./SmallTestOutput.mp4"); |
84 | | - pathToExternalMencoderBin = mencoderAsync.PathToExternalMencoderBin; |
85 | | - asyncTaskRunning = true; |
86 | | - while (asyncTaskRunning) |
87 | | - { |
88 | | - Task.Delay(1000); |
89 | | - } |
90 | | - Assert.InRange(progress, 1, 100); |
91 | | - Assert.True(mencoderAsync.Result.ExecutionWasSuccessfull, mencoderAsync.Result.StandardError); |
| 97 | + Assert.True(mencoderSync.Mencode("./TestFiles/small.mp4", "./SmallTestOutput.mp4", "-vf dsize=16/9,scale=-10:-1,harddup -of lavf -lavfopts format=mp4 -ovc x264 -sws 9 -x264encopts nocabac:level_idc=30:bframes=0:bitrate=512:threads=auto:global_header:threads=auto", "-oac mp3lame")); |
| 98 | + pathToExternalMencoderBin = mencoderSync.PathToExternalMencoderBin; |
| 99 | + } |
| 100 | + AssertVeraPdfGotDisposed(); |
| 101 | + } |
| 102 | + |
| 103 | + [Fact] |
| 104 | + public void ShouldDetectEncodeSyncFail() |
| 105 | + { |
| 106 | + using (var mencoderSync = new MencoderSharp.Mencoder()) |
| 107 | + { |
| 108 | + Assert.False(mencoderSync.Mencode("./TestFiles/DoesNotExist", "./SmallTestOutput.mp4", "-vf dsize=16/9,scale=-10:-1,harddup -of lavf -lavfopts format=mp4 -ovc x264 -sws 9 -x264encopts nocabac:level_idc=30:bframes=0:bitrate=512:threads=auto:global_header:threads=auto", "-oac mp3lame")); |
| 109 | + pathToExternalMencoderBin = mencoderSync.PathToExternalMencoderBin; |
92 | 110 | } |
93 | 111 | AssertVeraPdfGotDisposed(); |
94 | 112 | } |
|
0 commit comments