Ejemplo n.º 1
0
        public void ObjectResponse_Should_Return_Correctly()
        {
            var actual = ApiResponseHelper.ObjectResponse(StatusCodes.Status100Continue, true, message: "message", "content");

            actual.Should().BeOfType <ActionResult <ApiResponse> >();

            actual.Result.Should().BeOfType <ObjectResult>();
            actual.Result.As <ObjectResult>().StatusCode.Should().Be(StatusCodes.Status100Continue);

            actual.Result.As <ObjectResult>().Value.Should().BeOfType <ApiResponse>();
            actual.Result.As <ObjectResult>().Value.As <ApiResponse>().Success.Should().Be(true);
            actual.Result.As <ObjectResult>().Value.As <ApiResponse>().Message.Should().Be("message");
            actual.Result.As <ObjectResult>().Value.As <ApiResponse>().Data.Should().Be("content");
        }
Ejemplo n.º 2
0
        public void ObjectResponse_Should_Return_PagedResponse_Correctly()
        {
            var content = new PagedResponse <string>
            {
                Data          = new [] { "data" },
                PrevPageIndex = 111,
                NextPageIndex = 222
            };
            var actual = ApiResponseHelper.ObjectResponse(StatusCodes.Status100Continue, true, message: "message", content: content);

            actual.Should().BeOfType <ActionResult <ApiResponse> >();

            actual.Result.Should().BeOfType <ObjectResult>();
            actual.Result.As <ObjectResult>().StatusCode.Should().Be(StatusCodes.Status100Continue);

            actual.Result.As <ObjectResult>().Value.Should().BeOfType <ApiResponse>();
            actual.Result.As <ObjectResult>().Value.As <ApiResponse>().Success.Should().Be(true);
            actual.Result.As <ObjectResult>().Value.As <ApiResponse>().Message.Should().Be("message");
            actual.Result.As <ObjectResult>().Value.As <ApiResponse>().Data.Should().Be(content.Data);
            actual.Result.As <ObjectResult>().Value.As <ApiResponse>().Navigation.PrevPageIndex.Should().Be(content.PrevPageIndex);
            actual.Result.As <ObjectResult>().Value.As <ApiResponse>().Navigation.NextPageIndex.Should().Be(content.NextPageIndex);
        }