public async Task GivenForgotPasswordQueryHandler_WhenUserNotFound_ThenShouldThrowRestException()
        {
            _mockUserManager.FindByEmailAsync(_query.Email).ReturnsNullForAnyArgs();

            var forgotPasswordQueryHandler =
                new ForgotPasswordCommandHandler(_mockUserManager, _mockEmailBuilder, _mockEventBus);

            await Assert.ThrowsAsync <RestException>(() =>
                                                     forgotPasswordQueryHandler.Handle(_query, CancellationToken.None));
        }
        public async Task GivenForgotPasswordQueryHandler_WhenReceivesCorrectCommand_ThenShouldPublishSendEmailEvent()
        {
            _mockUserManager.FindByEmailAsync(_query.Email).ReturnsForAnyArgs(_user);

            var forgotPasswordQueryHandler =
                new ForgotPasswordCommandHandler(_mockUserManager, _mockEmailBuilder, _mockEventBus);

            await forgotPasswordQueryHandler.Handle(_query, CancellationToken.None);

            _mockEventBus.Received().Publish(Arg.Any <SendEmailEvent>());
        }
        GivenForgotPasswordQueryHandler_WhenReceivesCorrectCommand_ThenShouldCallEmailBuilderToGetPasswordResetEmail()
        {
            _mockUserManager.FindByEmailAsync(_query.Email).ReturnsForAnyArgs(_user);

            var forgotPasswordQueryHandler =
                new ForgotPasswordCommandHandler(_mockUserManager, _mockEmailBuilder, _mockEventBus);

            await forgotPasswordQueryHandler.Handle(_query, CancellationToken.None);

            _mockEmailBuilder.Received().ResetPasswordEmail(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>());
        }
        public async Task GivenForgotCommandHandler_WhenCorrectQueryReceived_ThenShouldUseUserManagerToFindUser()
        {
            _mockUserManager.FindByEmailAsync(_query.Email).ReturnsForAnyArgs(_user);

            var forgotPasswordQueryHandler =
                new ForgotPasswordCommandHandler(_mockUserManager, _mockEmailBuilder, _mockEventBus);

            await forgotPasswordQueryHandler.Handle(_query, CancellationToken.None);

            await _mockUserManager.ReceivedWithAnyArgs().FindByEmailAsync(_query.Email);
        }
Beispiel #5
0
        public async Task Handler_ForgotPassword()
        {
            var user = DataHelper.GetUser("test");

            _userRepository.
            Setup(x => x.GetAsync(It.IsAny <Expression <Func <User, bool> > >())).Returns(() => Task.FromResult(user));
            forgotPasswordCommand = new ForgotPasswordCommand
            {
                Email      = user.Email,
                TCKimlikNo = Convert.ToString(user.CitizenId)
            };
            var result = await forgotPasswordCommandHandler.Handle(forgotPasswordCommand, new System.Threading.CancellationToken());

            Assert.That(result.Success, Is.True);
        }
        public async Task Handler_ForgotPassword()
        {
            var user = DataHelper.GetUser("test");

            _userRepository.Setup(x => x.GetAsync(It.IsAny <Expression <Func <User, bool> > >()))
            .Returns(() => Task.FromResult(user));
            _forgotPasswordCommand = new ForgotPasswordCommand
            {
                Email      = user.Email,
                TcKimlikNo = Convert.ToString(user.CitizenId)
            };
            var result =
                await _forgotPasswordCommandHandler.Handle(_forgotPasswordCommand, new CancellationToken());

            result.Success.Should().BeTrue();
        }
        public void WhenCalled_SetUserPasswordToken()
        {
            _sut.Handle(_command, default).Wait();

            _service.Verify(x => x.SetUserPasswordToken(_user));
        }