Exemple #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);
            }
            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);
            }
        }
        /// <summary>
        /// Creates and initializes the MediaMuxer class for testing.
        /// </summary>
        protected IMediaMuxer SetupMuxer()
        {
            factory = new FakeProcessWorkerFactory();
            FakeFileSystemService FileSystemStub = new FakeFileSystemService();

            return(new MediaMuxer(factory, FileSystemStub, new MediaInfoReader(factory)));
        }
        public void GetFrameCount_Valid_ReturnsFrameCount(string output, int expected)
        {
            var Info = SetupInfo();
            ProcessStartedEventHandler Callback = (s, 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();
            int DataReceivedCalled = 0;

            Manager.DataReceived += (s, e) => DataReceivedCalled++;
            int InfoUpdatedCalled = 0;

            Manager.FileInfoUpdated += (s, e) => InfoUpdatedCalled++;
            int 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);
        }
 protected IMediaInfoReader SetupInfo()
 {
     factory = new FakeProcessWorkerFactory();
     return(new MediaInfoReader(factory));
 }