Beispiel #1
0
        public async Task CanDoIt_Receive()
        {
            var invoker = new CompiledPipelineInvoker(new DefaultPipeline(initialIncomingSteps: new IIncomingStep[]
            {
                new FakeReceiveStep("step 1"),
                new FakeReceiveStep("step 2"),
                new FakeReceiveStep("step 3"),
            }));

            var context = GetIncomingStepContext();
            await invoker.Invoke(context);

            var events = context.Load <List <string> >();

            Console.WriteLine();
            Console.WriteLine("Result:");
            Console.WriteLine(string.Join(Environment.NewLine, events));
            Console.WriteLine();

            Assert.That(events.ToArray(), Is.EqualTo(new[]
            {
                "step 1 before",
                "step 2 before",
                "step 3 before",
                "step 3 after",
                "step 2 after",
                "step 1 after",
            }));
        }
Beispiel #2
0
        public async Task InvokesInOrder_Compiled()
        {
            var invoker = new CompiledPipelineInvoker(new DefaultPipeline(initialIncomingSteps: new IIncomingStep[]
            {
                new NamedStep("first"),
                new NamedStep("second"),
                new NamedStep("third"),
            }));

            var transportMessage       = new TransportMessage(new Dictionary <string, string>(), new byte[0]);
            var fakeTransactionContext = GetFakeTransactionContext();
            var stepContext            = new IncomingStepContext(transportMessage, fakeTransactionContext);

            await invoker.Invoke(stepContext);

            Console.WriteLine(string.Join(Environment.NewLine, stepContext.Load <List <string> >()));
        }
Beispiel #3
0
        public void CheckTiming()
        {
            var pipeline = Enumerable.Range(0, 15)
                           .Select(stepNumber => new NamedStep($"step {stepNumber}"))
                           .ToArray();

            var defaultPipeline = new DefaultPipeline(initialIncomingSteps: pipeline);
            var invoker         = new CompiledPipelineInvoker(defaultPipeline);

            var stopwatch = Stopwatch.StartNew();

            1000000.Times(() =>
            {
                var stepContext = new IncomingStepContext(new TransportMessage(new Dictionary <string, string>(), new byte[0]), GetFakeTransactionContext());

                invoker.Invoke(stepContext).Wait();
            });

            Console.WriteLine($"Execution took {stopwatch.Elapsed.TotalSeconds:0.0} s");
        }