public void BeforeEachTest()
 {
     sessionFactory = new DbContextSessionFactory();
     uow = new DbUnitOfWork(sessionFactory);
     persister = new DbSagaPersister(sessionFactory);
     saga = GetTestSaga();
 }
Exemplo n.º 2
0
        private static void Main(string[] args)
        {
            Database.SetInitializer(new SagaDatabaseInitializer());
            var sessionFactory = new DbContextSessionFactory();
            var persister = new DbSagaPersister(sessionFactory);
            var saga = new SimpleSagaData
                           {
                               Id = Guid.NewGuid(),
                               BusinessId = 1
                           };
            persister.Save(saga);

            var action = new Action(() =>
                                        {
                                            while (true)
                                            {
                                                try
                                                {
                                                    persister.Update(saga);
                                                }
                                                catch (DbUpdateConcurrencyException exc)
                                                {
                                                    Console.WriteLine("Optimistic concurrency check failed.");
                                                }
                                            }
                                        });

            var task1 = new Task(action);
            var task2 = new Task(action);
            task1.Start();
            task2.Start();

            Console.WriteLine("Processing...");
            Console.ReadLine();
        }
Exemplo n.º 3
0
 public DbUnitOfWork(DbContextSessionFactory factory)
 {
     sessionFactory = factory;
 }
Exemplo n.º 4
0
 public DbUnitOfWork(DbContextSessionFactory factory)
 {
     sessionFactory = factory;
 }
Exemplo n.º 5
0
 public DbSagaPersister(DbContextSessionFactory factory)
 {
     _sessionFactory = factory;
 }