Unit Test Trust Issue on Vista
Further to my unit testing experiments that I have been blogging about in the last few days, I was playing around with the DashCommerce starter kit. After installing and configuring the site, I started by creating some tests for the code in the App_code folder.
The test creation was successful and I was all set to run. But luck was against me and I got compilation errors regarding missing namespace. As I had mentioned in my earlier blog, the testing happens via private accessor and since its creation happened successfully, ideally I shouldn't have had a need for adding explicit references and namespaces to my test project.
It turns, out that this happened due to the particular component for which I had generated the test to refer to an external assembly (SubSonic.dll), which in turn depended on the code in App_code folder. This caused something like circular reference and hence when the private accessor was created, it required the web site's code be added as reference. The workaround we followed was to publish the site and then refer to the generated App_Code.dll.
This wasn't the main issue that I wanted to describe here. When the compilation errors resolved, when I tried to run the test, I got an exception of type "Microsoft.VisualStudio.TestTools.TestManagement.ExecutionException". It pointed to a "Test Run deployment issue" and stated that the "file or location of the SubSonic.dll isn't trusted". This was strange since I had ensured that necessary permissions were granted on the folder so why this error.
I recalled from my earlier experiments on Vista about the file streams and how the files downloaded from the internet get tagged with additional file streams that marks it unsafe for execution. So I unblocked the file via File > Properties as shown in the image below.
After this I got similar error for another file and I realized that since this is a code that I downloaded from the net, all files have been tagged in similar way and I will need to unblock all. Doing that eventually worked and I was able to complete the testing successfully.
The one painful item was having had to unblock all files manually. Selecting all and right clicking to check Properties didn't help. Then later I found this which will help unblock multiple files.