public override void Load() { Bind<IRepository<Customer>>() .To<Repository<Customer>>(); Bind<IEventStore>() .To<EventStore>() .InSingletonScope(); Bind<ICustomerReadModelFacade>() .To<CustomerReadModelService>(); Bind<IReadModelDataBase>() .To<ReadModelDataBase>() .InSingletonScope(); //service bus var serviceBus = new InMemoryServiceBus(Kernel); Bind<IPublishEvents>().ToMethod(context => serviceBus); Bind<ISendCommands>().ToMethod(context => serviceBus); //do some assembly scanning to find all command handlers and event handlers and register them with Ninject //we will use Ninject to locate the handlers in the "service bus" Kernel.Bind(scanner => scanner .FromAssemblyContaining<RegisterNewCustomerCommandHandler>() .SelectAllClasses() .InheritedFromAny(new[] { typeof (CQRSSample.Domain.CommandHandlers.IHandleCommandsOfType<>), typeof (CQRSSample.Domain.EventHandlers.IHandleEventsOfType<>) }) .BindSingleInterface()); }
public override void Load() { Bind <IRepository <Customer> >() .To <Repository <Customer> >(); Bind <IEventStore>() .To <EventStore>() .InSingletonScope(); Bind <ICustomerReadModelFacade>() .To <CustomerReadModelService>(); Bind <IReadModelDataBase>() .To <ReadModelDataBase>() .InSingletonScope(); //service bus var serviceBus = new InMemoryServiceBus(Kernel); Bind <IPublishEvents>().ToMethod(context => serviceBus); Bind <ISendCommands>().ToMethod(context => serviceBus); //do some assembly scanning to find all command handlers and event handlers and register them with Ninject //we will use Ninject to locate the handlers in the "service bus" Kernel.Bind(scanner => scanner .FromAssemblyContaining <RegisterNewCustomerCommandHandler>() .SelectAllClasses() .InheritedFromAny(new[] { typeof(CQRSSample.Domain.CommandHandlers.IHandleCommandsOfType <>), typeof(CQRSSample.Domain.EventHandlers.IHandleEventsOfType <>) }) .BindSingleInterface()); }
public void SetupBeforeEachTest() { this.messageSubscription = A.Fake<IMessageSubscription>(); A.CallTo(() => this.MessageSubscriptionFactory.Create(A<Type>._)).Returns(this.messageSubscription); this.componentUnderTest = this.CreateInMemoryServiceBus(); }
public void ShouldNotDisposeSubscriptionDuringFinalise() { this.componentUnderTest.Receive(typeof(TestMessageAHandler)); this.componentUnderTest = null; GC.Collect(); GC.WaitForPendingFinalizers(); A.CallTo(() => this.messageSubscription.Dispose()).MustNotHaveHappened(); }
public void TestSimpleQueue() { const string QueueName = "Hello"; var inMemoryServiceBus = new InMemoryServiceBus(); inMemoryServiceBus.CreateQueueAsync(QueueName); inMemoryServiceBus.PushAsync(new Event("Haya") { EventType = QueueName }).Wait(); var pollerResult = inMemoryServiceBus.NextAsync(QueueName).Result; Assert.True(pollerResult.IsSuccessful); Assert.Equal(QueueName, pollerResult.PollingResult.QueueName); Assert.Equal(QueueName, pollerResult.PollingResult.EventType); Assert.Equal("Haya", pollerResult.PollingResult.GetBody<string>()); }
public void TestSimpleQueue() { const string TheQueueName = "Hello"; var inMemoryServiceBus = new InMemoryServiceBus(); inMemoryServiceBus.CreateQueueAsync(TheQueueName); inMemoryServiceBus.PushAsync(new Event("Haya") { EventType = TheQueueName }).Wait(); var pollerResult = inMemoryServiceBus.NextAsync(QueueName.FromSimpleQueueName(TheQueueName)).Result; Assert.True(pollerResult.IsSuccessful); Assert.Equal(TheQueueName, pollerResult.PollingResult.QueueName); Assert.Equal(TheQueueName, pollerResult.PollingResult.EventType); Assert.Equal("Haya", pollerResult.PollingResult.GetBody <string>()); }
public void SetupBeforeEachTest() { this.componentUnderTest = this.CreateInMemoryServiceBus(); }