public void Setup()
        {
            _dbSetUpHelper   = new DatabaseSetUpHelper();
            _serviceProvider = _dbSetUpHelper.GetServiceDependencyResolver();
            _context         = _dbSetUpHelper.GetContext();

            _userController = new UserController(_serviceProvider.GetService <IOptions <AppSettings> >(), _context);
        }
        public void Setup()
        {
            _dbSetUpHelper   = new DatabaseSetUpHelper();
            _serviceProvider = _dbSetUpHelper.GetServiceDependencyResolver();
            _context         = _dbSetUpHelper.GetContext();

            _httpContextHelper = new HttpContextHelper();
            var httpContext = _httpContextHelper.GetHttpContext();
            var objClaim    = _httpContextHelper.GetClaimsIdentity();

            _userController = new UserController(_serviceProvider.GetService <IOptions <AppSettings> >(), _context)
            {
                ControllerContext = new ControllerContext
                {
                    HttpContext = httpContext
                }
            };
            httpContext.User = new ClaimsPrincipal(objClaim);
        }
Ejemplo n.º 3
0
        public void TestSuccessfulLogin()
        {
            UserController             userController = new UserController(_serviceProvider.GetService <IOptions <AppSettings> >(), _context);
            ActionResult <LoggedInDto> response       = userController.Login(new LoginDto
            {
                UserName = "******",
                Password = "******"
            });

            Assert.IsNotNull(response.Value);
            Assert.IsFalse(string.IsNullOrEmpty(response.Value.UserName));
            Assert.IsFalse(string.IsNullOrEmpty(response.Value.Token));
        }