示例#1
0
 public UnitOfWork(WebApiDbEntities context)
 {
     _context = context;
     Products = new ProductRepository(_context);
     //Authors = new AuthorRepository(_context);
     User = new Repository <User>(_context);
 }
        public void ReInitializeTest()
        {
            _dbEntities     = new Mock <WebApiDbEntities>().Object;
            _userRepository = SetUpUserRepository();
            var unitOfWork = new Mock <IUnitOfWork>();

            unitOfWork.SetupGet(s => s.UserRepository).Returns(_userRepository);
            _unitOfWork   = unitOfWork.Object;
            _userServices = new UserServices(_unitOfWork);
        }
        public void ReInitializeTest()
        {
            _dbEntities        = new Mock <WebApiDbEntities>().Object;
            _productRepository = SetUpProductRepository();
            var unitOfWork = new Mock <IUnitOfWork>();

            unitOfWork.SetupGet(s => s.ProductRepository).Returns(_productRepository);
            _unitOfWork     = unitOfWork.Object;
            _productService = new ProductServices();
        }
示例#4
0
        public TokenServicesTests()
        {
            _tokens          = SetUpTokens();
            _dbEntities      = new Mock <WebApiDbEntities>().Object;
            _tokenRepository = SetUpTokenRepository();
            var unitOfWork = new Mock <IUnitOfWork>();

            unitOfWork.SetupGet(s => s.TokenRepository).Returns(_tokenRepository);
            _unitOfWork    = unitOfWork.Object;
            _tokenServices = new TokenServices(_unitOfWork);
        }
        public HttpResponseMessage Get()
        {
            List <Employee2> employeeList = new List <Employee2>();

            using (WebApiDbEntities dc = new WebApiDbEntities())
            {
                employeeList = dc.Employee2.OrderBy(x => x.FirstName).ToList();
                HttpResponseMessage response;
                response = Request.CreateResponse(HttpStatusCode.OK, employeeList);
                return(response);
            }
        }
        public void Setup()
        {
            _contacts          = SetUpContacts();
            _dbEntities        = new Mock <WebApiDbEntities>().Object;
            _contactRepository = SetUpContactRepository();
            var unitOfWork = new Mock <IUnitOfWork>();

            unitOfWork.SetupGet(s => s.ContactRepository).Returns(_contactRepository);
            _unitOfWork     = unitOfWork.Object;
            _contactService = new ContactService(_unitOfWork);
            _client         = new HttpClient {
                BaseAddress = new Uri(ServiceBaseURL)
            };
        }
示例#7
0
        public AuthRepository(bool isTest)
        {
            _context     = new WebApiDbEntities();
            _userManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(_context));
            _roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(_context));
            _provider    = new MachineKeyProtectionProvider();
            _userManager.UserTokenProvider = new DataProtectorTokenProvider <ApplicationUser>(_provider.Create("EmailConfirmation"));

            if (isTest)
            {
                _connectionString = @"Data Source=(LocalDB)\MSSQLLocalDB;Initial Catalog=DB_A15604_sportoweswiry;Integrated Security=True;";
            }
            else
            {
                _connectionString = @"Data Source=SQL5025.SmarterASP.NET;Initial Catalog=DB_A15604_sportoweswiry;User Id=DB_A15604_sportoweswiry_admin;Password=haslo123;";
            }
        }
示例#8
0
        public ProductControllerTest()
        {
            _products          = SetUpProducts();
            _tokens            = SetUpTokens();
            _dbEntities        = new Mock <WebApiDbEntities>().Object;
            _tokenRepository   = SetUpTokenRepository();
            _productRepository = SetUpProductRepository();
            var unitOfWork = new Mock <IUnitOfWork>();

            unitOfWork.SetupGet(s => s.ProductRepository).Returns(_productRepository);
            unitOfWork.SetupGet(s => s.TokenRepository).Returns(_tokenRepository);
            _unitOfWork     = unitOfWork.Object;
            _productService = new ProductServices(_unitOfWork);
            _tokenService   = new TokenServices(_unitOfWork);
            _client         = new HttpClient {
                BaseAddress = new Uri(ServiceBaseURL)
            };
            var tokenEntity = _tokenService.GenerateToken(1);

            _token = tokenEntity.AuthToken;
            _client.DefaultRequestHeaders.Add("Token", _token);
        }
示例#9
0
 /// <summary>
 /// Public Constructor,initializes privately declared local variables.
 /// </summary>
 /// <param name="context"></param>
 public GenericRepository(WebApiDbEntities context)
 {
     this.Context = context;
     this.DbSet   = context.Set <TEntity>();
 }
示例#10
0
 public UnitOfWork()
 {
     _context = new WebApiDbEntities();
 }
示例#11
0
 public UnitOfWork()
 {
     _context = new WebApiDbEntities();
 }
 /// <summary>
 /// Public Constructor,initializes privately declared local variables.
 /// </summary>
 /// <param name="context"></param>
 public TablaRepositoryCustom(WebApiDbEntities context)
 {
     this.Context = context;
     this.DbSet   = context.Set <TABLA>();
 }
示例#13
0
 /// <summary>
 /// Public Constructor,initializes privately declared local variables.
 /// </summary>
 /// <param name="context"></param>
 public FormatoServicioRepositoryCustom(WebApiDbEntities context)
 {
     this.Context = context;
     this.DbSet   = context.Set <FORMATO_SERVICIO>();
 }
示例#14
0
 /// <summary>
 /// Public Constructor,initializes privately declared local variables.
 /// </summary>
 /// <param name="context"></param>
 public NormaSectorRepositoryCustom(WebApiDbEntities context)
 {
     this.Context = context;
     this.DbSet   = context.Set <NORMA_SECTOR>();
 }
示例#15
0
        private GenericRepository <Token> _tokenRepository;     //仓储Token
        #endregion

        /// <summary>
        /// 显式的定义无参构造函数
        /// </summary>
        public UnitOfWork()
        {
            //实例化数据上下文对象
            _context = new WebApiDbEntities();
        }
示例#16
0
 public ProductRepository(WebApiDbEntities context) : base(context)
 {
 }