예제 #1
0
        public static Mock <TRepository> GetMoqRepository <TEntity, TRepository>(this IAcDomain acDomain)
            where TEntity : class, IAggregateRoot
            where TRepository : class, IRepository <TEntity>
        {
            var moRepository = new Mock <TRepository>();
            var context      = new MoqRepositoryContext(acDomain);

            moRepository.Setup(a => a.Context).Returns(context);
            moRepository.Setup(a => a.Add(It.IsAny <TEntity>()));
            moRepository.Setup(a => a.Remove(It.IsAny <TEntity>()));
            moRepository.Setup(a => a.Update(It.IsAny <TEntity>()));
            moRepository.Setup(a => a.GetByKey(It.IsAny <Guid>())).Returns((TEntity)null);
            moRepository.Setup(a => a.AsQueryable()).Returns(new List <TEntity>().AsQueryable());

            return(moRepository);
        }
예제 #2
0
 public MoqCommonRepository(IAcDomain acDomain)
 {
     this._acDomain = acDomain;
     _context       = new MoqRepositoryContext(acDomain);
 }