예제 #1
0
        public void ExecouteTest()
        {
            //Arrange
            const TypeOfTask typeOfTask = TypeOfTask.Video;

            var pipelineMediator = new Mock<IStepMediator>();
            var webClient = new Mock<IEncodeWebClient>();

            var pipelineStep = new GettingEntityStep(pipelineMediator.Object, webClient.Object);
            var stepData=new TaskStepData()
                {
                    TypeOfTask = typeOfTask
                };
            var encodeData = new Mock<IEncodeData>();

            pipelineMediator.Setup(m => m.Send(stepData, pipelineStep));
            webClient.Setup(m => m.GetEntity(typeOfTask)).Returns(encodeData.Object);

            pipelineStep.SetData(stepData);

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

            //Assert
            pipelineMediator.Verify(m => m.Send(It.Is<GettingEntityStepData>(d => d.EncodeData == encodeData.Object &&
                                                                                  d.EncoderState == EncoderState.Completed), pipelineStep));
        }
        public void ExecuteMethodTest()
        {
            //Arrange
            var stepData = new TaskStepData() { TaskId = "taskId", Resource="resource" };

            var pipelineMediator = new Mock<IStepMediator>();
            var webClient = new Mock<IEncodeWebClient>();
            var tokenSource = new Mock<CancellationTokenSourceWrapper>();

            var pipelineStep = new InitializingWebClientStep(pipelineMediator.Object, webClient.Object);
            pipelineStep.SetData(stepData);

            //Act
            pipelineStep.Execute(tokenSource.Object);

            //Assert
            webClient.Verify(m => m.Initialize(stepData.Resource, stepData.TaskId, tokenSource.Object), Times.Once());
        }