public void Handle_GivenSuccessfulUseCaseResponse_SetsOKHttpStatusCode()
    {
        // arrange
        var presenter = new ResetPasswordPresenter();

        // act
        presenter.Handle(new UseCaseResponseMessage("", true));

        // assert
        Assert.Equal((int)HttpStatusCode.OK, presenter.ContentResult.StatusCode);
    }
Example #2
0
    public void Handle_GivenSuccessfulUseCaseResponse_SetsOKHttpStatusCode()
    {
        // arrange
        var presenter = new ResetPasswordPresenter(_mapper);

        // act
        presenter.Handle(new UseCaseResponseMessage("", true));

        // assert
        Assert.NotNull(presenter.Response);
        Assert.True(presenter.Response.Success);
        //Assert.Null(presenter.Response.Errors);
        Assert.False(presenter.Response.Errors.Any());
    }
    public void Handle_GivenSuccessfulUseCaseResponse_SetsId()
    {
        // arrange
        var presenter = new ResetPasswordPresenter();

        // act
        presenter.Handle(new UseCaseResponseMessage("1234", true));

        // assert
        ResetPasswordResponse response = Serialization.JsonSerializer.DeSerializeObject <ResetPasswordResponse>(presenter.ContentResult.Content);

        Assert.Equal((int)HttpStatusCode.OK, presenter.ContentResult.StatusCode);
        Assert.NotNull(response);
        Assert.Null(response.Errors);
        Assert.True(response.Success);
    }
Example #4
0
    public void Handle_GivenFailedUseCaseResponse_SetsErrors()
    {
        // arrange
        var presenter = new ResetPasswordPresenter(_mapper);

        // act
        presenter.Handle(new UseCaseResponseMessage(new List <Error> {
            new Error(HttpStatusCode.BadRequest.ToString(), "Invalid username/password")
        }));

        // assert
        Assert.NotNull(presenter.Response);
        Assert.NotNull(presenter.Response.Errors);
        Assert.NotEmpty(presenter.Response.Errors);
        Assert.False(string.IsNullOrEmpty(presenter.Response.Errors.First().Code));
        Assert.False(string.IsNullOrEmpty(presenter.Response.Errors.First().Description));
        Assert.Equal(HttpStatusCode.BadRequest.ToString(), presenter.Response.Errors.First().Code);
        Assert.Equal("Invalid username/password", presenter.Response.Errors.First().Description);
    }
 public AccountsService(ILogger <AccountsService> logger, IRegisterUserUseCase registerUserUseCase, RegisterUserPresenter registerUserPresenter,
                        IDeleteUserUseCase deleteUserUseCase, DeleteUserPresenter deleteUserPresenter,
                        IFindUserUseCase findUserUseCase, FindUserPresenter findUserPresenter,
                        IChangePasswordUseCase changePasswordUseCase, ChangePasswordPresenter changePasswordPresenter,
                        IResetPasswordUseCase resetPasswordUseCase, ResetPasswordPresenter resetPasswordPresenter,
                        ILockUserUseCase lockUserUseCase, LockUserPresenter lockUserPresenter)
 {
     _logger = logger;
     _registerUserUseCase     = registerUserUseCase;
     _registerUserPresenter   = registerUserPresenter;
     _deleteUserUseCase       = deleteUserUseCase;
     _deleteUserPresenter     = deleteUserPresenter;
     _findUserUseCase         = findUserUseCase;
     _findUserPresenter       = findUserPresenter;
     _changePasswordUseCase   = changePasswordUseCase;
     _changePasswordPresenter = changePasswordPresenter;
     _resetPasswordUseCase    = resetPasswordUseCase;
     _resetPasswordPresenter  = resetPasswordPresenter;
     _lockUserUseCase         = lockUserUseCase;
     _lockUserPresenter       = lockUserPresenter;
 }
    public void Handle_GivenFailedUseCaseResponse_SetsErrors()
    {
        // arrange
        var presenter = new ResetPasswordPresenter();

        // act
        presenter.Handle(new UseCaseResponseMessage(new List <Error> {
            new Error(HttpStatusCode.BadRequest.ToString(), "Invalid username/password")
        }));

        // assert
        ResetPasswordResponse response = Serialization.JsonSerializer.DeSerializeObject <ResetPasswordResponse>(presenter.ContentResult.Content);

        Assert.Equal((int)HttpStatusCode.BadRequest, presenter.ContentResult.StatusCode);
        Assert.NotNull(response);
        Assert.NotNull(response.Errors);
        Assert.NotEmpty(response.Errors);
        Assert.False(string.IsNullOrEmpty(response.Errors.First().Code));
        Assert.False(string.IsNullOrEmpty(response.Errors.First().Description));
        Assert.Equal(HttpStatusCode.BadRequest.ToString(), response.Errors.First().Code);
        Assert.Equal("Invalid username/password", response.Errors.First().Description);
    }
 public AuthController(
     ILoginUseCase loginUseCase,
     LoginPresenter loginPresenter,
     IExchangeRefreshTokenUseCase exchangeRefreshTokenUseCase,
     ExchangeRefreshTokenPresenter exchangeRefreshTokenPresenter,
     IGeneratePasswordResetUseCase generatePasswordResetUseCase,
     GeneratePasswordResetPresenter generatePasswordResetPresenter,
     IResetPasswordUseCase resetPasswordUseCase,
     ResetPasswordPresenter resetPasswordPresenter,
     ISendEmailUseCase sendEmailUseCase,
     SendEmailPresenter sendEmailPresenter)
 {
     _loginUseCase   = loginUseCase;
     _loginPresenter = loginPresenter;
     _exchangeRefreshTokenUseCase    = exchangeRefreshTokenUseCase;
     _exchangeRefreshTokenPresenter  = exchangeRefreshTokenPresenter;
     _generatePasswordResetUseCase   = generatePasswordResetUseCase;
     _generatePasswordResetPresenter = generatePasswordResetPresenter;
     _resetPasswordUseCase           = resetPasswordUseCase;
     _resetPasswordPresenter         = resetPasswordPresenter;
     _sendEmailUseCase   = sendEmailUseCase;
     _sendEmailPresenter = sendEmailPresenter;
 }
Example #8
0
 public ResetPasswordCommandHandler(ILogger <ResetPasswordCommandHandler> logger, IResetPasswordUseCase useCase, ResetPasswordPresenter presenter)
 {
     _logger    = logger;
     _useCase   = useCase;
     _presenter = presenter;
 }