public void CancelActivationAfterAccountActivatedFailTest_ChecksIfTheAccountActivationIsNotCancelledAfterAccountHasBeenActivated_VerifiesByExpectingException()
        {
            IUserApplicationService         userApplicationService         = (IUserApplicationService)_applicationContext["UserApplicationService"];
            IRegistrationApplicationService registrationApplicationService = (IRegistrationApplicationService)_applicationContext["RegistrationApplicationService"];
            IUserRepository userRepository = (IUserRepository)_applicationContext["UserRepository"];

            string username         = "******";
            string email            = "*****@*****.**";
            string password         = "******";
            string activationKey    = registrationApplicationService.CreateAccount(new SignupUserCommand(email, username, password, "USA", TimeZone.CurrentTimeZone, ""));
            bool   accountActivated = userApplicationService.ActivateAccount(new ActivationCommand(activationKey, username, password));

            Assert.IsTrue(accountActivated);
            User userBeforeCancel = userRepository.GetUserByUserName(username);

            Assert.IsNotNull(userBeforeCancel);
            Assert.IsTrue(userBeforeCancel.IsActivationKeyUsed.Value);
            // Exception is raised here
            userApplicationService.CancelAccountActivation(new CancelActivationCommand(activationKey));

            User userAfterCancel = userRepository.GetUserByUserName(username);

            Assert.IsNull(userAfterCancel);
            Assert.IsTrue(userBeforeCancel.IsActivationKeyUsed.Value);
        }
        public void CancelAccountActivationFailedDueToInvalidActivationKey_MakesSureAccountActivationDoesNotGetCancelledWhenInvfalidActivationKeyIsGiven_VerifiesByExpectingException()
        {
            IUserApplicationService         userApplicationService         = (IUserApplicationService)_applicationContext["UserApplicationService"];
            IRegistrationApplicationService registrationApplicationService =
                (IRegistrationApplicationService)_applicationContext["RegistrationApplicationService"];

            string username      = "******";
            string email         = "*****@*****.**";
            string password      = "******";
            string activationKey = registrationApplicationService.CreateAccount(new SignupUserCommand(email, username, password, "USA", TimeZone.CurrentTimeZone, ""));

            userApplicationService.CancelAccountActivation(new CancelActivationCommand(activationKey + "1"));
        }
        public void CancelAccountActivationSuccessfulTest_ChecksIfTheAccountActivationIsCancelledAsExpectedWhenEverythingIsInOrder_VerifiesByQueryingTheDatabase()
        {
            IUserApplicationService         userApplicationService         = (IUserApplicationService)_applicationContext["UserApplicationService"];
            IRegistrationApplicationService registrationApplicationService = (IRegistrationApplicationService)_applicationContext["RegistrationApplicationService"];
            IUserRepository userRepository = (IUserRepository)_applicationContext["UserRepository"];

            string username                = "******";
            string email                   = "*****@*****.**";
            string password                = "******";
            string activationKey           = registrationApplicationService.CreateAccount(new SignupUserCommand(email, username, password, "USA", TimeZone.CurrentTimeZone, ""));
            bool   cancelAccountActivation = userApplicationService.CancelAccountActivation(new CancelActivationCommand(activationKey));

            Assert.IsTrue(cancelAccountActivation);

            User userByUserName = userRepository.GetUserByUserName(username);

            Assert.IsNull(userByUserName);
        }
 public IHttpActionResult CancelUserActivation([FromBody] CancelActivationParams cancelActivationParams)
 {
     try
     {
         if (log.IsDebugEnabled)
         {
             log.Debug("CanceUserActivation Call Recevied, parameters:" + cancelActivationParams);
         }
         _userApplicationService.CancelAccountActivation(
             new CancelActivationCommand(cancelActivationParams.ActivationKey));
         return
             (Ok("cancelled"));
     }
     catch (InvalidOperationException exception)
     {
         if (log.IsErrorEnabled)
         {
             log.Error("CanceUserActivation Call Exception ", exception);
         }
         return(BadRequest(exception.Message));
     }
     catch (InvalidCredentialException exception)
     {
         if (log.IsErrorEnabled)
         {
             log.Error("CanceUserActivation Call Exception ", exception);
         }
         return(BadRequest(exception.Message));
     }
     catch (Exception exception)
     {
         if (log.IsErrorEnabled)
         {
             log.Error("CanceUserActivation Call Exception ", exception);
         }
         return(InternalServerError());
     }
 }
        public void CancelAccountActivationNoAccountExistsFail_MakesSureAccountActivationDoesNotGetCancelledWhenNoSuchAccountIsPresent_VerifiesByExpectingException()
        {
            IUserApplicationService userApplicationService = (IUserApplicationService)_applicationContext["UserApplicationService"];

            userApplicationService.CancelAccountActivation(new CancelActivationCommand("1eew355ygf43rdwq1"));
        }