public async Task UsersAreLockedOutAccordingToAfterMaxLoginAttemptsFail() { string userId = "test"; string emailAddress = "*****@*****.**"; string name = "John Doe"; string password = "******"; _eventStore.WithEvents("test", "user-test", new UserCreated(userId, emailAddress, name), new EmailAddressVerificationRequested(userId, emailAddress, _token), new PasswordResetTokenCreated(userId, _token), new EmailAddressVerified(userId, emailAddress), new PasswordSet(userId, _passwordHasher(password)) ); LoginFailed failedLogin = new LoginFailed(userId, _now); failedLogin.AddMetadataValue("userVersion", _eventStore.Streams["user-test"].Count - 1); _eventStore.WithEvents(userId, "userLogin-test", failedLogin, failedLogin); Guid commandId = Guid.NewGuid(); Result result = await _handler.Execute(new LoginUser(commandId, userId, "not the password")); Assert.Equal(LoginResult.LockedOut, result.Value <LoginResult>(commandId)); _eventStore.AssertEvents(userId, "userLogin-test", new LoginFailed(userId, _now), new AccountLockedOut(userId, _lockoutPolicy())); }