Beispiel #1
0
        public void EmptyCanBeExecuted()
        {
            // Arrange
            var pipeLineType = 505;
            var pipeline     = new PipelineFactory.BuildPipeline <TestMiddlewareBase, TestPipelineContext>(IoCProvider)
                               .Build(pipeLineType);
            var context = new TestPipelineContext();

            // Act
            pipeline.Execute(context);

            // Assert
            Assert.NotNull(pipeline);
        }
Beispiel #2
0
        public void MakesExecutionMetaDataForEachMiddleware()
        {
            // Arrange
            var pipeLineType = 100;
            var pipeline     = new PipelineFactory.BuildPipeline <TestMiddlewareBase, TestPipelineContext>(IoCProvider)
                               .Build(pipeLineType);
            var context = new TestPipelineContext();

            // Act
            pipeline.Execute(context);
            var count = context.MetaData.ExecutionReports.Count();

            // Assert
            Assert.AreEqual(2, count);
        }
Beispiel #3
0
        public void ContextIsPassedToMiddleware()
        {
            // Arrange
            var pipeLineType = 100;
            var pipeline     = new PipelineFactory.BuildPipeline <TestMiddlewareBase, TestPipelineContext>(IoCProvider)
                               .Build(pipeLineType);
            var context = new TestPipelineContext();

            // Act
            pipeline.Execute(context);

            // Assert
            Assert.AreEqual(context, TestMiddlewareOne.ExecutedContext);
            Assert.AreEqual(context, TestMiddlewareTwo.ExecutedContext);
        }
Beispiel #4
0
        public void ExceptionsStopExecution()
        {
            // Arrange
            var pipeLineType = 100;
            var pipeline     = new PipelineFactory.BuildPipeline <TestMiddlewareBase, TestPipelineContext>(IoCProvider)
                               .Build(pipeLineType);
            var context = new TestPipelineContext();

            TestMiddlewareOne.ThrowException = true;

            // Act
            pipeline.Execute(context);
            var count = context.MetaData.ExecutionReports.Count();

            // Assert
            Assert.AreEqual(1, count);
        }
Beispiel #5
0
        public void ExceptionsAreCaught()
        {
            // Arrange
            var pipeLineType = 100;
            var pipeline     = new PipelineFactory.BuildPipeline <TestMiddlewareBase, TestPipelineContext>(IoCProvider)
                               .Build(pipeLineType);
            var context = new TestPipelineContext();

            TestMiddlewareOne.ThrowException = true;

            // Act
            pipeline.Execute(context);
            var executionReport = context.MetaData.ExecutionReports.First();

            // Assert
            Assert.IsTrue(executionReport.ExceptionThrown as InvalidOperationException != null);
        }
Beispiel #6
0
        public void ExecutionMetaDataIsPopulated()
        {
            // Arrange
            var pipeLineType = 100;
            var pipeline     = new PipelineFactory.BuildPipeline <TestMiddlewareBase, TestPipelineContext>(IoCProvider)
                               .Build(pipeLineType);
            var context  = new TestPipelineContext();
            var expected = new TestMiddlewareOne();

            // Act
            pipeline.Execute(context);
            var executionReport = context.MetaData.ExecutionReports.First();

            // Assert
            Assert.AreEqual(executionReport.ExecutionOrder, expected.ExecutionOrder, "ExecutionOrder");
            Assert.AreEqual(executionReport.TargetPipelineType, expected.TargetPipelineType, "TargetPipelineType");
            Assert.AreEqual(executionReport.ExceptionThrown, null, "ExceptionThrown");
            Assert.True(executionReport.DurationInMs >= 100, "DurationInMs");
        }