Exemplo n.º 1
0
        public void Get_User_Profile_Valid_Creds()
        {
            var controller = new AuthController(_dbCtx);
            var creds      = new LoginCredentials()
            {
                Username = "******",
                Password = "******"
            };
            var result = controller.LoginUser(creds) as ObjectResult;

            var token = ((AuthResponse)result.Value).ResponseToken;

            var httpContext = new DefaultHttpContext();

            httpContext.Request.Headers[_config.authHeader] = $"Bearer {token}";

            var controllerContext = new ControllerContext()
            {
                HttpContext = httpContext
            };

            var userController = new UserManagementController(_dbCtx);

            userController.ControllerContext = controllerContext;

            var userControllerResult = userController.ViewUserProfile();

            var objResult = userControllerResult as ObjectResult;

            var response = (ObjectResponse <UserProfile>)objResult.Value;

            var profile = response.Value;

            var outcome = profile != null;

            Assert.True(outcome);
        }