Esempio n. 1
0
 public UserController(
     UserRegisterHandler userRegisterHandler,
     UserLoginHandler userLoginHandler,
     UserLogoutHandler userLogoutHandler,
     UserGetInfoHandler userGetInfoHandler)
 {
     _userRegisterHandler = userRegisterHandler;
     _userLoginHandler    = userLoginHandler;
     _userLogoutHandler   = userLogoutHandler;
     _userGetInfoHandler  = userGetInfoHandler;
 }
Esempio n. 2
0
        public async Task RegisterUser_ThrowsDuplicateException_WhenUserAlredyExists()
        {
            //Arrange
            Mock <IApplicationUsersRepository>    applicationRepository = new Mock <IApplicationUsersRepository>();
            Mock <IApplicationUsersUnitOfWork>    unitOfWork            = new Mock <IApplicationUsersUnitOfWork>();
            Mock <IStorageService>                storageService        = new Mock <IStorageService>();
            Mock <ILogger <UserRegisterHandler> > logger = new Mock <ILogger <UserRegisterHandler> >();

            applicationRepository.Setup(r => r.CreateUser(It.IsAny <ApplicationUser>(), It.IsAny <String>())).Throws <DuplicateException>();
            unitOfWork.Setup(u => u.ApplicationUsers).Returns(applicationRepository.Object);

            Mock <IMapper> mapper = new Mock <IMapper>();

            mapper.Setup(m => m.Map <UserRegisteredEvent>(It.IsAny <Object>())).Returns(new UserRegisteredEvent(Guid.NewGuid(), String.Empty, String.Empty, String.Empty));
            Mock <IMessagePublisher <UserRegisteredEvent> > messagePublisher = new Mock <IMessagePublisher <UserRegisteredEvent> >();

            messagePublisher.Setup(p => p.Publish(It.IsAny <UserRegisteredEvent>(), It.IsAny <Guid>())).Returns(Task.CompletedTask);


            var handler = new UserRegisterHandler(
                unitOfWork.Object,
                storageService.Object,
                messagePublisher.Object,
                mapper.Object,
                logger.Object);

            //Act/Assert
            await Assert.ThrowsAsync <DuplicateException>(async() =>
            {
                await handler.HandleAsync(new RegisterUserCommand(
                                              id: Guid.NewGuid(),
                                              firstName: String.Empty,
                                              lastName: String.Empty,
                                              password: String.Empty,
                                              email: String.Empty,
                                              education: String.Empty,
                                              occupation: String.Empty,
                                              dateOfBirth: DateTime.Now,
                                              image: null
                                              ));
            });
        }
Esempio n. 3
0
 public UserController(
     UserRegisterHandler userRegisterHandler,
     UserConfirmEmailHandler userConfirmEmailHandler,
     UserLoginHandler userLoginHandler,
     UserLogoutHandler userLogoutHandler,
     UserLogoutFromAllDevicesHandler userLogoutFromAllDevicesHandler,
     UserSendResetPasswordEmailHandler sendResetPasswordEmailHandler,
     UserResetPasswordHandler userResetPasswordHandler,
     UserGetInfoHandler userGetInfoHandler,
     UserEditHandler userEditHandler)
 {
     _userRegisterHandler               = userRegisterHandler;
     _userConfirmEmailHandler           = userConfirmEmailHandler;
     _userLoginHandler                  = userLoginHandler;
     _userLogoutHandler                 = userLogoutHandler;
     _userLogoutFromAllDevicesHandler   = userLogoutFromAllDevicesHandler;
     _userSendResetPasswordEmailHandler = sendResetPasswordEmailHandler;
     _userResetPasswordHandler          = userResetPasswordHandler;
     _userGetInfoHandler                = userGetInfoHandler;
     _userEditHandler = userEditHandler;
 }
Esempio n. 4
0
 public void RegisterUser()
 {
     MobileStaticVariables.UserStatus = UserStatusEnum.Unlogged;
     UserRegisterHandler?.Invoke();
 }