0

I am writing test cases for my web api project and using nunit test framework. I am facing problem during config load in main project when I comes through test project.

string folderPath = HttpContext.Current.Server.MapPath("~/StartupLogs");

I am getting null when I comes through test project but If comes through actual project it return path. Please suggest how can I get this path when I comes through test project in c#.

mahesh sharma
  • 998
  • 1
  • 7
  • 21
  • `HttpContext` is an implementation concern that is tightly coupled to IIS which is not running during unit tests. You need to abstract that out so it can be properly mocked when testing in isolation. – Nkosi Oct 26 '17 at 10:05
  • But I have some config that I need to load to run our code so how can I handle because I can not mock without code changes. – mahesh sharma Oct 26 '17 at 10:15
  • Then update the question to show the actual problem. The question in its current state is unclear as it is incomplete. Read [ask] and then provide a [mcve] that can be used to better understand your problem. – Nkosi Oct 26 '17 at 10:16
  • @Nkosi okay thanks – mahesh sharma Oct 26 '17 at 10:18

0 Answers0