public void ProcessingServer_Publish_NoPipeline()
        {
            var factory = new Mock <IEventBusFactory>();
            var server  = new ProcessingServer(factory.Object);

            Assert.DoesNotThrow(() => server.Publish(new Event("pipeline", new EventData())));
        }
示例#2
0
        public void PipelineBuilder_Resolver_Perfomance()
        {
            var server  = new ProcessingServer();
            var builder = new PipelineBuilder();

            builder.BuildPipeline(server, new PipelineConfiguration
            {
                Id             = "1",
                InputHandler   = new HandlerNode(typeof(PlainInputHandler)),
                OutputHandlers = new List <HandlerNode>
                {
                    new HandlerNode(typeof(PlainOutputHandler))
                }
            });

            builder.BuildPipeline(server, new PipelineConfiguration
            {
                Id             = "2",
                InputHandler   = new HandlerNode(typeof(CustomInputHandler)),
                OutputHandlers = new List <HandlerNode>
                {
                    new HandlerNode(typeof(PlainOutputHandler))
                }
            });

            //server.EventBusFactory.GetEventBus("1").Publish(new Event("1", new EventData()));
            //server.EventBusFactory.GetEventBus("2").Publish(new Event("2", new EventData()));

            var runner = new BenchmarkRunner();

            runner.SetIterations(10);

            runner.AddSession("Simple resolver",
                              ProfilerSession.StartSession()
                              .Task(() => server.Publish(new Event("1", new EventData())))
                              .SetThreads(5)
                              );
            runner.AddSession("Complex resolver",
                              ProfilerSession.StartSession()
                              .Task(() => server.Publish(new Event("2", new EventData())))
                              .SetThreads(5)
                              );

            var result = runner.RunSessions();

            result.Trace();
        }
        public void ProcessingServer_Publish()
        {
            var bus = new Mock <IEventBus>();

            bus.Setup(exp => exp.PipelineId).Returns("pipeline");

            var factory = new Mock <IEventBusFactory>();

            factory.Setup(exp => exp.GetEventBus(It.IsAny <string>())).Returns(() => bus.Object);
            var server = new ProcessingServer(factory.Object);

            server.Publish(new Event("pipeline", new EventData()));

            bus.Verify(exp => exp.Publish(It.IsAny <Event>()), Times.Once);
        }