コード例 #1
0
        public void Run_FeedOutput_DataReceivedCalled(ProcessOutput outputType, string expectedData)
        {
            var manager = SetupManager();

            manager.OutputType      = outputType;
            manager.ProcessStarted += (s, e) =>
            {
                var pMock = Mock.Get <IProcess>(e.ProcessWorker.WorkProcess);
                pMock.Raise(x => x.OutputDataReceived += null, FakeProcessWorkerFactory.CreateMockDataReceivedEventArgs(OutputDataStream));
                pMock.Raise(x => x.ErrorDataReceived  += null, FakeProcessWorkerFactory.CreateMockDataReceivedEventArgs(ErrorDataStream));
            };
            manager.DataReceived += (s, e) =>
            {
                if (expectedData != null)
                {
                    Assert.Equal(expectedData, e.Data);
                }
            };

            manager.Run(TestFileName, null);

            if (expectedData != null)
            {
                Assert.Contains(expectedData, manager.Output, StringComparison.InvariantCulture);
            }
            else
            {
                Assert.Equal("", manager.Output);
            }
        }
        public void RunEncoder_InjectFFmpeg_ExpectedStreams(string output, string videoFormat, string audioFormat)
        {
            var manager = SetupManager();

            manager.ProcessStarted += (s, e) => FakeProcessWorkerFactory.FeedOutputToProcess(manager, output);

            var result = manager.RunEncoder(null, EncoderApp.FFmpeg);

            var info = manager.FileInfo as FileInfoFFmpeg;

            if (videoFormat != null)
            {
                Assert.NotNull(info.VideoStream);
                Assert.Equal(videoFormat, info.VideoStream.Format);
            }
            else
            {
                Assert.Null(info.VideoStream);
            }

            if (audioFormat != null)
            {
                Assert.NotNull(info.AudioStream);
                Assert.Equal(audioFormat, info.AudioStream.Format);
            }
            else
            {
                Assert.Null(info.AudioStream);
            }
        }
コード例 #3
0
        /// <summary>
        /// Creates and initializes the MediaMuxer class for testing.
        /// </summary>
        protected IMediaMuxer SetupMuxer()
        {
            _factory = new FakeProcessWorkerFactory();
            var fileSystemStub = new FakeFileSystemService();

            return(new MediaMuxer(_factory, fileSystemStub, new FakeMediaInfoReader()));
        }
コード例 #4
0
        public void GetFrameCount_Valid_ReturnsFrameCount(string output, int expected)
        {
            var info = SetupInfo();

            void Callback(object s, ProcessStartedEventArgs e) => FakeProcessWorkerFactory.FeedOutputToProcess(e.ProcessWorker, output);

            var result = info.GetFrameCount(TestFile, null, Callback);

            Assert.Equal(expected, result);
        }
        public void RunEncoder_InjectX264_StatusSuccess(string output)
        {
            var manager = SetupManager();

            manager.ProcessStarted += (s, e) => FakeProcessWorkerFactory.FeedOutputToProcess(manager, output);

            var result = manager.RunEncoder(null, EncoderApp.x264);

            Assert.Equal(CompletionStatus.Success, result);
        }
        public void RunEncoder_InjectX264_ExpectedFrameCount(string output, int expectedFrameCount)
        {
            var manager = SetupManager();

            manager.ProcessStarted += (s, e) => FakeProcessWorkerFactory.FeedOutputToProcess(manager, output);

            var result = manager.RunEncoder(null, EncoderApp.x264);

            var info = manager.FileInfo as FileInfoX264;

            Assert.Equal(expectedFrameCount, info.FrameCount);
        }
        public void RunEncoder_InjectFFmpeg_ExpectedFrameCount(string output, int expectedFrameCount)
        {
            var manager = SetupManager();

            manager.ProcessStarted += (s, e) => FakeProcessWorkerFactory.FeedOutputToProcess(manager, output);

            var result = manager.RunEncoder(null, EncoderApp.FFmpeg);

            var info = manager.FileInfo as FileInfoFFmpeg;

            Assert.Equal(expectedFrameCount, info.FrameCount);
            Assert.True(info.FileDuration > TimeSpan.Zero);
        }
        public void RunEncoder_OptionFrameCount_ReturnsSpecifiedFrameCount(string output, int frameCount)
        {
            var manager = SetupManager();

            manager.Options.FrameCount = frameCount;
            manager.ProcessStarted    += (s, e) => FakeProcessWorkerFactory.FeedOutputToProcess(manager, output);

            manager.RunEncoder(null, EncoderApp.FFmpeg);

            var info = manager.FileInfo as FileInfoFFmpeg;

            Assert.Equal(frameCount, info.FrameCount);
        }
        public void RunEncoder_InjectX264_EventsTriggered(string output, int statusLines)
        {
            var manager            = SetupManager();
            var dataReceivedCalled = 0;

            manager.DataReceived += (s, e) => dataReceivedCalled++;
            var infoUpdatedCalled = 0;

            manager.FileInfoUpdated += (s, e) => infoUpdatedCalled++;
            var statusUpdatedCalled = 0;

            manager.ProgressReceived += (s, e) => statusUpdatedCalled++;
            manager.ProcessStarted   += (s, e) => FakeProcessWorkerFactory.FeedOutputToProcess(manager, output);

            var result = manager.RunEncoder(null, EncoderApp.x264);

            Assert.True(dataReceivedCalled > 0);
            Assert.Equal(1, infoUpdatedCalled);
            Assert.Equal(statusLines, statusUpdatedCalled);
        }
コード例 #10
0
 protected IMediaInfoReader SetupInfo()
 {
     _factory = new FakeProcessWorkerFactory();
     return(new MediaInfoReader(_factory));
 }