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);
    }
Beispiel #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);
    }
Beispiel #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 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);
    }