Skip to content

Instantly share code, notes, and snippets.

@jcolebrand
Created February 24, 2017 15:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcolebrand/500c34a848635b924bddabfdf2eea9e4 to your computer and use it in GitHub Desktop.
Save jcolebrand/500c34a848635b924bddabfdf2eea9e4 to your computer and use it in GitHub Desktop.
for talking to Nick Craver
// this is mockable in your unit tests so you can just assign the func over it
public static Func<HttpContextBase> Context = () => new HttpContextWrapper(HttpContext.Current);
public void SomeMethod(){
var context = Context();
if (context == null) return;
// use context here like you would HttpContext.Current
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment