public async Task InMemoryCommandBus_Configuration_MultipleHandlers_ConfigurationOk() { var c = new InMemoryCommandBusConfigurationBuilder() .AllowMultipleHandlersFor <TestMultipleHandlerFromConfig>(); var bus = new InMemoryCommandBus(c.Build()); (await bus.DispatchAsync(new TestMultipleHandlerFromConfig()).ConfigureAwait(false)).IsSuccess.Should().BeTrue(); }
public async Task InMemoryCommandBus_Configuration_MultipleHandlers_ConfigurationOk_ShouldWait() { s_Order.Clear(); var c = new InMemoryCommandBusConfigurationBuilder() .AllowMultipleHandlersFor <TestMultipleHandlerFromConfigParallel>(true); var bus = new InMemoryCommandBus(c.Build()); (await bus.DispatchAsync(new TestMultipleHandlerFromConfigParallel()).ConfigureAwait(false)).IsSuccess.Should().BeTrue(); s_Order.Should().HaveCount(3); s_Order.Should().Contain("One"); s_Order.Should().Contain("Two"); s_Order.Should().Contain("Three"); }
/// <summary> /// Configure the system to use InMemory Command bus for dipsatching commands, with the provided configuration. /// </summary> /// <param name="bootstrapper">Bootstrapper instance.</param> /// <param name="configurationBuilderAction">Action to apply on builder.</param> /// <param name="excludedCommandsDLLs">DLLs name to exclude from auto-configuration into IoC /// (IAutoRegisterType will be ineffective).</param> /// <returns>Bootstrapper Instance.</returns> public static Bootstrapper UseInMemoryCommandBus(this Bootstrapper bootstrapper, Action <InMemoryCommandBusConfigurationBuilder> configurationBuilderAction, params string[] excludedCommandsDLLs) { if (configurationBuilderAction == null) { throw new ArgumentNullException(nameof(configurationBuilderAction)); } InMemoryCommandBus.InitHandlersCollection(excludedCommandsDLLs); var builder = new InMemoryCommandBusConfigurationBuilder(); configurationBuilderAction(builder); return(UseInMemoryCommandBus(bootstrapper, builder.Build())); }
public async Task InMemoryCommandBus_Configuration_DispatchIfClause() { TestIfCommandHandler.ResetData(); var cfgBuilder = new InMemoryCommandBusConfigurationBuilder() .DispatchOnlyIf <TestIfCommand>(e => e.Data > 1); var b = new InMemoryCommandBus(cfgBuilder.Build()); TestIfCommandHandler.Data.Should().Be(0); await b.DispatchAsync(new TestIfCommand { Data = 1 }).ConfigureAwait(false); TestIfCommandHandler.Data.Should().Be(0); await b.DispatchAsync(new TestIfCommand { Data = 10 }).ConfigureAwait(false); TestIfCommandHandler.Data.Should().Be(10); }