Пример #1
0
        public async System.Threading.Tasks.Task Post_ShouldCreateUserAsync()
        {
            Mapper.Initialize(cfg =>
            {
                cfg.CreateMap <User, UserBindingModel>();
            });

            var user = new UserBindingModel
            {
                Email      = "*****@*****.**",
                Username   = "******",
                ClientURL  = "/User/Activate?token=B7BDBF93BA5AE5E2A7DBB926EE8ACD2A",
                IsVerified = false,
                Token      = "B7BDBF93BA5AE5E2A7DBB926EE8ACD2A"
            };
            var options = new DbContextOptionsBuilder <UpstackDbContext>()
                          .UseInMemoryDatabase(databaseName: "Post_ShouldCreateUserAsync")
                          .Options;

            using (var context = new UpstackDbContext(options))
            {
                IUnitOfWork _unitofWork = new UnitOfWork(context);
                _userController = new UserController(_unitofWork, ioptions);
                var result = await _userController.Post(user);

                _unitofWork.Save();


                var createdResult = result as OkResult;

                Assert.Equal(200, createdResult.StatusCode);
            }
        }
Пример #2
0
        public void Update_ShouldVerifyToken(string token)
        {
            var options = new DbContextOptionsBuilder <UpstackDbContext>()
                          .UseInMemoryDatabase(databaseName: "Update_ShouldVerifyCustomer")
                          .Options;

            using (var context = new UpstackDbContext(options))
            {
                IUnitOfWork _unitofWork = new UnitOfWork(context);
                _userController = new UserController(_unitofWork, ioptions);
                var result = _userController.Put(token);
                _unitofWork.Save();


                var createdResult = result as NotFoundResult;

                Assert.Equal(404, createdResult.StatusCode);
            }
        }
Пример #3
0
        public UnitOfWork(UpstackDbContext context)
        {
            _context = context;

            UserRepository = new UserRepository(_context);
        }
 public UserRepository(UpstackDbContext DbContext)
 {
     _dbContext = DbContext;
 }