Exemplo n.º 1
0
        public void Setup()
        {
            _userRepo          = new UserRepositoryMock();
            _permissionService = new PermissionServiceMock(_userRepo);
            _avatarController  = new AvatarController(_userRepo, _permissionService)
            {
                // Mock the Http Context because this isn't an actual call avatar controller
                ControllerContext = new ControllerContext {
                    HttpContext = new DefaultHttpContext()
                }
            };
            _userController = new UserController(
                _userRepo, _permissionService, new EmailServiceMock(), new PasswordResetServiceMock());

            _userController.ControllerContext = new ControllerContext {
                HttpContext = new DefaultHttpContext()
            };
            _jwtAuthenticatedUser = new User {
                Username = "******", Password = "******"
            };
            _userRepo.Create(_jwtAuthenticatedUser);
            _jwtAuthenticatedUser = _permissionService.Authenticate(
                _jwtAuthenticatedUser.Username, _jwtAuthenticatedUser.Password).Result ?? throw new Exception();
        }