示例#1
0
            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);
            }
示例#2
0
            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);
            }
示例#3
0
 public void TestSetup()
 {
     _serviceProvider = ServiceCollectionFixture.CreateServiceProviderScopeFactory();
     _inProcessBus    = new InProcessBus(_serviceProvider);
 }