Exemplo n.º 1
0
        public void Initialize()
        {
            _pipelineMediator = new Mock<IStepMediator>();
            _fileSystem = new Mock<IFileSystem>();
            _fileWrapper = new Mock<IFileWrapper>();
            _tempFileCreator = new Mock<ITempFileManager>();
            _tokenSource = new Mock<CancellationTokenSourceWrapper>();
            _encodeData = new Mock<IEncodeData>();

            _pipelineStep = new DownloadStep(_pipelineMediator.Object, _tempFileCreator.Object, _fileSystem.Object, _fileWrapper.Object);

            var stepData = new GettingEntityStepData()
            {
                EncoderState = EncoderState.Completed,
                EncodeData = _encodeData.Object
            };
            _pipelineStep.SetData(stepData);
        }
Exemplo n.º 2
0
        public void ExecuteMethodTest()
        {
            //Arrange
            var pipelineMediator = new Mock<IStepMediator>();
            var webClient = new Mock<IEncodeWebClient>();
            var encodeData = new Mock<IEncodeData>();
            var creatorFactory = new Mock<IEncodeCreatorFactory>();
            var tempFileManager = new Mock<ITempFileManager>();
            var encodeCreator = new Mock<IEncodeCreator>();
            var ffmpegParser = new Mock<IFfmpegParser>();
            var dataReceiveHandler = new Mock<IDataReceivedHandler>();
            var encodeStringFactory = new Mock<IVideoEncodeStringFactory>();
            var encodeStringBuilder = new Mock<IEncodeStringBuilder>();

            var stepData = new GettingEntityStepData()
            {
                EncodeData = encodeData.Object
            };

            var pipelineStep = new CreatorStep(pipelineMediator.Object, webClient.Object, creatorFactory.Object, tempFileManager.Object);

            creatorFactory.Setup(m => m.Create(encodeData.Object)).Returns(encodeCreator.Object);
            encodeCreator.Setup(m => m.CreateFfmpegParser()).Returns(ffmpegParser.Object);
            encodeCreator.Setup(m => m.CreateDataReceivedHandler(ffmpegParser.Object)).Returns(dataReceiveHandler.Object);
            encodeCreator.Setup(m => m.CreateEncodeStringFactory()).Returns(encodeStringFactory.Object);
            encodeCreator.Setup(m => m.CreateEncodeStringBuilder(tempFileManager.Object, encodeStringFactory.Object)).Returns(encodeStringBuilder.Object);
            pipelineStep.SetData(stepData);

            //Act
            pipelineStep.Execute(It.IsAny<CancellationTokenSourceWrapper>());

            //Assert
            pipelineMediator.Verify(m => m.Send(It.Is<CreatorStepData>(d =>
                                                                       d.DataReceivedHandler == dataReceiveHandler.Object &&
                                                                       d.EncodeStringBuilder == encodeStringBuilder.Object &&
                                                                       d.EncoderState == EncoderState.Completed), pipelineStep),
                                    Times.Once());
        }