Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed some NullReferenceException, added an alternative way of configuring the objects and added fluent configurators. #9

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

jgauffin
Copy link

I got NullReferenceException for different properties like the InputStream. Those shouldn't have to be configured by should be setup per default. This PR initializes all properties with relevant default values for request/response/context.

As an alternative to the Get extension method there is now a property for httpcontext/request/response called Control which exposes all properties as setters/getters. The syntax becomes a little bit cleaner (request.Control.HttpMethod = "POST"). All existing unit tests do of course pass with flying colors (i.e. I've tried to make everything backwards compatible).

Finally I've introduced a fluent syntax for using this library:

// simple context
var httpContext = builder
    .Post("http://localhost/?A=1")
    .WithForm(new { FirstName = "Jonas", LastName = "Gauffin", UserName = "jgauffin" })
    .RespondWith(403)
    .Build();

// configuring the session
var httpContext = builder
    .UsingSession(new {UserId = 10})
    .Build();

// setting principal
var principal ? new GenericPrincipal(new GenericIdentity("Arne"), new []{"Admin"});
var httpContext = builder
    .UsePrincipal(principal)
    .Build();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants