Ejemplo n.º 1
0
        public BatchStateMachineTests()
        {
            _sagaRepository = new InMemorySagaRepository <BatchState>();
            _stateMachine   = new BatchStateMachine();

            _testHarness = new InMemoryTestHarness();
            _testHarness.OnConfigureInMemoryReceiveEndpoint += ConfigureInMemoryReceiveEndpoint;
            _testHarness.OnConfigureInMemoryBus             += ConfigureInMemoryBus;
        }
Ejemplo n.º 2
0
        public BatchStateMachineTests()
        {
            var dbOptionsBuilder = new DbContextOptionsBuilder()
                                   .UseSqlServer(TestConstants.ConnectionString)
                                   .EnableSensitiveDataLogging();

            _dbContextFactory = () => new SampleBatchDbContext(dbOptionsBuilder.Options);

            // Makes sure the DB is created for tests
            using (var db = _dbContextFactory())
            {
                db.Database.EnsureCreated();
            }

            _sagaRepository = EntityFrameworkSagaRepository <BatchState> .CreatePessimistic(_dbContextFactory, new CustomSqlLockStatementProvider("select * from {0}.{1} WITH (UPDLOCK, ROWLOCK) WHERE BatchId = @p0"));

            _stateMachine = new BatchStateMachine();

            _inMemoryTestHarness     = new InMemoryTestHarness();
            _inMemoryConsumerHarness = _inMemoryTestHarness.Consumer <FakeBatchJobSagaConsumer>(Guid.NewGuid().ToString());
            _inMemoryTestHarness.OnConfigureInMemoryReceiveEndpoint += ConfigureInMemoryReceiveEndpoint;
            _inMemoryTestHarness.OnConfigureInMemoryBus             += ConfigureInMemoryBus;
        }