I just started experimenting moq for unit testing my modules.
Actually, the class for which I have to write an unit test uses
Assembly.GetExecutingAssembly().Location
internally to determine a path.
But, this doesn't work while writing unit tests because, the path of the executing assembly is different (the path of the unit testing assembly is taken)
AppData\\Local\\Temp\\3ylnx32t.ukg\\TestApplication.Test\\assembly\\dl3\\aeb938e6\\f3664631_d982ce01
.
I tried, disabling shadow copying.
AppDomainSetup appDomain= new AppDomainSetup{ShadowCopyFiles = "false",};
appDomain.ShadowCopyFiles=false.ToString();
still, it doesn't work!
Any suggestions are appreciated. Thanks in advance.
You can use TestContext.CurrentContext.TestDirectory
as mentioned by Charlie Poole from NUnit here.
Reference: https://stackoverflow.com/a/29057351/589574