Esempio n. 1
1
        public void CanMeasureTimeSpentInSteps()
        {
            var stats = new PipelineStepProfilerStats();
            var pipeline = new DefaultPipeline()
                .OnReceive(new Step300())
                .OnReceive(new Step100())
                .OnReceive(new Step200());

            var profiler = new PipelineStepProfiler(pipeline, stats);

            var receivePipeline = profiler.ReceivePipeline();
            var invoker = new DefaultPipelineInvoker();
            var transportMessage = new TransportMessage(new Dictionary<string, string>(), new byte[0]);

            using (new DefaultTransactionContextScope())
            {
                var stepContext = new IncomingStepContext(transportMessage, AmbientTransactionContext.Current);

                invoker.Invoke(stepContext, receivePipeline).Wait();

                var stepStats = stats.GetStats();

                Console.WriteLine(string.Join(Environment.NewLine, stepStats));
            }
        }
Esempio n. 2
0
        public void InjectsStepAtTheEndIfAnchorCannotBeFound()
        {
            var pipeline = new DefaultPipeline()
                .OnReceive(new Step1())
                .OnReceive(new Step2());

            var injector = new PipelineStepInjector(pipeline)
                .OnReceive(new InjectedStep(), PipelineRelativePosition.After, typeof(Step3));

            var receivePipeline = injector.ReceivePipeline().ToArray();

            Assert.That(receivePipeline.Select(s => s.GetType()), Is.EqualTo(new[]
            {
                typeof(Step1),
                typeof(Step2),
                typeof(InjectedStep),
            }));
        }
        public void CanInjectStepInTheBack()
        {
            var pipeline = new DefaultPipeline()
                .OnReceive(new Step1())
                .OnReceive(new Step2());

            var injector = new PipelineStepConcatenator(pipeline)
                .OnReceive(new InjectedStep(), PipelineAbsolutePosition.Back);

            var receivePipeline = injector.ReceivePipeline().ToArray();

            Assert.That(receivePipeline.Select(s => s.GetType()), Is.EqualTo(new[]
            {
                typeof(Step1),
                typeof(Step2),
                typeof(InjectedStep),
            }));
        }
Esempio n. 4
0
        public void CanInjectStepBeforeAnotherStep()
        {
            var pipeline = new DefaultPipeline()
                .OnReceive(new Step1())
                .OnReceive(new Step2())
                .OnReceive(new Step3());

            var injector = new PipelineStepInjector(pipeline)
                .OnReceive(new InjectedStep(), PipelineRelativePosition.Before, typeof(Step2));

            var receivePipeline = injector.ReceivePipeline().ToArray();

            Assert.That(receivePipeline.Select(s => s.GetType()), Is.EqualTo(new[]
            {
                typeof(Step1),
                typeof(InjectedStep),
                typeof(Step2),
                typeof(Step3),
            }));
        }