I’m trying to set up some unit tests for an XNA project. After some ordeals with making sure the test project was set to build in the configuration manager and removing references to the XNA content project, I finally got the tests to build.
But the tests still won’t run half of the time. If I click “run selection” from the test view I continually get the error “No such interface supported (Exception from HRESULT:0x80004002 (E_NOINTERFACE)).” If I instead press the “run all tests in solution” button, it sometimes runs, but usually it gives me this error: “Specific Cast is not Valid.” if run all tests does work the first time (this seems to happen after updating from SVN), it stops working immediately after that.
I’ve found some people with similar issues:
But both seemed to have died without resolutions. Any help would be appreciated.
A default XNA solution is not COM-Visible. The test framework seems to behave slightly better if it is COM-Visible. The easiest fix is to open AssemblyInfo.cs, find the line
And change false to true.
A blog post by Carlos Quintero led me to the fix. This only works about half of the time, and I’m not actually certain it’s responsible for fixing the problem.
Aaron Stebner claims in a forum post that it shouldn’t work whatsoever if the test project references a ContentProject, and references the WPDT release notes which agree with that. In my tests just now, the Game project itself must not reference a ContentProject for the tests to run succesfully every time. I’ve taken to removing the reference to run tests and replacing it afterwards. Depending on your test coverage this can work well or be useless, but it looks like it’s the best we can get with the built-in test suite.