public void SubscribeToEvent_registers_handler_for_command(TestNybusConfigurator nybus, ISubscriptionBuilder subscriptionBuilder)
        {
            NybusConfiguratorExtensions.SubscribeToEvent <FirstTestEvent, FirstTestEventHandler>(nybus);

            nybus.ApplySubscriptions(subscriptionBuilder);

            Mock.Get(subscriptionBuilder).Verify(p => p.SubscribeToEvent <FirstTestEvent>(typeof(FirstTestEventHandler)));
        }
        public void SubscribeToCommand_registers_handler_instance_for_command(TestNybusConfigurator nybus, ISubscriptionBuilder subscriptionBuilder, FirstTestCommandHandler handler)
        {
            NybusConfiguratorExtensions.SubscribeToCommand <FirstTestCommand, FirstTestCommandHandler>(nybus, handler);

            nybus.ApplySubscriptions(subscriptionBuilder);

            Mock.Get(subscriptionBuilder).Verify(p => p.SubscribeToCommand <FirstTestCommand>(handler.GetType()));
        }
        public void SubscribeToCommand_registers_handler_instance(TestNybusConfigurator nybus, IServiceCollection services, FirstTestCommandHandler handler)
        {
            NybusConfiguratorExtensions.SubscribeToCommand <FirstTestCommand, FirstTestCommandHandler>(nybus, handler);

            nybus.ApplyServiceConfigurations(services);

            Mock.Get(services).Verify(p => p.Add(It.Is <ServiceDescriptor>(sd => sd.ServiceType == handler.GetType())));
        }
        public void SubscribeToCommand_registers_delegate_handler_type(TestNybusConfigurator nybus, IServiceCollection services, CommandReceivedAsync <FirstTestCommand> testHandler)
        {
            NybusConfiguratorExtensions.SubscribeToCommand(nybus, testHandler);

            nybus.ApplyServiceConfigurations(services);

            Mock.Get(services).Verify(p => p.Add(It.Is <ServiceDescriptor>(sd => sd.ServiceType == typeof(DelegateWrapperCommandHandler <FirstTestCommand>))));
        }
        public void SubscribeToCommand_subscribes_to_command_type(TestNybusConfigurator nybus, ISubscriptionBuilder subscriptionBuilder)
        {
            NybusConfiguratorExtensions.SubscribeToCommand <FirstTestCommand>(nybus);

            nybus.ApplySubscriptions(subscriptionBuilder);

            Mock.Get(subscriptionBuilder).Verify(p => p.SubscribeToCommand <FirstTestCommand>(typeof(ICommandHandler <FirstTestCommand>)));
        }
        public void RegisterErrorFilterProvider_adds_provider_with_custom_setup(TestNybusConfigurator nybus, IServiceCollection services, Func <IServiceProvider, IErrorFilterProvider> providerFactory)
        {
            NybusConfiguratorExtensions.RegisterErrorFilterProvider <TestErrorFilterProvider>(nybus, providerFactory);

            nybus.ApplyServiceConfigurations(services);

            Mock.Get(services).Verify(p => p.Add(It.Is <ServiceDescriptor>(sd => sd.ServiceType == typeof(IErrorFilterProvider) && sd.ImplementationFactory == providerFactory)));
        }
        public void SubscribeToCommand_registers_delegate_handler_for_command(TestNybusConfigurator nybus, ISubscriptionBuilder subscriptionBuilder, CommandReceivedAsync <FirstTestCommand> testHandler)
        {
            NybusConfiguratorExtensions.SubscribeToCommand(nybus, testHandler);

            nybus.ApplySubscriptions(subscriptionBuilder);

            Mock.Get(subscriptionBuilder).Verify(p => p.SubscribeToCommand <FirstTestCommand>(typeof(DelegateWrapperCommandHandler <FirstTestCommand>)));
        }
        public void SubscribeToEvent_registers_async_delegate_handler_for_command(TestNybusConfigurator nybus, ISubscriptionBuilder subscriptionBuilder, EventReceivedAsync <FirstTestEvent> testHandler)
        {
            NybusConfiguratorExtensions.SubscribeToEvent(nybus, testHandler);

            nybus.ApplySubscriptions(subscriptionBuilder);

            Mock.Get(subscriptionBuilder).Verify(p => p.SubscribeToEvent <FirstTestEvent>(typeof(DelegateWrapperEventHandler <FirstTestEvent>)));
        }
        public void SubscribeToEvent_registers_handler_type(TestNybusConfigurator nybus, IServiceCollection services)
        {
            NybusConfiguratorExtensions.SubscribeToEvent <FirstTestEvent, FirstTestEventHandler>(nybus);

            nybus.ApplyServiceConfigurations(services);

            Mock.Get(services).Verify(p => p.Add(It.Is <ServiceDescriptor>(sd => sd.ServiceType == typeof(FirstTestEventHandler))));
        }
Exemplo n.º 10
0
        public void UseRabbitMqBusEngine_invokes_configuration_delegate(TestNybusConfigurator configurator, IServiceCollection services)
        {
            Mock <Action <IRabbitMqConfigurator> > configurationDelegate = new Mock <Action <IRabbitMqConfigurator> >();

            RabbitMqConfiguratorExtensions.UseRabbitMqBusEngine(configurator, configurationDelegate.Object);

            configurationDelegate.Verify(p => p(It.IsAny <IRabbitMqConfigurator>()), Times.Once);
        }
Exemplo n.º 11
0
        public void UseRabbitMqBusEngine_registers_StaticQueueFactoryProvider(TestNybusConfigurator configurator, IServiceCollection services)
        {
            RabbitMqConfiguratorExtensions.UseRabbitMqBusEngine(configurator);

            configurator.ApplyServiceConfigurations(services);

            Mock.Get(services).Verify(p => p.Add(It.Is <ServiceDescriptor>(sd => sd.ServiceType == typeof(IQueueFactoryProvider) && sd.ImplementationType == typeof(StaticQueueFactoryProvider))), Times.Once);
        }
Exemplo n.º 12
0
        public void UseInMemoryBusEngine_registers_InMemory_bus_engine(TestNybusConfigurator nybus, IServiceCollection services)
        {
            InMemoryConfiguratorExtensions.UseInMemoryBusEngine(nybus);

            nybus.ApplyServiceConfigurations(services);

            Mock.Get(services).Verify(p => p.Add(It.Is <ServiceDescriptor>(sd => sd.ServiceType == typeof(IBusEngine) && sd.ImplementationType == typeof(InMemoryBusEngine))));
        }