Ejemplo n.º 1
0
        public void Can_get_current_transaction()
        {
            var transaction = new FakeDbContextTransaction();

            var context = InMemoryTestHelpers.Instance.CreateContext(
                new ServiceCollection().AddSingleton <IDbContextTransactionManager>(
                    new FakeDbContextTransactionManager(transaction)));

            Assert.Same(transaction, context.Database.CurrentTransaction);
        }
Ejemplo n.º 2
0
        public async Task Can_begin_transaction(bool async)
        {
            var transaction = new FakeDbContextTransaction();

            var context = InMemoryTestHelpers.Instance.CreateContext(
                new ServiceCollection().AddSingleton <IDbContextTransactionManager>(
                    new FakeDbContextTransactionManager(transaction)));

            Assert.Same(
                transaction,
                async
                    ? await context.Database.BeginTransactionAsync()
                    : context.Database.BeginTransaction());
        }
Ejemplo n.º 3
0
 public FakeDbContextTransactionManager(FakeDbContextTransaction transaction)
 {
     _transaction = transaction;
 }