public void CommandLoggingInterceptorDoesNotBreakProcessingChain() { var commandLoggingInterceptor = new DefaultCommandLoggingInterceptor(_logFactory); var commandSimpleInterceptor = new CommandSimpleInterceptor(); var commandsHandler = new CommandsHandler(); using (var messagingEngine = new MessagingEngine( _logFactory, new TransportResolver(new Dictionary <string, TransportInfo> { { "InMemory", new TransportInfo("none", "none", "none", null) } }))) { using (var engine = new CqrsEngine( _logFactory, messagingEngine, Register.DefaultEndpointResolver(new InMemoryEndpointResolver()), Register.CommandInterceptors(commandLoggingInterceptor, commandSimpleInterceptor), Register.BoundedContext("test1") .ListeningCommands(typeof(int)).On("lykke-wallet-events") .WithCommandsHandler(commandsHandler))) { engine.StartSubscribers(); messagingEngine.Send(1, new Endpoint("InMemory", "lykke-wallet-events", serializationFormat: SerializationFormat.Json)); Thread.Sleep(1000); Assert.True(commandSimpleInterceptor.Intercepted); } } }
public void TwoSimpleCommandInterceptorsTest() { var commandSimpleInterceptorOne = new CommandSimpleInterceptor(); var commandSimpleInterceptorTwo = new CommandSimpleInterceptor(); var commandsHandler = new CommandsHandler(); using (var messagingEngine = new MessagingEngine( _logFactory, new TransportResolver(new Dictionary <string, TransportInfo> { { "InMemory", new TransportInfo("none", "none", "none", null) } }))) { using (var engine = new CqrsEngine( _logFactory, messagingEngine, Register.DefaultEndpointResolver(new InMemoryEndpointResolver()), Register.CommandInterceptors(commandSimpleInterceptorOne, commandSimpleInterceptorTwo), Register.BoundedContext("swift-cashout") .ListeningCommands(typeof(int)).On("lykke-wallet-events") .WithCommandsHandler(commandsHandler))) { engine.StartSubscribers(); messagingEngine.Send(1, new Endpoint("InMemory", "lykke-wallet-events", serializationFormat: SerializationFormat.Json)); Thread.Sleep(1000); Assert.True(commandSimpleInterceptorOne.Intercepted); Assert.True(commandSimpleInterceptorTwo.Intercepted); Assert.NotNull(commandSimpleInterceptorOne.InterceptionTimestamp); Assert.NotNull(commandSimpleInterceptorTwo.InterceptionTimestamp); Assert.True(commandSimpleInterceptorOne.InterceptionTimestamp < commandSimpleInterceptorTwo.InterceptionTimestamp); Assert.True(commandsHandler.HandledCommands.Count > 0); } } }