static void SetupTenantDatabases(EndpointBehaviorBuilder <Context> builder)
    {
        EndpointConfiguration cfg = null;

        builder.CustomConfig(c => cfg = c);

        builder.When((session, context) =>
        {
            var tablePrefix = cfg.GetSettings().EndpointName().Replace(".", "_");
            MsSqlConnectionBuilder.MultiTenant.Setup("TenantA");
            MsSqlConnectionBuilder.MultiTenant.Setup("TenantB");
            var helperA     = new ConfigureEndpointHelper(cfg, tablePrefix, () => MsSqlConnectionBuilder.MultiTenant.Build("TenantA"), BuildSqlDialect.MsSqlServer, null);
            var helperB     = new ConfigureEndpointHelper(cfg, tablePrefix, () => MsSqlConnectionBuilder.MultiTenant.Build("TenantB"), BuildSqlDialect.MsSqlServer, null);
            context.Cleanup = () =>
            {
                helperA.Cleanup();
                helperB.Cleanup();
            };
            return(Task.FromResult(0));
        });
    }
예제 #2
0
 public static EndpointBehaviorBuilder <TContext> When <TContext>(this EndpointBehaviorBuilder <TContext> endpointBehavior, Func <TContext, Task <bool> > predicate, Func <IMessageSession, TContext, Task> action) where TContext : ScenarioContext
 {
     return(endpointBehavior.When(ctx => predicate(ctx).GetAwaiter().GetResult(), action));
 }