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

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

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

        // act
        presenter.Handle(new FindUserResponse(new User(), "", true, null, null));

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

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

            // assert
            dynamic data = JsonConvert.DeserializeObject(presenter.ContentResult.Content);

            Assert.True(data.success.Value);
            Assert.Equal("1234", data.id.Value);
        }
예제 #4
0
    public void Handle_GivenSuccessfulUseCaseResponse_SetsId()
    {
        // arrange
        var presenter = new FindUserPresenter();

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

        // assert
        FindUserResponse data = JsonSerializer.DeSerializeObject <FindUserResponse>(presenter.ContentResult.Content);

        Assert.True(data.Success);
        Assert.Equal("1234", data.Id);
    }
    public void Handle_GivenSuccessfulUseCaseResponse_SetsId()
    {
        // arrange
        var presenter = new FindUserPresenter(_mapper);

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

        // assert
        Assert.NotNull(presenter.Response);
        Assert.NotNull(presenter.Response.Response);
        Assert.True(presenter.Response.Response.Success);
        Assert.False(presenter.Response.Response.Errors.Any());
        Assert.Equal("1234", presenter.Response.Id);
    }
        public void Handle_GivenFailedUseCaseResponse_SetsErrors()
        {
            // arrange
            var presenter = new FindUserPresenter();

            // act
            presenter.Handle(new FindUserResponse(new List <Error>()
            {
                new Error(null, "missing first name")
            }));

            // assert
            List <Error> errors = Serialization.JsonSerializer.DeSerializeObject <List <Error> >(presenter.ContentResult.Content);

            Assert.Equal((int)HttpStatusCode.BadRequest, presenter.ContentResult.StatusCode);
            Assert.NotNull(errors);
            Assert.NotEmpty(errors);
            Assert.Equal("missing first name", errors.First().Description);
        }
    public void Handle_GivenFailedUseCaseResponse_SetsErrors()
    {
        // arrange
        var presenter = new FindUserPresenter(_mapper);

        // act
        presenter.Handle(new FindUserResponse(null, null, false, null, new List <Error>()
        {
            new Error(HttpStatusCode.BadRequest.ToString(), "missing first name")
        }));

        // assert
        Assert.NotNull(presenter.Response);
        Assert.NotNull(presenter.Response.Response.Errors);
        Assert.NotEmpty(presenter.Response.Response.Errors);
        Assert.Equal("missing first name", presenter.Response.Response.Errors.First().Description);
        Assert.False(presenter.Response.Response.Success);
        Assert.NotNull(presenter.Response.Response.Errors);
        Assert.False(string.IsNullOrEmpty(presenter.Response.Response.Errors.First().Code));
        Assert.False(string.IsNullOrEmpty(presenter.Response.Response.Errors.First().Description));
        Assert.Equal(HttpStatusCode.BadRequest.ToString(), presenter.Response.Response.Errors.First().Code);
    }
예제 #8
0
    public void Handle_GivenFailedUseCaseResponse_SetsErrors()
    {
        // arrange
        var presenter = new FindUserPresenter();

        // act
        presenter.Handle(new FindUserResponse(null, null, false, null, new List <Error>()
        {
            new Error(HttpStatusCode.BadRequest.ToString(), "missing first name")
        }));

        // assert
        Models.Response.FindUserResponse response = Serialization.JsonSerializer.DeSerializeObject <Models.Response.FindUserResponse>(presenter.ContentResult.Content);
        Assert.Equal((int)HttpStatusCode.BadRequest, presenter.ContentResult.StatusCode);
        Assert.NotNull(response);
        Assert.NotNull(response.Errors);
        Assert.NotEmpty(response.Errors);
        Assert.Equal("missing first name", response.Errors.First().Description);
        Assert.False(response.Success);
        Assert.NotNull(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);
    }