I've built up a custom SharePoint library for creating lists, connecting to configuration lists, etc. I have added a Unit Test Project to the solution to test the class library files, but it seems my test methods are unable to do simple things with the SharePoint API. For instance, in my unit test method I have this:
[TestMethod]
public void TestMethod()
{
using (SPSite site = new SPSite("http://mysite/sitecollection/"))
{
...Omitted for brevity
}
}
When running the test, I get the error System.IO.FileNotFoundException: The Web Application at http://mysite/sitecollection/ could not be found.
Please keep in mind that this is a valid site collection and that I am running under farm priveledges.
Are there caveats/gotchas to get unit testing working with SharePoint class libraries? Or is my only option to add a SharePoint project and test my class library that way?