Web Unit Tests Without HttpContext
1 min read
Phil Haack created a very useful HttpSimulator to assist in unit testing code that accesses the HttpContext. I was up an running in a few minutes. Here’s a sample that worked for me.
[TestMethod]public void GetGroupsTest(){ using (HttpSimulator sim = new HttpSimulator().SimulateRequest()) { Dictionary<string, GroupDao> groups = GroupCao.GetGroups(); }} Share:
Share on LinkedIn
Quick Share: Your custom post text has been copied to your clipboard! Click the button below to open LinkedIn's share dialog, then paste it.
💡 Tip: LinkedIn will open in a new tab. Use Ctrl+V (or Cmd+V on Mac) to paste your text.
Note: LinkedIn will show the article preview. You can add your custom text above it.