예제 #1
0
        /// <summary>
        /// Constructs a new SqlRepo object using the provided DbContext and DbTransaction
        /// </summary>
        /// <param name="context">Entity Framework DbContext</param>
        /// <param name="trans">Subclass of DbTransaction that rolls back on Dispose (may be null)</param>
        public SqlRepo(TContext context, TestingTransaction <TContext> trans)
        {
            Transaction = trans;
            Context     = context;

            //attach context to transaction, when appropriate
            if (trans != null && trans.Context != context &&
                trans.TransactionState == TransactionState.Begun)
            {
                trans.AttachContext(context);
            }

            _dbset = Context.Set <TEntity>();
        }
예제 #2
0
 public UnitTestBase()
 {
     Context     = new TContext();
     Transaction = new TestingTransaction <TContext>(Context);
 }
 public IntegrationTestBase()
 {
     Context     = new TContext();
     Transaction = new TestingTransaction <TContext>(Context, TransactionState.Begun);
 }