public void Establish() { _controlBusSender = new SpyControlBusSender(); var registry = new SubscriberRegistry(); registry.Register <MyCommand, MyMonitoredHandler>(); var container = new TinyIoCContainer(); var handlerFactory = new TinyIocHandlerFactory(container); container.Register <IHandleRequests <MyCommand>, MyMonitoredHandler>(); container.Register <IHandleRequests <MyCommand>, MonitorHandler <MyCommand> >(); container.Register <IAmAControlBusSender>(_controlBusSender); container.Register <MonitorConfiguration>(new MonitorConfiguration { IsMonitoringEnabled = true, InstanceName = "UnitTests" }); _commandProcessor = new CommandProcessor(registry, handlerFactory, new InMemoryRequestContextFactory(), new PolicyRegistry()); _command = new MyCommand(); _originalRequestAsJson = JsonConvert.SerializeObject(_command); _at = DateTime.UtcNow; Clock.OverrideTime = _at; }
public MonitorHandlerPipelineAsyncTests() { _controlBusSender = new SpyControlBusSender(); var registry = new SubscriberRegistry(); registry.RegisterAsync <MyCommand, MyMonitoredHandlerAsync>(); var container = new ServiceCollection(); container.AddTransient <MyMonitoredHandlerAsync>(); container.AddTransient <MonitorHandlerAsync <MyCommand> >(); container.AddSingleton <IAmAControlBusSenderAsync>(_controlBusSender); container.AddSingleton(new MonitorConfiguration { IsMonitoringEnabled = true, InstanceName = "UnitTests" }); var handlerFactory = new ServiceProviderHandlerFactory(container.BuildServiceProvider()); _commandProcessor = new CommandProcessor(registry, (IAmAHandlerFactoryAsync)handlerFactory, new InMemoryRequestContextFactory(), new PolicyRegistry()); _command = new MyCommand(); _originalRequestAsJson = JsonConvert.SerializeObject(_command); _at = DateTime.UtcNow.AddMilliseconds(-500); }
public MonitorHandlerMustObserveButRethrowTests() { _controlBusSender = new SpyControlBusSender(); var registry = new SubscriberRegistry(); registry.RegisterAsync <MyCommand, MyMonitoredHandlerThatThrowsAsync>(); var container = new ServiceCollection(); container.AddTransient <MyMonitoredHandlerThatThrowsAsync>(); container.AddTransient <MonitorHandlerAsync <MyCommand> >(); container.AddSingleton <IAmAControlBusSenderAsync>(_controlBusSender); container.AddSingleton(new MonitorConfiguration { IsMonitoringEnabled = true, InstanceName = "UnitTests" }); container.AddSingleton <IBrighterOptions>(new BrighterOptions() { HandlerLifetime = ServiceLifetime.Transient }); var handlerFactory = new ServiceProviderHandlerFactory(container.BuildServiceProvider()); _commandProcessor = new CommandProcessor(registry, handlerFactory, new InMemoryRequestContextFactory(), new PolicyRegistry()); _command = new MyCommand(); _originalRequestAsJson = JsonSerializer.Serialize(_command, JsonSerialisationOptions.Options); _at = DateTime.UtcNow.AddMilliseconds(-500); }
public MonitorHandlerMustObserveButRethrowTests() { _controlBusSender = new SpyControlBusSender(); var registry = new SubscriberRegistry(); registry.RegisterAsync <MyCommand, MyMonitoredHandlerThatThrowsAsync>(); var container = new TinyIoCContainer(); var handlerFactory = new TinyIocHandlerFactoryAsync(container); container.Register <IHandleRequestsAsync <MyCommand>, MyMonitoredHandlerThatThrowsAsync>(); container.Register <IHandleRequestsAsync <MyCommand>, MonitorHandlerAsync <MyCommand> >(); container.Register <IAmAControlBusSenderAsync>(_controlBusSender); container.Register(new MonitorConfiguration { IsMonitoringEnabled = true, InstanceName = "UnitTests" }); _commandProcessor = new CommandProcessor(registry, handlerFactory, new InMemoryRequestContextFactory(), new PolicyRegistry()); _command = new MyCommand(); _originalRequestAsJson = JsonConvert.SerializeObject(_command); _at = DateTime.UtcNow.AddMilliseconds(-500); }
public MonitorHandlerTests() { _controlBusSender = new SpyControlBusSender(); var registry = new SubscriberRegistry(); registry.Register <MyCommand, MyMonitoredHandlerThatThrows>(); var container = new TinyIoCContainer(); var handlerFactory = new TinyIocHandlerFactory(container); container.Register <IHandleRequests <MyCommand>, MyMonitoredHandlerThatThrows>(); container.Register <IHandleRequests <MyCommand>, MonitorHandler <MyCommand> >(); container.Register <IAmAControlBusSender>(_controlBusSender); container.Register(new MonitorConfiguration { IsMonitoringEnabled = true, InstanceName = "UnitTests" }); _commandProcessor = new CommandProcessor(registry, handlerFactory, new InMemoryRequestContextFactory(), new PolicyRegistry()); _command = new MyCommand(); _at = DateTime.UtcNow.AddMilliseconds(-500); }