How can I make HttpContext available to be used by my Unit Tests?
问题 I want to write a unit test which tests the function of a class called UploadedFile. The problem I face is this class' static constructor uses HttpContext.Current property and because I am running my unit test from a class library I do not have an HttpContext at the testing time. Look at my static constructor: static UploadedFile() { if (HttpContext.Current == null) throw new Exception("web server not available"); HttpServerUtility server = HttpContext.Current.Server; // SET