Пример #1
0
        public async Task Send_message_to_test_consumer()
        {
            // add migrations by calling
            // dotnet ef migrations add --context auditdbcontext --output-dir Migrations\\Audit audit_init
            DbContextOptionsBuilder <AuditDbContext> optionsBuilder = new DbContextOptionsBuilder <AuditDbContext>().
                                                                      UseSqlServer(LocalDbConnectionStringProvider.GetLocalDbConnectionString(),
                                                                                   m =>
            {
                var executingAssembly = typeof(ContextFactory).GetTypeInfo().Assembly;

                m.MigrationsAssembly(executingAssembly.GetName().Name);
                m.MigrationsHistoryTable("__AuditEFMigrationHistoryAudit");
            });

            _store = new EntityFrameworkAuditStore(optionsBuilder.Options, "EfCoreAudit");
            using (var dbContext = _store.AuditContext)
            {
                await dbContext.Database.MigrateAsync();

                await dbContext.Database.ExecuteSqlCommandAsync("TRUNCATE TABLE EfCoreAudit");
            }

            _harness = new InMemoryTestHarness();
            _harness.OnConnectObservers += bus =>
            {
                bus.ConnectSendAuditObservers(_store);
                bus.ConnectConsumeAuditObserver(_store);
            };
            _harness.Consumer <TestConsumer>();

            await _harness.Start();

            await _harness.InputQueueSendEndpoint.Send(new A());
        }
Пример #2
0
        TransactionOutboxTestsDbContext GetDbContext()
        {
            var dbContext = new TransactionOutboxTestsDbContext(new DbContextOptionsBuilder()
                                                                .UseSqlServer(LocalDbConnectionStringProvider.GetLocalDbConnectionString("MassTransitUnitTests_TransactionOutbox")).Options);

            return(dbContext);
        }
Пример #3
0
 public static void Apply(DbContextOptionsBuilder builder)
 {
     builder.UseSqlServer(LocalDbConnectionStringProvider.GetLocalDbConnectionString(), m =>
     {
         m.MigrationsAssembly(Assembly.GetExecutingAssembly().GetName().Name);
         m.MigrationsHistoryTable($"__{nameof(FutureSagaDbContext)}");
     });
 }
Пример #4
0
        public SagaDbContext <SimpleSaga, SimpleSagaMap> CreateDbContext(string[] args)
        {
            var dbContextOptionsBuilder = new DbContextOptionsBuilder <SagaDbContext <SimpleSaga, SimpleSagaMap> >();

            dbContextOptionsBuilder.UseSqlServer(LocalDbConnectionStringProvider.GetLocalDbConnectionString(),
                                                 m =>
            {
                var executingAssembly = typeof(ContextFactory).GetTypeInfo().Assembly;
                m.MigrationsAssembly(executingAssembly.GetName().Name);
            });

            return(new SagaDbContext <SimpleSaga, SimpleSagaMap>(dbContextOptionsBuilder.Options));
        }
        public SimpleSagaDbContextWithResilienceStrategy CreateDbContext(string[] args)
        {
            var dbContextOptionsBuilder = new DbContextOptionsBuilder <SimpleSagaDbContextWithResilienceStrategy>();

            dbContextOptionsBuilder.UseSqlServer(LocalDbConnectionStringProvider.GetLocalDbConnectionString(),
                                                 m =>
            {
                var executingAssembly = typeof(ContextFactory).GetTypeInfo().Assembly;
                m.MigrationsAssembly(executingAssembly.GetName().Name);
                m.EnableRetryOnFailure();
            });

            return(new SimpleSagaDbContextWithResilienceStrategy(dbContextOptionsBuilder.Options));
        }
Пример #6
0
        public AuditDbContext CreateDbContext(string[] args)
        {
            var optionsBuilder = new DbContextOptionsBuilder <AuditDbContext>().
                                 UseSqlServer(LocalDbConnectionStringProvider.GetLocalDbConnectionString(),
                                              m =>
            {
                var executingAssembly = typeof(ContextFactory).GetTypeInfo().Assembly;

                m.MigrationsAssembly(executingAssembly.GetName().Name);
                m.MigrationsHistoryTable("__AuditEFMigrationHistoryAudit");
            });

            return(new AuditDbContext(optionsBuilder.Options, "EfCoreAudit"));
        }
Пример #7
0
        public SagaWithDependencyContext CreateDbContext(string[] args)
        {
            var dbContextOptionsBuilder =
                new DbContextOptionsBuilder <SagaWithDependencyContext>();

            dbContextOptionsBuilder.UseSqlServer(LocalDbConnectionStringProvider.GetLocalDbConnectionString(),
                                                 m =>
            {
                var executingAssembly = typeof(ContextFactory).GetTypeInfo().Assembly;
                m.MigrationsAssembly(executingAssembly.GetName().Name);
                m.MigrationsHistoryTable("__SagaWithDependencyMigrations");
            });

            return(new SagaWithDependencyContext(dbContextOptionsBuilder.Options));
        }