public void Arrange() { _user = new User { Email = EmailAddress, Password = CorrectHashedPassword, Salt = CorrectSalt, PasswordProfileId = CorrectProfileId, FailedLoginAttempts = 1 }; _userRepository = new Mock <IUserRepository>(); _userRepository.Setup(r => r.GetByEmailAddress(EmailAddress)) .Returns(Task.FromResult(_user)); _passwordService = new Mock <IPasswordService>(); _passwordService.Setup(s => s.VerifyAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())) .Returns(Task.FromResult(false)); _passwordService.Setup(s => s.VerifyAsync(CorrectPassword, CorrectHashedPassword, CorrectSalt, CorrectProfileId)) .Returns(Task.FromResult(true)); _configuration = new EmployerUsersConfiguration { Account = new AccountConfiguration { AllowedFailedLoginAttempts = 2 } }; _configurationService = new Mock <IConfigurationService>(); _configurationService.Setup(s => s.GetAsync <EmployerUsersConfiguration>()).Returns(Task.FromResult(_configuration)); _mediator = new Mock <IMediator>(); _mediator.Setup(m => m.PublishAsync(It.IsAny <IAsyncNotification>())).Returns(Task.FromResult <object>(null)); _logger = new Mock <ILogger>(); _validator = new Mock <IValidator <AuthenticateUserCommand> >(); _validator.Setup(x => x.ValidateAsync(It.IsAny <AuthenticateUserCommand>())).ReturnsAsync(new ValidationResult { ValidationDictionary = new Dictionary <string, string>() }); _auditService = new Mock <IAuditService>(); _commandHandler = new AuthenticateUserCommandHandler( _userRepository.Object, _passwordService.Object, _configurationService.Object, _mediator.Object, _logger.Object, _validator.Object, _auditService.Object); _command = new AuthenticateUserCommand { EmailAddress = EmailAddress, Password = CorrectPassword }; }
private void ConfigureHashingService(EmployerUsersConfiguration config) { For <IHashingService>().Use(x => new HashingService(config.AllowedHashstringCharacters, config.Hashstring)); }