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 CommandLoggingInterceptorTestForDefaultLogging() { var commandLoggingInterceptor = new DefaultCommandLoggingInterceptor(_logFactory); 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), Register.BoundedContext("test1") .ListeningCommands(typeof(int)).On("lykke-wallet-events") .WithCommandsHandler(commandsHandler))) { engine.StartSubscribers(); using (var writer = new StringWriter()) { var prevOut = Console.Out; Console.SetOut(writer); messagingEngine.Send(1, new Endpoint("InMemory", "lykke-wallet-events", serializationFormat: SerializationFormat.Json)); Thread.Sleep(1000); Console.SetOut(prevOut); var output = writer.ToString(); Assert.IsFalse(output.IsNullOrEmpty(), "Command was not logged"); } } } }