public async Task ShouldMutateMessage() { var mutator = new FakeMutator(); A.CallTo(() => Configuration.Settings.Container.Resolve(A <Type> .Ignored)).Returns(mutator); MutationManager.RegisterMutator("test", typeof(FakeMutator)); var next = A.Fake <Func <Task> >(); var context = new TestableIncomingLogicalMessageContext(); context.UpdateMessageInstance(Fake <Messages.IEvent>()); await Sut.Invoke(context, next).ConfigureAwait(false); A.CallTo(() => next()).MustHaveHappened(); mutator.MutatedIncoming.Should().BeTrue(); }
private static void Main(string[] args) { var configurationBuilder = new ConfigurationBuilder(); configurationBuilder.AddEnvironmentVariables("TODOMVC_"); Configuration = configurationBuilder.Build(); Console.Title = "Domain"; Log.Logger = new LoggerConfiguration() .MinimumLevel.Warning() .WriteTo.Console(outputTemplate: "[{Level}] {Message}{NewLine}{Exception}") .CreateLogger(); AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionTrapper; NServiceBus.Logging.LogManager.Use <SerilogFactory>(); _container = new Container(x => { x.For <IValidatorFactory>().Use <StructureMapValidatorFactory>(); x.Scan(y => { y.TheCallingAssembly(); y.WithDefaultConventions(); }); }); MutationManager.RegisterMutator("domain", typeof(Mutator)); // Start the bus _bus = InitBus().Result; Console.WriteLine("Press CTRL+C to exit..."); Console.CancelKeyPress += (sender, eArgs) => { QuitEvent.Set(); eArgs.Cancel = true; }; QuitEvent.WaitOne(); _bus.Stop().Wait(); }
public async Task ShouldNotMutateReplies() { var mutator = new FakeMutator(); A.CallTo(() => Configuration.Settings.Container.Resolve(A <Type> .Ignored)).Returns(mutator); MutationManager.RegisterMutator("test", typeof(FakeMutator)); var next = A.Fake <Func <Task> >(); var context = new TestableOutgoingLogicalMessageContext(); context.Headers[Headers.MessageIntent] = MessageIntentEnum.Reply.ToString(); context.UpdateMessage(Fake <Messages.IEvent>()); await Sut.Invoke(context, next).ConfigureAwait(false); A.CallTo(() => next()).MustHaveHappened(); mutator.MutatedOutgoing.Should().BeFalse(); }
private static void Main(string[] args) { var configurationBuilder = new ConfigurationBuilder(); configurationBuilder.AddEnvironmentVariables("ESHOP_"); Configuration = configurationBuilder.Build(); Console.Title = "Domain"; var config = new LoggerConfiguration() .MinimumLevel.Debug() .Enrich.FromLogContext().Enrich.WithThreadId().Enrich.WithProcessName().Enrich.WithProperty("Endpoint", "Domain") .WriteTo.Console(outputTemplate: "[{Level}] {Message}{NewLine}{Exception}", restrictedToMinimumLevel: Serilog.Events.LogEventLevel.Warning); if (!string.IsNullOrEmpty(Configuration["SeqConnection"])) { config.WriteTo.Seq(Configuration["SeqConnection"]); } Log.Logger = config.CreateLogger(); AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionTrapper; NServiceBus.Logging.LogManager.Use <SerilogFactory>(); // Scan working directory for assemblies containing messages var assemblies = new Assembly[] { Assembly.GetExecutingAssembly() }.Concat( DIExtensions.GetAssembliesInDirectory(selector: (file) => file.Name.StartsWith("Aggregates") || file.Name.StartsWith("eShop"))).ToList(); _container = new Container(x => { x.For <IValidatorFactory>().Use <StructureMapValidatorFactory>(); x.For <IMessageSession>().Use(() => Aggregates.Bus.Instance); x.For <Mutator>().Use <Mutator>(); x.Scan(y => { // Note do not use structuremap's assembly scanning it will load EVERY package in nuget foreach (var a in assemblies) { y.Assembly(a); } y.WithDefaultConventions(); y.AddAllTypesOf <ISetup>(); y.AddAllTypesOf <ISeed>(); }); }); MutationManager.RegisterMutator("domain", typeof(Mutator)); // Start the bus _bus = InitBus().Result; Console.WriteLine("Press CTRL+C to exit..."); Console.CancelKeyPress += (sender, eArgs) => { QuitEvent.Set(); eArgs.Cancel = true; }; QuitEvent.WaitOne(); _bus.Stop().Wait(); }