Beispiel #1
0
 public ServiceTest()
 {
     _unitOfWork      = Substitute.For <IUnitOfWork>();
     _readUnitOfWork  = Substitute.For <IReadUnitOfWork>();
     _usersRepository = Substitute.For <IUsersRepository>();
     _usersService    = Substitute.For <IUsersService>();
 }
Beispiel #2
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="unitWork"></param>
        public Repository(IQueryableUnitOfWork unitWork)
        {
            //写工作单元
            this.unitOfWork = unitWork;

            //读工作单元
            if (ConfigurationManager.AppSettings["IsEnabledRW"] != "1")
            {
                this.ReadUnitWork = unitWork;
            }
        }
        public ReadRepository(IReadUnitOfWork unitOfWork)
        {
            if (unitOfWork == null)
            {
                throw new ArgumentNullException("IReadUnitOfWork can not be null");
            }

            _unitOfWork = unitOfWork;
            _context    = unitOfWork.Context as DbContext;

            if (_context == null)
            {
                throw new ArgumentNullException("IReadUnitOfWork.Context is null or not of type DbContext!");
            }
        }
Beispiel #4
0
 /// <summary>
 /// 初始化
 /// </summary>
 /// <param name="readUnitOfWork">读取数据库工作单元</param>
 /// <param name="writeUnitOfWork">写人数据库工作单元</param>
 public EfRepository(IReadUnitOfWork readUnitOfWork, IWriteUnitOfWork writeUnitOfWork)
 {
     WriteUow = writeUnitOfWork;
     ReadUow  = DbMode == Utils.Enums.DbMode.Single ? null : readUnitOfWork;
 }