public async Task WhenSubscriberNotRegistered_CheckEventHandlerIsNotInvoked() { var serviceProvider = ServiceCollectionFixture.CreateServiceProviderScopeFactory(); var inProcessBus = new InProcessBus(serviceProvider); var publisher = inProcessBus.CreatePublisher(TopicName); _ = inProcessBus.CreateSubscription(TopicName); var handlerOne = AssertTestEventHandled <DoSomethingOnTestEvent>(serviceProvider, false); await publisher.Publish(TestEvent.WithMessage("This is a test message")); await Task.WhenAll(handlerOne); }
public async Task WhenMultipleSubscriberRegistered_CheckEventHandlerIsInvokedForAll() { var serviceProvider = ServiceCollectionFixture.CreateServiceProviderScopeFactory(); var inProcessBus = new InProcessBus(serviceProvider); var publisher = inProcessBus.CreatePublisher(TopicName); var subscription = inProcessBus.CreateSubscription(TopicName); subscription.AddSubscriber <TestEvent, DoSomethingOnTestEvent>(); subscription.AddSubscriber <TestEvent, DoSomethingElseOnTestEvent>(); var handlerOne = AssertTestEventHandled <DoSomethingOnTestEvent>(serviceProvider); var handlerTwo = AssertTestEventHandled <DoSomethingElseOnTestEvent>(serviceProvider); await publisher.Publish(TestEvent.WithMessage("This is a test message")); await Task.WhenAll(handlerOne, handlerTwo); }
public void TestSetup() { _serviceProvider = ServiceCollectionFixture.CreateServiceProviderScopeFactory(); _inProcessBus = new InProcessBus(_serviceProvider); }