public void Init()
        {
            this.userRepo            = new Mock <IEfRepostory <User> >();
            this.carAdServicesMocked = new Mock <ICarAdServices>().Object;
            this.unitOfWorkMocked    = new Mock <IEfUnitOfWork>().Object;

            this.users = new List <User>()
            {
                new User {
                    UserName = "******"
                },
                new User {
                    UserName = "******"
                },
                new User {
                    UserName = "******"
                },
            };

            this.expectedUser = new User
            {
                UserName = "******"
            };

            users.Add(expectedUser);

            var usersAsQuarable = this.users.AsQueryable();

            this.userRepo.Setup(x => x.All).Returns(usersAsQuarable);
        }
Esempio n. 2
0
 public DynamicSeparateRepository(DbFactory dbFactory, ContextFactory contextFactory) :
     base(dbFactory)
 {
     DbFactory      = dbFactory;
     ContextFactory = contextFactory;
     EfUnitOfWork   = new DynamicUnitOfWork <TEntity>(contextFactory, dbFactory);
 }
Esempio n. 3
0
        public void Init()
        {
            this.carAdsRepoMock         = new Mock <IEfRepostory <CarAd> >();
            this.carBrandsRepoMock      = new Mock <IEfRepostory <CarBrand> >().Object;
            this.carModelsRepoMock      = new Mock <IEfRepostory <CarModel> >().Object;
            this.carFeatureServicesMock = new Mock <ICarFeatureServices>().Object;
            this.unitOfWorkMocked       = new Mock <IEfUnitOfWork>().Object;

            this.carAds = new List <CarAd>
            {
                new CarAd {
                    Title = "Awesome car!"
                },
                new CarAd {
                    Title = "Wohoo. Can be yours"
                },
                new CarAd {
                    Title = "Be fast!"
                },
            };

            this.expectedCarAd = new CarAd
            {
                Title = "Wohooo"
            };

            carAds.Add(expectedCarAd);

            var carAdsQuarable = this.carAds.AsQueryable();

            this.carAdsRepoMock.Setup(x => x.All).Returns(carAdsQuarable);
        }
Esempio n. 4
0
 public override void Dispose()
 {
     EfUnitOfWork?.Dispose();
     EfUnitOfWork = null;
     ContextFactory?.Dispose();
     ContextFactory = null;
 }
Esempio n. 5
0
 public InventoryService(IEfUnitOfWork unitOfWork, IMappingProvider mapper, IEfGenericRepository <Inventory> inventories)
 {
     Guard.WhenArgument(unitOfWork, "unitOfWork").IsNull().Throw();
     Guard.WhenArgument(mapper, "mapper").IsNull().Throw();
     Guard.WhenArgument(inventories, "inventories").IsNull().Throw();
     this.inventories = inventories;
 }
Esempio n. 6
0
        public AddsServices(IEfRepository <Add> adds, IEfUnitOfWork context)
        {
            Guard.WhenArgument(adds, "adds").IsNull().Throw();
            Guard.WhenArgument(context, "context").IsNull().Throw();

            this.adds    = adds;
            this.context = context;
        }
 public void Init()
 {
     this.carAdsRepoMock         = new Mock <IEfRepostory <CarAd> >().Object;
     this.carBrandsRepoMock      = new Mock <IEfRepostory <CarBrand> >().Object;
     this.carModelsRepoMock      = new Mock <IEfRepostory <CarModel> >().Object;
     this.carFeatureServicesMock = new Mock <ICarFeatureServices>().Object;
     this.unitOfWorkMocked       = new Mock <IEfUnitOfWork>().Object;
 }
Esempio n. 8
0
 public void Dispose()
 {
     EfUnitOfWork?.Dispose();
     EfUnitOfWork = null;
     _entities    = null;
     ContextFactory?.Dispose();
     ContextFactory = null;
 }
Esempio n. 9
0
        public CategoriesServices(IEfRepository <Category> categories, IEfUnitOfWork context)
        {
            Guard.WhenArgument(context, "context").IsNull().Throw();
            Guard.WhenArgument(categories, "categories").IsNull().Throw();

            this.categories = categories;
            this.context    = context;
        }
Esempio n. 10
0
 public override void Dispose()
 {
     base.Dispose();
     EfUnitOfWork = null;
     _entities    = null;
     ContextFactory?.Dispose();
     ContextFactory = null;
 }
Esempio n. 11
0
        public ProvincesServices(IEfRepository <Province> provinces, IEfUnitOfWork context)
        {
            Guard.WhenArgument(context, "context").IsNull().Throw();
            Guard.WhenArgument(provinces, "provinces").IsNull().Throw();

            this.provinces = provinces;
            this.context   = context;
        }
Esempio n. 12
0
 public ProductService(IEfUnitOfWork unitOfWork, IEfGenericRepository <Product> products, IMappingProvider mapper)
 {
     Guard.WhenArgument(unitOfWork, "unitofwork").IsNull().Throw();
     Guard.WhenArgument(products, "GenRepo").IsNull().Throw();
     Guard.WhenArgument(mapper, "mapper").IsNull().Throw();
     this.unitOfWork = unitOfWork;
     this.products   = products;
     this.mapper     = mapper;
 }
Esempio n. 13
0
 public Handler(
     ILogger <CreateUserCommand> logger,
     IEfUnitOfWork <UserDataContext> context,
     IEventBus eventBus)
 {
     _logger   = logger;
     _context  = context;
     _eventBus = eventBus;
 }
Esempio n. 14
0
 public GenericRepository(IUnitOfWork uoW)
 {
     if (uoW == null)
     {
         throw new ArgumentNullException("uoW", "GenericRepository: Unit of Work not Provided");
     }
     _unitOfWork = (IEfUnitOfWork <ObjectContext>)uoW;
     _context    = _unitOfWork.GetContext;
 }
Esempio n. 15
0
        public RegistrationService(IEfRepository <RegularUser> usersRepo,
                                   IEfUnitOfWork unitOfWork)
        {
            Guard.WhenArgument(usersRepo, "usersRepo").IsNull().Throw();
            Guard.WhenArgument(unitOfWork, "unitOfWork").IsNull().Throw();

            this.usersRepo  = usersRepo;
            this.unitOfWork = unitOfWork;
        }
Esempio n. 16
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            IEfUnitOfWork uow = DependencyResolver.Current.GetService(typeof(IEfUnitOfWork)) as IEfUnitOfWork;

            Guard.WhenArgument(uow, "unitOfWork").IsNull().Throw();
            this.unitOfWork = uow;

            base.OnActionExecuting(filterContext);
        }
Esempio n. 17
0
        public UserServices(IEfRepostory <User> usersRepo, ICarAdServices carAdServices, IEfUnitOfWork unitOfWork)
        {
            Guard.WhenArgument(usersRepo, "usersRepo").IsNull().Throw();
            Guard.WhenArgument(carAdServices, "carAdServices").IsNull().Throw();
            Guard.WhenArgument(unitOfWork, "unitOfWork").IsNull().Throw();

            this.usersRepo     = usersRepo;
            this.carAdServices = carAdServices;
            this.unitOfWork    = unitOfWork;
        }
Esempio n. 18
0
        public CarOffersService(IEfRepository <CarOffer> carOffersRepo, IEfUnitOfWork dbContext)
        {
            if (carOffersRepo == null || dbContext == null)
            {
                throw new ArgumentNullException("CarOffersRepo and dbContext can not be null!");
            }

            this.carOffersRepo = carOffersRepo;
            this.dbContext     = dbContext;
        }
Esempio n. 19
0
        public OrderService(IEfUnitOfWork unitOfWork, IMappingProvider mapper, IEfGenericRepository <Order> orders)
        {
            Guard.WhenArgument(unitOfWork, "unitOfWork").IsNull().Throw();
            Guard.WhenArgument(mapper, "mapper").IsNull().Throw();
            Guard.WhenArgument(orders, "orders").IsNull().Throw();

            this.unitOfWork = unitOfWork;
            this.mapper     = mapper;
            this.orders     = orders;
        }
Esempio n. 20
0
        public ProductService(IEfQuerable <Product> products, IEfUnitOfWork unitOfWork, IMapperService mapperService)
        {
            Guard.WhenArgument(products, nameof(products)).IsNull().Throw();
            Guard.WhenArgument(unitOfWork, nameof(unitOfWork)).IsNull().Throw();
            Guard.WhenArgument(mapperService, nameof(mapperService)).IsNull().Throw();

            this.products      = products;
            this.unitOfWork    = unitOfWork;
            this.mapperService = mapperService;
        }
Esempio n. 21
0
        public UserService(IEfRepository <RegularUser> regularUsersRepo, IEfRepository <UploadedImage> uploadedImagesRepo,
                           IEfUnitOfWork unitOfWork)
        {
            Guard.WhenArgument(regularUsersRepo, "regularUsersRepo").IsNull().Throw();
            Guard.WhenArgument(uploadedImagesRepo, "uploadedImagesRepo").IsNull().Throw();
            Guard.WhenArgument(unitOfWork, "unitOfWork").IsNull().Throw();

            this.regularUsersRepo   = regularUsersRepo;
            this.uploadedImagesRepo = uploadedImagesRepo;
            this.unitOfWork         = unitOfWork;
        }
Esempio n. 22
0
 public UserService(IMappingProvider mapper, IHashingPassword hashing, IEfUnitOfWork unitOfWork, IEfGenericRepository <User> users)
 {
     Guard.WhenArgument(mapper, "mapper").IsNull().Throw();
     Guard.WhenArgument(hashing, "hashing").IsNull().Throw();
     Guard.WhenArgument(unitOfWork, "unitOfWork").IsNull().Throw();
     Guard.WhenArgument(users, "userRepo").IsNull().Throw();
     this.hashing    = hashing;
     this.unitOfWork = unitOfWork;
     this.mapper     = mapper;
     this.users      = users;
 }
Esempio n. 23
0
        //private readonly ContextType _contextType;

        //protected MarukoBaseRepository(IEfUnitOfWork unitOfWork, ContextType contextType)
        //{
        //    if (unitOfWork == null)
        //        throw new ArgumentNullException("unitOfWork is null");

        //    UnitOfWork = unitOfWork;
        //    _unitOfWork = unitOfWork;
        //    _contextType = contextType;
        //}

        protected MarukoBaseRepository(IEfUnitOfWork unitOfWork)
        {
            if (unitOfWork == null)
            {
                throw new ArgumentNullException("unitOfWork is null");
            }

            UnitOfWork  = unitOfWork;
            _unitOfWork = unitOfWork;
            //_contextType = AttributeExtension.GetContextAttributeValue<TEntity>();
        }
Esempio n. 24
0
        public UploadedImageService(IEfRepository <UploadedImage> imagesRepo, IEfRepository <RegularUser> usersRepo,
                                    IEfUnitOfWork uow)
        {
            Guard.WhenArgument(imagesRepo, "imagesRepo").IsNull().Throw();
            Guard.WhenArgument(usersRepo, "usersRepo").IsNull().Throw();
            Guard.WhenArgument(uow, "uow").IsNull().Throw();

            this.imagesRepo = imagesRepo;
            this.usersRepo  = usersRepo;
            this.uow        = uow;
        }
Esempio n. 25
0
 public AddressService(IEfUnitOfWork unitOfWork, IMappingProvider mapper, IUserService userService, IEfGenericRepository <Address> addresses)
 {
     Guard.WhenArgument(unitOfWork, "unitOfWork").IsNull().Throw();
     Guard.WhenArgument(mapper, "mapper").IsNull().Throw();
     Guard.WhenArgument(userService, "userService").IsNull().Throw();
     Guard.WhenArgument(addresses, "addresses").IsNull().Throw();
     this.unitOfWork  = unitOfWork;
     this.mapper      = mapper;
     this.userService = userService;
     this.addresses   = addresses;
 }
Esempio n. 26
0
 public BankCardService(IEfUnitOfWork unitOfWork, IMappingProvider mapper, IUserService userService, IEfGenericRepository <BankCard> bankCards)
 {
     Guard.WhenArgument(unitOfWork, "unitOfWork").IsNull().Throw();
     Guard.WhenArgument(mapper, "mapper").IsNull().Throw();
     Guard.WhenArgument(userService, "userService").IsNull().Throw();
     Guard.WhenArgument(bankCards, "bankCards").IsNull().Throw();
     this.unitOfWork  = unitOfWork;
     this.mapper      = mapper;
     this.userService = userService;
     this.bankCards   = bankCards;
 }
Esempio n. 27
0
        public void Init()
        {
            this.repoMocked = new Mock <IEfRepository <Add> >();
            this.unitOfWork = new Mock <IEfUnitOfWork>().Object;

            this.adds = new List <Add>
            {
                new Add {
                    Description = "car", IsDeleted = false, Id = Guid.NewGuid()
                }
            }.AsQueryable();
            repoMocked.Setup(x => x.All).Returns(adds);
        }
Esempio n. 28
0
        public void Init()
        {
            this.repoMocked = new Mock <IEfRepository <City> >();
            this.unitOfWork = new Mock <IEfUnitOfWork>().Object;

            this.cities = new List <City>
            {
                new City {
                    Name = "Sofia", Id = 1, ProvinceId = 1
                }
            }.AsQueryable();
            repoMocked.Setup(x => x.All).Returns(cities);
        }
Esempio n. 29
0
        public void Init()
        {
            this.provinceRepoMocked = new Mock <IEfRepository <Province> >();
            this.unitOfWork         = new Mock <IEfUnitOfWork>().Object;

            this.provinces = new List <Province>
            {
                new Province {
                    ProvinceName = "Sofia", Id = 1
                }
            }.AsQueryable();
            provinceRepoMocked.Setup(x => x.All).Returns(provinces);
        }
Esempio n. 30
0
        public void Init()
        {
            this.repoMocked = new Mock <IEfRepository <Category> >();
            this.unitOfWork = new Mock <IEfUnitOfWork>().Object;

            this.cat = new List <Category>
            {
                new Category {
                    CategorieName = "one", Id = 1
                }
            }.AsQueryable();
            repoMocked.Setup(x => x.All).Returns(cat);
        }