protected override void Context()
        {
            base.Context();
            _createAccountRequest = new CreateAccountRequest
                                        {
                                            FirstName = "Colin",
                                            LastName = "Callahan",
                                            EmailAddress = "*****@*****.**",
                                        };

            AuthorizationService.Stub(
                x => x.CanExecute(Arg<string>.Is.Equal(Username), Arg<Type>.Is.Equal(typeof (CreateAccountRequest)))).
                Return(true);

            _createAccountRequestValidator = MockRepository.GenerateStub<CreateAccountRequestValidator>();
            _createAccountRequestValidator.Stub(
                x => x.Validate(Arg<CreateAccountRequest>.Is.Equal(_createAccountRequest)))
                .Return(new ValidationResult());

            ValidatorFactory.Stub(
                x => x.GetValidator<CreateAccountRequest>())
                .Return(_createAccountRequestValidator);

            AccountRepository.Stub(x => x.UserNameExists(Arg<string>.Is.Equal(_createAccountRequest.Username)))
                .Return(true);

            _expectedCreateAccountResponse = new CreateAccountResponse
                                                 {
                                                     Success = false,
                                                     Errors = new List<string>{"The username " + _createAccountRequest.Username + " is unavailable.",}
                                                 };
        }
        protected override void Context()
        {
            base.Context();
            AuthorizationService.Stub(x => x.CanExecute(Arg<string>.Is.Anything, Arg<Type>.Is.Anything)).Return(false);

            _expectedReponse = new CreateAccountResponse
                                   {
                                       Success = false,
                                       Errors = new List<string> {"User is not authorized to Create Account"}
                                   };
        }
        protected override void Context()
        {
            base.Context();

            _createAccountRequest = new CreateAccountRequest();

            AuthorizationService.Stub(
                x => x.CanExecute(Arg<string>.Is.Equal(Username), Arg<Type>.Is.Equal(typeof (CreateAccountRequest)))).
                Return(true);

            _validationResultReturnedFromValidator = new ValidationResult(new List<ValidationFailure>
                                                                              {
                                                                                  new ValidationFailure("FirstName",
                                                                                                        "First Name cannot be empty."),
                                                                                  new ValidationFailure("LastName",
                                                                                                        "Last Name cannot be empty."),
                                                                                  new ValidationFailure("EmailAddress",
                                                                                                        "Email Address cannot be empty."),
                                                                                  new ValidationFailure("Username",
                                                                                                        "Username cannot be empty."),
                                                                                  new ValidationFailure("Role",
                                                                                                        "Role cannot be empty."),

                                                                              });

            _createAccountRequestValidator = MockRepository.GenerateStub<CreateAccountRequestValidator>();
            _createAccountRequestValidator.Stub(
                x => x.Validate(Arg<CreateAccountRequest>.Is.Equal(_createAccountRequest)))
                .Return(_validationResultReturnedFromValidator);

            ValidatorFactory.Stub(
                x => x.GetValidator<CreateAccountRequest>())
                .Return(_createAccountRequestValidator);

            _expectedCreateAccountResponse = new CreateAccountResponse
                                                 {
                                                     Success = false,
                                                     Errors = _validationResultReturnedFromValidator.Errors.Select(x=>x.ErrorMessage),
                                                 };
        }
        protected override void Context()
        {
            base.Context();
            _createAccountRequest = new CreateAccountRequest
                                        {
                                            FirstName = "Colin",
                                            LastName = "Callahan",
                                            EmailAddress = "*****@*****.**",
                                            Username = "******",
                                            Role = Role.Employee,
                                        };

            AuthorizationService.Stub(
                x => x.CanExecute(Arg<string>.Is.Equal(Username), Arg<Type>.Is.Equal(typeof (CreateAccountRequest)))).
                Return(true);

            _createAccountRequestValidator = MockRepository.GenerateStub<CreateAccountRequestValidator>();
            _createAccountRequestValidator.Stub(
                x => x.Validate(Arg<CreateAccountRequest>.Is.Equal(_createAccountRequest)))
                .Return(new ValidationResult());

            ValidatorFactory.Stub(
                x => x.GetValidator<CreateAccountRequest>())
                .Return(_createAccountRequestValidator);

            AccountRepository.Stub(x => x.UserNameExists(Arg<string>.Is.Equal(_createAccountRequest.Username)))
                .Return(false);

            CryptographyService.Stub(x => x.Encrypt(Arg<string>.Is.Equal(_createAccountRequest.Username + "_password")))
                .Return(EncryptedPassword);

            AccountRepository.Stub(
                x => x.Create(Arg<CreateAccountRequest>.Is.Equal(_createAccountRequest),
                         Arg<string>.Is.Equal(EncryptedPassword)))
                .WhenCalled(x => _createAccountRequestPassedToRepository = x.Arguments[0] as CreateAccountRequest)
                .WhenCalled(x => _encryptedPasswordPassedToRepository = x.Arguments[1].ToString());

            SettingsProvider.Stub(x => x.GetEmailSettings())
                .Return(new EmailSettings
                            {
                                AdminEmailAddress = AdminEmailAddress,
                            });

            EmailService.Stub(x => x.SendEmail(Arg<SendMailRequest>.Is.Anything))
                .WhenCalled(x => _sendMailRequestPassedToMailService = x.Arguments[0] as SendMailRequest);

            _expectedCreateAccountResponse = new CreateAccountResponse
                                                 {
                                                     Success = true,
                                                 };

            _expectedCreateAccountRequest = new CreateAccountRequest
                                                {
                                                    FirstName = "Colin",
                                                    LastName = "Callahan",
                                                    EmailAddress = "*****@*****.**",
                                                    Username = "******",
                                                    Role = Role.Employee,
                                                };
        }
 protected override void BecauseOf()
 {
     _response = AccountCreator.Execute(Username, _createAccountRequest);
 }
 protected override void BecauseOf()
 {
     _response = AccountCreator.Execute("some unauthorized username", new CreateAccountRequest());
 }