I’m using Visual Studio 2010 and created a bunch of unit tests.
Here is an example:
[TestMethod()]
[HostType("ASP.NET")]
[AspNetDevelopmentServerHost("C:\\Users\\Employee\\Documents\\Code Spaces\\shopvote2\\trunk\\Web", "/Web")]
[UrlToTest("http://localhost/Web")]
public void GetUserDetailsTest()
{
api_Accessor target = new api_Accessor(); // TODO: Initialize to an appropriate value
string username = string.Empty; // TODO: Initialize to an appropriate value
string passhash = string.Empty; // TODO: Initialize to an appropriate value
int requestID = 0; // TODO: Initialize to an appropriate value
ShoppingRequestDetailsData[] expected = null; // TODO: Initialize to an appropriate value
ShoppingRequestDetailsData[] actual;
actual = target.GetUserDetails(username, passhash, requestID);
Assert.AreEqual(expected, actual);
Assert.Inconclusive("Verify the correctness of this test method.");
}
The problem is, it says:
The type or namespace name ‘ShoppingRequestDetailsData’ could not be found (are you missing a using directive or an assembly reference?)
Cannot implicitly convert type ‘ShoppingWithFriends.ShoppingRequestDetailsData[]’ to ‘ShoppingRequestDetailsData[]’
It picks up the Namespace that it’s from, and I can run the tests that don’t require custom classes. It’s only these that are causing me problems.
Any ideas?
Thanks.
A few things to check:
First, I would double-check the reference in your project — is it a project reference or an assembly reference? If it’s an assembly reference, are you sure that it’s pointing at the right version of the file? (e.g. if you renamed directories, maybe it’s pointing at the old directory). To be sure, use a tool like Reflector to examine the assembly directly and make sure the type is there in the right namespace.
Second, I’m not sure if this is your problem but I had a similar issue where a namespace was not found even though there was a project reference in the same solution, types were public, etc..
It turned out that I needed to change the “Target Framework” to be “.NET Framework 4” instead of “.NET Framework 4 Client Profile”. I didn’t bother figuring out why this resulted in an “unknown namespace” error, but it solved my problem.
Just a couple things to check, hope it helps…
John