tiagodaraujo / HttpContextMoq

MIT License
34 stars 14 forks source link

Add extensions methods for setting common Request/Response properties #3

Closed mjamro closed 2 years ago

mjamro commented 2 years ago

I added several more extension methods, as they make using of this library way easier. The changes allow for settings commonly used properties of HTTP Request/Response like Method, Content Type, Body, Content Length.

I also updated the Readme as it lacked simple how-to example.

Example

var context = new HttpContextMock()
    .SetupUrl("http://localhost:8000/path")
    .SetupRequestMethod("POST")
    .SetupRequestContentType("application/json")
    .SetupRequestBody(new MemoryStream(data))
    .SetupRequestContentLength(data.Length)
    .SetupResponseContentType("application/json")
    .SetupResponseBody(new MemoryStream(data))
    .SetupResponseContentLength(data.Length);
mjamro commented 2 years ago

Any chance for merging and releasing that?

tiagodaraujo commented 2 years ago

Hi @mjamro, Thanks for your contribution. Great Job 💪 I will publish a new release with these changes.

Sorry for the delay, I've been on vacation for a long time 😄