System.IO.FileNotFoundException: The Web application at http://localhost could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application
If you get the above error while opening a site through an SPSite object while performing a unit test in Visual Studio 2010, a simple resolution is to update the test engine settings to run in a 64 bit process.
To do this, highlight the test project in the Solution Explorer and from the Test menu, select Edit Test Settings -> Local (local.testsettings).
Next, select Hosts from the left hand pane and change the Run tests in 32 bit or 64 bit process: to Run tests in 64 bit process on 64 bit machine.