ฉันมีบริการเว็บฉันกำลังพยายามทดสอบหน่วย ในบริการมันดึงค่าหลายHttpContextอย่างเช่น:
 m_password = (string)HttpContext.Current.Session["CustomerId"];
 m_userID = (string)HttpContext.Current.Session["CustomerUrl"];
ในการทดสอบหน่วยฉันกำลังสร้างบริบทโดยใช้คำขอผู้ปฏิบัติงานง่ายๆเช่น:
SimpleWorkerRequest request = new SimpleWorkerRequest("", "", "", null, new StringWriter());
HttpContext context = new HttpContext(request);
HttpContext.Current = context;
อย่างไรก็ตามเมื่อใดก็ตามที่ฉันพยายามตั้งค่า HttpContext.Current.Session
HttpContext.Current.Session["CustomerId"] = "customer1";
HttpContext.Current.Session["CustomerUrl"] = "customer1Url";
ฉันได้รับข้อยกเว้นอ้างอิง null ที่ระบุว่าHttpContext.Current.Sessionเป็นโมฆะ
มีวิธีการเริ่มต้นเซสชันปัจจุบันในการทดสอบหน่วยหรือไม่