% cd C:\PathTo\MyApplication
% sn -Tp MyApplication.exeThe resulting output is the public key. I cut and pasted this into the AssemblyInfo.cs file of my application (NOTE: Not of my test app) similar to that shown below (the actual public key was changed)
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("MyTestAassemblyName, PublicKey=" + "0024000004800000940000000602000000240000525341310004000001000100adfedd2329a0f8" + "3e057f0b14e47f02ec865e542c2dcca6349177fe3530edd5080276c48c6d02fa0a6f67738cc1a0" + "793be3322cf17b8995acc15055c00fa61b67a203c7eb2516922810ff0b17cd2e08492bdcafc4a9" + "23e6fff4caba672a4c2d0d0f5cac9aea9
5c3dce3717bb733d852c387f5f025c42c14ec8d759f7e" + "b13689be" )]This got me a little further. Since I have .xml files that the unit under test required, the tests failed when trying to load them as they aren't copied over to the default testing directory by default. This was remedied by using the Test->Edit Test Run Configuration menu. In the resulting dialog I was able to Add the .xml file to the deployment as shown.
Once I had everything working, I renamed the folder that my main application was in. At some point in the process I had also turned on code coverage options in the test run configuration file. I then got a "Strong name validation failed" error. It turns out the run configuration file keeps a copy to the password key file and when the directory got renamed this reference was broken. I went back into the dialog under coverage and respecified both my target .exe for coverage and the .key file. Once this was done all the tests started working again. All is well again and I even have data driven tests working, but that's another post.
Unit Testing with a database
My most recent issue was to hook in tests that require talking to the Sql Server Compact Edition database. When the test runs the piped value |DataDirectory| points off to the program folder where SqlCE is actually installed instead of the directory where my .exe sits. This was easily remedied by coding a new path in the the data directory variable using the following: