public void ForgotUsernameRequestFailTest_ProvidesAnInvalidEmailIdToSendTheMailTo_VerifiesByTheReturnedBoolean()
        {
            IUserApplicationService         userApplicationService         = (IUserApplicationService)_applicationContext["UserApplicationService"];
            IRegistrationApplicationService registrationApplicationService =
                (IRegistrationApplicationService)_applicationContext["RegistrationApplicationService"];

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

            userApplicationService.ActivateAccount(new ActivationCommand(activationKey, username, "burnitdown"));
            manualResetEvent.WaitOne(6000);

            userApplicationService.ForgotUsername(new ForgotUsernameCommand(email + "1"));
        }
        public void ForgotUsernameRequestSuccessTest_ProvidesAValidEmailIdToSendTheMailTo_VerifiesByTheReturnedBoolean()
        {
            IUserApplicationService         userApplicationService         = (IUserApplicationService)_applicationContext["UserApplicationService"];
            IRegistrationApplicationService registrationApplicationService =
                (IRegistrationApplicationService)_applicationContext["RegistrationApplicationService"];

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

            userApplicationService.ActivateAccount(new ActivationCommand(activationKey, username, "burnitdown"));
            // Wait for the asynchrnous email sending event to be completed otherwise no more emails can be sent until
            // this operation finishes
            manualResetEvent.WaitOne(6000);

            string returnedUsername = userApplicationService.ForgotUsername(new ForgotUsernameCommand(email));

            // Wait for the email to be sent and operation to be completed
            manualResetEvent.WaitOne(5000);
            Assert.AreEqual(username, returnedUsername);
        }
 public IHttpActionResult ForgotUsername([FromBody] ForgotUsernameParams forgotUsernameParams)
 {
     try
     {
         if (log.IsDebugEnabled)
         {
             log.Debug("ForgotUsername Call Recevied, parameters:" + forgotUsernameParams);
         }
         return
             (Ok(_userApplicationService.ForgotUsername(new ForgotUsernameCommand(forgotUsernameParams.Email))));
     }
     catch (InvalidOperationException exception)
     {
         if (log.IsErrorEnabled)
         {
             log.Error("ForgotUsername Call Exception ", exception);
         }
         return(BadRequest(exception.Message));
     }
     catch (InvalidCredentialException exception)
     {
         if (log.IsErrorEnabled)
         {
             log.Error("ForgotUsername Call Exception ", exception);
         }
         return(BadRequest(exception.Message));
     }
     catch (Exception exception)
     {
         if (log.IsErrorEnabled)
         {
             log.Error("ForgotUsername Call Exception ", exception);
         }
         return(InternalServerError());
     }
 }