Ejemplo n.º 1
0
        public virtual void GetAllTest()
        {
            //Arrange
            IQueryableUnitOfWork unitOfWork   = GetUnitOfWork();
            ITraceManager        traceManager = this.GetTraceManager();

            Repository <TEntity> repository = new Repository <TEntity>(unitOfWork, traceManager);

            //Act
            IEnumerable <TEntity> entities = repository.GetAll();

            //If Entity is parent in hierarchy invoke GetAll<K> where K:TEntity
            //for all K types in assembly
            if (HashNestedTypes)
            {
                foreach (Type type in typeof(TEntity).Assembly.GetExportedTypes())
                {
                    if (typeof(TEntity) != type && typeof(TEntity).IsAssignableFrom(type))
                    {
                        MethodInfo genericGetAll = (from m
                                                    in repository.GetType().GetMethods()
                                                    where m.Name == "GetAll" && m.IsGenericMethod
                                                    select m).First();

                        var result = genericGetAll.MakeGenericMethod(new Type[] { type })
                                     .Invoke(repository, null);

                        //Assert
                        Assert.IsNotNull(result);
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public Repository(IQueryableUnitOfWork unitOfWork)
 {
     if (unitOfWork == null)
     {
         throw new ArgumentNullException(nameof(unitOfWork));
     }
     _unitOfWork = unitOfWork;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Create a new instance of repository
 /// </summary>
 /// <param name="unitOfWork">Associated Unit Of Work</param>
 public EntityRepository(IQueryableUnitOfWork unitOfWork)
 {
     if (unitOfWork == null)
     {
         throw new ArgumentNullException("unitOfWork");
     }
     this.QueryableUnitOfWork = unitOfWork;
 }
Ejemplo n.º 4
0
        public TRepository CreateRepository <TEntity, TRepository>(IQueryableUnitOfWork unitOfWork)
            where TRepository : IRepository <TEntity>
            where TEntity : Entity
        {
            TRepository repository = (TRepository)Activator.CreateInstance(typeof(TRepository), unitOfWork);

            return(repository);
        }
Ejemplo n.º 5
0
        public BooksController SetController <T, TId>(T entity) where TId : struct where T : EntityBase <TId>
        {
            UnitOfWorkTest <T, TId> testExtensions = new UnitOfWorkTest <T, TId>();

            unitOfWork     = testExtensions.SetQueryableUnitOfWork(entity);
            bookRepository = new BookRepository(unitOfWork);
            bookService    = new BookService(bookRepository);
            return(new BooksController(bookService));
        }
Ejemplo n.º 6
0
 public BaseRepository(IQueryableUnitOfWork unitOfWork)
 {
     if (unitOfWork == null)
     {
         throw new ArgumentNullException("unitOfWork");
     }
     _unitOfWork = unitOfWork;
     DbSet       = _unitOfWork.GetDatabaseContext().Set <T>();
 }
Ejemplo n.º 7
0
        protected Repository()
        {
            if (unitOfWork == null)
            {
                throw new ArgumentNullException("unitOfWork");
            }

            UnitOfWork = unitOfWork;
        }
Ejemplo n.º 8
0
        public virtual void Repository_ConstructorWithNullContainerThrowNewArgumentNullException_Test()
        {
            //Arrange
            IQueryableUnitOfWork unitOfWork   = null;
            ITraceManager        traceManager = this.GetTraceManager();

            //Act
            Repository <TEntity> repository = new Repository <TEntity>(unitOfWork, traceManager);
        }
        /// <summary>
        /// Create a new instance of repository
        /// </summary>
        /// <param name="unitOfWork">Associated Unit Of Work</param>
        public Repository(IQueryableUnitOfWork unitOfWork)
        {
            if (unitOfWork == (IUnitOfWork)null)
            {
                throw new ArgumentNullException("unitOfWork");
            }

            _UnitOfWork = unitOfWork;
        }
Ejemplo n.º 10
0
        public virtual void Repository_AddNullItemThrowArgumentNullException_Test()
        {
            //Arrange
            IQueryableUnitOfWork unitOfWork   = GetUnitOfWork();
            ITraceManager        traceManager = this.GetTraceManager();
            //Act
            Repository <TEntity> repository = new Repository <TEntity>(unitOfWork, traceManager);

            repository.Add(null);
        }
Ejemplo n.º 11
0
        public Repository(IQueryableUnitOfWork unitOfWork)
        {
            if (unitOfWork == (IUnitOfWork)null)
            {
                throw new ArgumentNullException("unitOfWork");
            }

            this.unitOfWork = unitOfWork;
            this.logger     = LogManager.GetCurrentClassLogger();
        }
Ejemplo n.º 12
0
        public Repository(IQueryableUnitOfWork unitOfWork, IDbSet <TEntity> set)
        {
            if (unitOfWork == null)
            {
                throw new ArgumentNullException(nameof(unitOfWork));
            }

            _UnitOfWork = unitOfWork;
            _Set        = set;
        }
Ejemplo n.º 13
0
        public virtual void Repository_ApplyChangesWithNullCollectionThrowNewArgumentNullException_Test()
        {
            //Arrange
            IQueryableUnitOfWork unitOfWork   = GetUnitOfWork();
            ITraceManager        traceManager = this.GetTraceManager();

            //Act
            ExtendedRepository <TEntity> repository = new ExtendedRepository <TEntity>(unitOfWork, traceManager);

            repository.Modify((List <TEntity>)null);
        }
Ejemplo n.º 14
0
        public virtual void GenericRepositoryApplyChangesWithNullItemThrowNewArgumentNullException_Test()
        {
            //Arrange
            IQueryableUnitOfWork unitOfWork   = GetUnitOfWork();
            ITraceManager        traceManager = this.GetTraceManager();

            //Act
            Repository <TEntity> repository = new Repository <TEntity>(unitOfWork, traceManager);

            repository.Modify((TEntity)null);
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Create a new instance of repository
 /// </summary>
 /// <param name="unitOfWork">Associated Unit Of Work</param>
 public RepositoryObject(IQueryableUnitOfWork unitOfWork)
 {
     if (unitOfWork == (IUnitOfWork)null)
     {
         throw new ArgumentNullException("unitOfWork");
     }
     else
     {
         uow = unitOfWork;
     }
 }
Ejemplo n.º 16
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="unitWork"></param>
        public Repository(IQueryableUnitOfWork unitWork)
        {
            //写工作单元
            this.unitOfWork = unitWork;

            //读工作单元
            if (ConfigurationManager.AppSettings["IsEnabledRW"] != "1")
            {
                this.ReadUnitWork = unitWork;
            }
        }
Ejemplo n.º 17
0
        public EFRepository(IQueryableUnitOfWork unitOfWork)
        {
            if (unitOfWork == (IUnitOfWork)null)
            {
                throw new ArgumentNullException("unitOfWork");
            }

            _UnitOfWork = unitOfWork;
            //_context = context;
            //_dbSet = context.Set<T>();
        }
Ejemplo n.º 18
0
        public void Repository_GetFilteredElementsWithNullFilterThrowNewArgumentNullException_Test()
        {
            //Arrange
            IQueryableUnitOfWork unitOfWork   = GetUnitOfWork();
            ITraceManager        traceManager = this.GetTraceManager();

            Repository <TEntity> repository = new Repository <TEntity>(unitOfWork, traceManager);

            //Act
            IEnumerable <TEntity> entities = repository.GetFilteredElements(null);
        }
Ejemplo n.º 19
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (_unitOfWork != null)
         {
             _unitOfWork.Dispose();
             _unitOfWork = null;
         }
     }
 }
Ejemplo n.º 20
0
        public void Repository_GetBySpecWithNullSpecThrowArgumentNullException_Test()
        {
            //Arrange
            IQueryableUnitOfWork unitOfWork   = GetUnitOfWork();
            ITraceManager        traceManager = this.GetTraceManager();

            Repository <TEntity> repository = new Repository <TEntity>(unitOfWork, traceManager);

            //Act
            repository.GetBySpec((ISpecification <TEntity>)null);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Create a new instance of repository
        /// </summary>
        /// <param name="unitOfWork">Associated Unit Of Work</param>
        /// <param name="logger">Logger</param>
        public Repository(IQueryableUnitOfWork unitOfWork,
                          ILogger <Repository <TEntity> > logger)
        {
            if (unitOfWork == (IUnitOfWork)null)
            {
                throw new ArgumentNullException("unitOfWork");
            }

            _UnitOfWork = unitOfWork;
            _logger     = logger;
        }
Ejemplo n.º 22
0
        public void Repository_GetFilteredElementsWithFilterNullAndOrderNotNullThrowNewArgumentNullException_Test()
        {
            //Arrange
            IQueryableUnitOfWork unitOfWork   = GetUnitOfWork();
            ITraceManager        traceManager = this.GetTraceManager();

            Repository <TEntity> repository = new Repository <TEntity>(unitOfWork, traceManager);

            //Act
            IEnumerable <TEntity> entities = repository.GetFilteredElements <int>(null, OrderByExpression, false);
        }
Ejemplo n.º 23
0
        public virtual void Repository_DeleteValidItemTest()
        {
            //Arrange
            IQueryableUnitOfWork unitOfWork   = GetUnitOfWork();
            ITraceManager        traceManager = this.GetTraceManager();

            //Act
            Repository <TEntity> repository = new Repository <TEntity>(unitOfWork, traceManager);
            TEntity item = new TEntity();

            repository.Remove(item);
        }
Ejemplo n.º 24
0
        public void Repository_GetPagedElementsWithNullSpecThrowNewArgumentNullException_Test()
        {
            //Arrange
            IQueryableUnitOfWork unitOfWork   = GetUnitOfWork();
            ITraceManager        traceManager = this.GetTraceManager();
            Repository <TEntity> repository   = new Repository <TEntity>(unitOfWork, traceManager);
            int pageIndex = 0;
            int pageCount = 10;

            //Act
            IEnumerable <TEntity> entities = repository.GetPagedElements <int>(pageIndex, pageCount, OrderByExpression, null, false);
        }
Ejemplo n.º 25
0
        public virtual void Repository_ApplyChangesValidItem_Test()
        {
            //Arrange
            IQueryableUnitOfWork unitOfWork   = GetUnitOfWork();
            ITraceManager        traceManager = this.GetTraceManager();

            //Act
            Repository <TEntity> repository = new Repository <TEntity>(unitOfWork, traceManager);
            TEntity item = new TEntity();

            repository.Modify(item);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Default constructor for GenericRepository
        /// </summary>
        /// <param name="unitOfWork">A unit of work  for this repository</param>
        /// <param name="traceManager">TraceManager dependency</param>
        public ExtendedRepository(IQueryableUnitOfWork unitOfWork)
            : base(unitOfWork)
        {
            //check preconditions
            if (unitOfWork == (IQueryableUnitOfWork)null)
            {
                throw new ArgumentNullException("unitOfWork", Resources.Exception_ContainerCannotBeNull);
            }

            //set internal values
            m_CurrentUoW = unitOfWork;
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Create a new instance of repository
        /// </summary>
        /// <param name="unitOfWork">Associated Unit Of Work</param>
        /// <param name="traceManager">Trace store.</param>
        public ReadOnlyRepository(IQueryableUnitOfWork unitOfWork)
        {
            //check preconditions
            if (unitOfWork == (IQueryableUnitOfWork)null)
            {
                throw new ArgumentNullException("unitOfWork", Resources.Exception_ContainerCannotBeNull);
            }

            //set internal values
            m_UnitOfWork = unitOfWork;

            ((DbContext)this.UnitOfWork).Database.Log = Console.Write;
        }
Ejemplo n.º 28
0
        public virtual void Repository_ApplyChangesInCollection_Test()
        {
            //Arrange
            IQueryableUnitOfWork unitOfWork   = GetUnitOfWork();
            ITraceManager        traceManager = this.GetTraceManager();

            //Act
            ExtendedRepository <TEntity> repository = new ExtendedRepository <TEntity>(unitOfWork, traceManager);
            List <TEntity> items = new List <TEntity>();

            items.Add(new TEntity());
            repository.Modify(items);
        }
Ejemplo n.º 29
0
        public void Repository_GetFilteredElementsWithPaggingNullFilterExpressionThrowNewArgumentNullException_Test()
        {
            //Arrange
            IQueryableUnitOfWork unitOfWork   = GetUnitOfWork();
            ITraceManager        traceManager = this.GetTraceManager();

            Repository <TEntity> repository = new Repository <TEntity>(unitOfWork, traceManager);
            int pageIndex = 1;
            int pageCount = 1;

            //Act
            IEnumerable <TEntity> entities = repository.GetFilteredElements <int>(null, pageIndex, pageCount, null, false);
        }
Ejemplo n.º 30
0
        public virtual void Repository_InvokeConstructor_Test()
        {
            //Arrange
            IQueryableUnitOfWork unitOfWork   = GetUnitOfWork();
            ITraceManager        traceManager = this.GetTraceManager();

            //Act
            Repository <TEntity> repository = new Repository <TEntity>(unitOfWork, traceManager);
            IUnitOfWork          actual     = repository.UnitOfWork;

            //Assret
            Assert.AreEqual(unitOfWork, actual);
        }
Ejemplo n.º 31
0
 public OrganizationQuery(IQueryableUnitOfWork unitOfWork)
 {
     _unitOfWork = unitOfWork;
 }
Ejemplo n.º 32
0
 public RequestQuery(IQueryableUnitOfWork unitOfWork)
 {
     _unitOfWork = unitOfWork;
 }
Ejemplo n.º 33
0
 public AircraftSeriesQuery(IQueryableUnitOfWork unitOfWork)
 {
     _unitOfWork = unitOfWork;
 }
Ejemplo n.º 34
0
 public SnHistoryQuery(IQueryableUnitOfWork unitOfWork)
 {
     _unitOfWork = unitOfWork;
 }
Ejemplo n.º 35
0
 public PurchaseInvoiceQuery(IQueryableUnitOfWork unitOfWork)
 {
     _unitOfWork = unitOfWork;
 }
Ejemplo n.º 36
0
 public ContractEngineQuery(IQueryableUnitOfWork unitOfWork)
 {
     _unitOfWork = unitOfWork;
 }
Ejemplo n.º 37
0
 public ItemQuery(IQueryableUnitOfWork unitOfWork)
 {
     _unitOfWork = unitOfWork;
 }
Ejemplo n.º 38
0
 public AircraftPurchaseReceptionQuery(IQueryableUnitOfWork unitOfWork)
 {
     _unitOfWork = unitOfWork;
 }
Ejemplo n.º 39
0
 public EnginePlanQuery(IQueryableUnitOfWork unitOfWork)
 {
     _unitOfWork = unitOfWork;
 }
Ejemplo n.º 40
0
 public CreditNoteQuery(IQueryableUnitOfWork unitOfWork)
 {
     _unitOfWork = unitOfWork;
 }
Ejemplo n.º 41
0
 public ApprovalDocQuery(IQueryableUnitOfWork unitOfWork)
 {
     _unitOfWork = unitOfWork;
 }
Ejemplo n.º 42
0
 public ManagerQuery(IQueryableUnitOfWork unitOfWork)
 {
     _unitOfWork = unitOfWork;
 }
Ejemplo n.º 43
0
 public AcConfigQuery(IQueryableUnitOfWork unitOfWork)
 {
     _unitOfWork = unitOfWork;
 }
Ejemplo n.º 44
0
 public MaintainWorkQuery(IQueryableUnitOfWork unitOfWork)
 {
     _unitOfWork = unitOfWork;
 }
Ejemplo n.º 45
0
 public RelatedDocQuery(IQueryableUnitOfWork unitOfWork)
 {
     _unitOfWork = unitOfWork;
 }
Ejemplo n.º 46
0
 public TradeQuery(IQueryableUnitOfWork unitOfWork)
 {
     _unitOfWork = unitOfWork;
 }
Ejemplo n.º 47
0
 public DocumentPathQuery(IQueryableUnitOfWork unitOfWork)
 {
     _unitOfWork = unitOfWork;
 }
Ejemplo n.º 48
0
 public CtrlUnitQuery(IQueryableUnitOfWork unitOfWork)
 {
     _unitOfWork = unitOfWork;
 }
Ejemplo n.º 49
0
 public BasicConfigGroupQuery(IQueryableUnitOfWork unitOfWork)
 {
     _unitOfWork = unitOfWork;
 }
Ejemplo n.º 50
0
 public AnnualQuery(IQueryableUnitOfWork unitOfWork)
 {
     _unitOfWork = unitOfWork;
 }
Ejemplo n.º 51
0
 public IssuedUnitQuery(IQueryableUnitOfWork unitOfWork)
 {
     _unitOfWork = unitOfWork;
 }
Ejemplo n.º 52
0
 public PaymentScheduleQuery(IQueryableUnitOfWork unitOfWork)
 {
     _unitOfWork = unitOfWork;
 }
Ejemplo n.º 53
0
 public AircraftLicenseQuery(IQueryableUnitOfWork unitOfWork)
 {
     _unitOfWork = unitOfWork;
 }
Ejemplo n.º 54
0
 public BasicConfigHistoryQuery(IQueryableUnitOfWork unitOfWork)
 {
     _unitOfWork = unitOfWork;
 }
Ejemplo n.º 55
0
 public ProgrammingFileQuery(IQueryableUnitOfWork unitOfWork)
 {
     _unitOfWork = unitOfWork;
 }
Ejemplo n.º 56
0
 public SnRemInstRecordQuery(IQueryableUnitOfWork unitOfWork)
 {
     _unitOfWork = unitOfWork;
 }
Ejemplo n.º 57
0
 public AirlinesQuery(IQueryableUnitOfWork unitOfWork)
 {
     _unitOfWork = unitOfWork;
 }
Ejemplo n.º 58
0
 public GuaranteeQuery(IQueryableUnitOfWork unitOfWork)
 {
     _unitOfWork = unitOfWork;
 }
Ejemplo n.º 59
0
 public CAACAircraftTypeQuery(IQueryableUnitOfWork unitOfWork)
 {
     _unitOfWork = unitOfWork;
 }
Ejemplo n.º 60
0
 public AircraftCategoryQuery(IQueryableUnitOfWork unitOfWork)
 {
     _unitOfWork = unitOfWork;
 }