public async Task UpdateUser_CheckEvents(ApplicationUser user, ApplicationUser oldUser, Action <IEvent>[] assertions)
        {
            //Arrange
            var userStoreMock = new Mock <IUserStore <ApplicationUser> >();

            userStoreMock.Setup(x => x.FindByIdAsync(user.Id, CancellationToken.None)).ReturnsAsync(oldUser);
            var eventPublisher = new EventPublisherStub();

            var userManager = SecurityMockHelpers.TestCustomUserManager(userStoreMock, eventPublisher);

            //Act
            var result = await userManager.UpdateAsync(user);

            //Assert
            result.Succeeded.Should().BeTrue();
            eventPublisher.Events.Should().SatisfyRespectively(assertions);
        }
        public async Task ChangePassword_CheckEvents(ApplicationUser user, Action <IEvent>[] assertions)
        {
            //Arrange
            var userStoreMock = new Mock <IUserStore <ApplicationUser> >();

            userStoreMock.Setup(x => x.FindByIdAsync(user.Id, CancellationToken.None)).ReturnsAsync(user);
            userStoreMock.As <IUserPasswordStore <ApplicationUser> >()
            .Setup(x => x.GetPasswordHashAsync(It.IsAny <ApplicationUser>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(user.PasswordHash);
            var eventPublisher = new EventPublisherStub();

            var userManager = SecurityMockHelpers.TestCustomUserManager(userStoreMock, eventPublisher);

            //Act
            var result = await userManager.ChangePasswordAsync(user, "current_pass", "Qwerty123!");

            //Assert
            result.Succeeded.Should().BeTrue();
            eventPublisher.Events.Should().SatisfyRespectively(assertions);
        }
        public async Task ResetPassword_CheckEvents(ApplicationUser user, Action <IEvent>[] assertions)
        {
            //Arrange
            var userStoreMock = new Mock <IUserStore <ApplicationUser> >();

            userStoreMock.Setup(x => x.FindByIdAsync(user.Id, CancellationToken.None)).ReturnsAsync(user);
            userStoreMock.As <IUserPasswordStore <ApplicationUser> >()
            .Setup(x => x.SetPasswordHashAsync(user, user.PasswordHash, CancellationToken.None))
            .Returns(Task.CompletedTask);
            var eventPublisher = new EventPublisherStub();

            var userManager = SecurityMockHelpers.TestCustomUserManager(userStoreMock, eventPublisher);

            userManager.RegisterTokenProvider("Static", new StaticTokenProvider());
            userManager.Options.Tokens.PasswordResetTokenProvider = "Static";
            var token = await userManager.GeneratePasswordResetTokenAsync(user);

            //Act
            var result = await userManager.ResetPasswordAsync(user, token, "Qwerty123!");

            //Assert
            result.Succeeded.Should().BeTrue();
            eventPublisher.Events.Should().SatisfyRespectively(assertions);
        }