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

Modify base for MapPath #5

Closed
ghost opened this issue Apr 16, 2017 · 1 comment
Closed

Modify base for MapPath #5

ghost opened this issue Apr 16, 2017 · 1 comment

Comments

@ghost
Copy link

ghost commented Apr 16, 2017

I'd like to suggest making the base path for Http.Context.Current.Server.MapPath configurable. Currently it is always set to AppDomain.CurrentDomain.BaseDirectory and cannot be changed.

Motivation:
The standard use case for FakeHttpContext is to create unit tests for web applications. The unit test project is usually separated from the web application project, so that they reside in different project directories. For successfully faking a web request, the MapPath would need to have the path that an actual web request to the web application directory would have not to the unit test Debug\bin directory.

vadimzozulya pushed a commit that referenced this issue Apr 17, 2017
@vadimzozulya
Copy link
Owner

Hi @hannobo, not sure that I completely understand why do you need this, as this util is for unit testing, where you don't need to create any requests, but I've implemented what you need.

Now you can set base path like this:

using (new FakeHttpContext { BasePath = "C:\myBasePath" })
{
}

NOTE: only absolute path can be use as a base path. It's a limitation which I can avoid (even with reflection).

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

No branches or pull requests

1 participant