Exemplo n.º 1
0
 public void Init()
 {
     _repository        = new UserIdentityRepository();
     _missionRepository = new MissionRepository();
     _userRepository    = new UserRepository();
     _ratingRepository  = new RatingRepository();
     _service           = new UserIdentityService(_repository);
     _userService       = new UserService(_userRepository, _missionRepository, _ratingRepository, new AppCountersService(new AppCountersRepository()));
     _controller        = new UserIdentityController(_userService, _service, new MailService(null, _repository), null);
 }
Exemplo n.º 2
0
        public void should_get_profile_response_for_case_admin()
        {
            _claimsPrincipal = new ClaimsPrincipalBuilder()
                               .WithRole(AppRoles.CaseAdminRole)
                               .Build();
            _controller = SetupControllerWithClaims(_claimsPrincipal);
            var response = _controller.GetUserProfile();
            var result   = response.Result.As <OkObjectResult>();

            result.Should().NotBeNull();
            var userProfile = (UserProfileResponse)result.Value;

            userProfile.IsVhOfficerAdministratorRole.Should().BeFalse();
            userProfile.IsCaseAdministrator.Should().BeTrue();
        }
        private UserIdentityController GetUserIdentityController()
        {
            var mockIdentityService = new Mock <IUserIdentityService>();

            mockIdentityService.Setup(identit => identit.IdentityUser(It.Is <string>(s => s.Contains(invalidUser.Name)),
                                                                      It.IsAny <string>())).Returns(invalidUser);

            mockIdentityService.Setup(identit => identit.IdentityUser(It.Is <string>(s => s.Contains(validUser.Name)),
                                                                      It.Is <string>(s => s.Contains(validUser.Password)))).Returns(validUser);

            mockIdentityService.Setup(identit => identit.RegisterUser(It.Is <string>(s => s.Contains(validUser.Name)),
                                                                      It.IsAny <string>())).Returns(OperationDetails.Error(""));

            mockIdentityService.Setup(identit => identit.RegisterUser(It.Is <string>(s => s.Contains(validUser.Name)),
                                                                      It.Is <string>(s => s.Contains(validUser.Password)))).Returns(validOperationDetails);

            mockIdentityService.Setup(identit => identit.GetIdentity(It.Is <User>(u => u.Name == validUser.Name && u.Password == validUser.Password)))
            .Returns("token");

            var controller = new UserIdentityController(mockIdentityService.Object);

            return(controller);
        }