Exemplo n.º 1
0
        public void Initialize()
        {
            _pipelineMediator = new Mock<IStepMediator>();
            _webClient = new Mock<IEncodeWebClient>();
            _ffmpegProcess = new Mock<IFfmpeg>();
            _watchDogTimer = new Mock<IWatchDogTimer>();
            _dataReceiveHandler = new Mock<IDataReceivedHandler>();
            _encodeStringBuilder = new Mock<IEncodeStringBuilder>();
            _tokenSource = new Mock<CancellationTokenSourceWrapper>();

            _pipelineStep = new EncodeStep(_pipelineMediator.Object, _webClient.Object, _ffmpegProcess.Object, _watchDogTimer.Object);

            _encoderStatus = new EncoderStatus()
                {
                    EncoderState = EncoderState.Failed,
                    ErrorMessage = "errorMessage"
                };
            _stepData = new CreatorStepData()
                {
                    EncoderState = EncoderState.Completed,
                    EncodeStringBuilder = _encodeStringBuilder.Object,
                    DataReceivedHandler = _dataReceiveHandler.Object
                };

            _encodeStringBuilder.Setup(m => m.GetContentType()).Returns(ContentType);
            _encodeStringBuilder.Setup(m => m.GetFfmpegArguments()).Returns(Arguments);
            _ffmpegProcess.Setup(m => m.Start(Arguments, _tokenSource.Object, _dataReceiveHandler.Object.ProcessData)).Returns(() =>
                {
                    var tcs = new TaskCompletionSource<EncoderStatus>();
                    tcs.SetResult(_encoderStatus);
                    return tcs.Task;
                });

            _pipelineStep.SetData(_stepData);
        }
Exemplo n.º 2
0
        public void Initialize()
        {
            _pipelineMediator    = new Mock <IStepMediator>();
            _webClient           = new Mock <IEncodeWebClient>();
            _ffmpegProcess       = new Mock <IFfmpeg>();
            _watchDogTimer       = new Mock <IWatchDogTimer>();
            _dataReceiveHandler  = new Mock <IDataReceivedHandler>();
            _encodeStringBuilder = new Mock <IEncodeStringBuilder>();
            _tokenSource         = new Mock <CancellationTokenSourceWrapper>();

            _pipelineStep = new EncodeStep(_pipelineMediator.Object, _webClient.Object, _ffmpegProcess.Object, _watchDogTimer.Object);

            _encoderStatus = new EncoderStatus()
            {
                EncoderState = EncoderState.Failed,
                ErrorMessage = "errorMessage"
            };
            _stepData = new CreatorStepData()
            {
                EncoderState        = EncoderState.Completed,
                EncodeStringBuilder = _encodeStringBuilder.Object,
                DataReceivedHandler = _dataReceiveHandler.Object
            };

            _encodeStringBuilder.Setup(m => m.GetContentType()).Returns(ContentType);
            _encodeStringBuilder.Setup(m => m.GetFfmpegArguments()).Returns(Arguments);
            _ffmpegProcess.Setup(m => m.Start(Arguments, _tokenSource.Object, _dataReceiveHandler.Object.ProcessData)).Returns(() =>
            {
                var tcs = new TaskCompletionSource <EncoderStatus>();
                tcs.SetResult(_encoderStatus);
                return(tcs.Task);
            });

            _pipelineStep.SetData(_stepData);
        }