Esempio n. 1
0
        public void Execute_HandlesExceptionThrownByOperation()
        {
            // ARRANGE
            var mockOperation = new Mock <IPipelineOperation <TestPipelineContext> >();

            mockOperation
            .Setup(o => o.Dependencies)
            .Returns(new List <Type>());

            mockOperation
            .Setup(o => o.Execute(It.IsAny <TestPipelineContext>()))
            .Throws <OperationExecutionException>();

            var operations = new ReadOnlyDictionary <Type, IPipelineOperation <TestPipelineContext> >(
                new Dictionary <Type, IPipelineOperation <TestPipelineContext> >
            {
                { typeof(TestOperation), mockOperation.Object }
            }
                );

            var opManager = new TestBasePipelineCoordinator(operations, _asyncOperations);

            // ACTION
            opManager.Execute <TestOperation>();

            // ASSERT
            Assert.False(opManager.Context.Successful);
            Assert.NotEmpty(opManager.Context.Exceptions);
            Assert.IsType <OperationExecutionException>(opManager.Context.Exceptions[0]);
            Assert.Contains(typeof(TestOperation), opManager.OperationsExecuted);
        }
Esempio n. 2
0
        public void Execute_ThrowsExceptionOnNullContextParameter()
        {
            // ARRANGE
            var opManager = new TestBasePipelineCoordinator(_operations, _asyncOperations);

            // ACTION / ASSERT
            Assert.Throws <ArgumentException>(() => opManager.Execute <TestOperation>(null));
        }
Esempio n. 3
0
        public void Execute_DoesNothingWhenEndProcessingInContextIsTrue()
        {
            // ARRANGE
            var opManager = new TestBasePipelineCoordinator(_operations, _asyncOperations);

            opManager.Context.EndProcessing = true;

            // ACTION
            opManager.Execute <TestDependencyOperation>();

            // ASSERT
            Assert.True(opManager.Context.Successful);
            Assert.Empty(opManager.Context.Exceptions);
            Assert.Empty(opManager.OperationsExecuted);
            Assert.Single(opManager.Context.ResultMessages);
            Assert.Contains("Not Executed", opManager.Context.ResultMessages[0]);
        }
Esempio n. 4
0
        public void Execute_RunsOperationSuccessfully()
        {
            // ARRANGE
            var operations = new ReadOnlyDictionary <Type, IPipelineOperation <TestPipelineContext> >(
                new Dictionary <Type, IPipelineOperation <TestPipelineContext> >
            {
                { typeof(TestDependencyOperation), new TestDependencyOperation() }
            }
                );

            var opManager = new TestBasePipelineCoordinator(operations, _asyncOperations);

            // ACTION
            opManager.Execute <TestDependencyOperation>();

            // ASSERT
            Assert.True(opManager.Context.Successful);
            Assert.Empty(opManager.Context.Exceptions);
            Assert.Contains(typeof(TestDependencyOperation), opManager.OperationsExecuted);
        }
Esempio n. 5
0
        public void Execute_ThrowsExceptionOnMissingDependency()
        {
            // ARRANGE
            var testOperation = new TestOperation();

            var operations = new ReadOnlyDictionary <Type, IPipelineOperation <TestPipelineContext> >(
                new Dictionary <Type, IPipelineOperation <TestPipelineContext> >
            {
                { typeof(TestOperation), testOperation }
            }
                );

            var opManager = new TestBasePipelineCoordinator(operations, _asyncOperations);

            // ACTION
            opManager.Execute <TestOperation>();

            // ASSERT
            Assert.True(opManager.Context.EndProcessing);
            Assert.Single(opManager.Context.Exceptions);
        }