We are using ReSharper 2.0 (build #259), NUnit 2.2.7 and VS2005.
After installing TypeMock.NET and enabling it from the Tools menu a test now fails with a System.TypeLoadException, when running the test from within the IDE using the ReSharper Unit Test Runner.
If I disable TypeMock.NET from the Tools menu and run the test again from within the IDE it works fine and goes green.
The test itself is an existing test that does not reference TypeMock.NET yet. I have not added any references to TypeMock.NET, I am just running existing working code.
How/why is just turning TypeMock.NET on causing my test to fail?
Any help or guidance would be appreciated as this product looks great!
I am experiencing a similar problem, but with NUnit. When using NUnit to run a certain test, everything works well, but when running that test with TypeMock (via TMockRunner, or by launching from inside a TypeMock-enabled instance of VisualStudio) I encounter a System.TypeLoadException:
Failures:
1) com.innovationNext.aware.test.unit.domain.TestTester.BugAddSavedReferenceThrowsOnExistingUriWithFragments : System.TypeLoadException : Could not load type 'com.innovationNext.aware.domain.ReferenceList`1' from assembly 'aware, Version=2.3.2.7, Culture=neutral, PublicKeyToken=null' due to value type mismatch.
at com.innovationNext.aware.domain.ReferenceList`1.Contains(T reference)
at com.innovationNext.aware.domain.SavedReferenceList.AsyncAddAndDownload(Dictionary`2 references) in C:productswareetty-tweakeddevsrcdomainSavedReferenceList.cs:line 83
at com.innovationNext.aware.test.unit.domain.TestTester.BugAddSavedReferenceThrowsOnExistingUriWithFragments() in C:productswareetty-tweakeddev estunitdomainTestTester.cs:line 56
I am working on extracting a test case, but I do not have code ready yet. The problem is also not perfectly predictable -- I've been unable to reproduce the problem on a Win2k machine (my main dev. box is running XP.)
I've reproduced the problem with TypeMock 3.6.1 paired with NUnit 2.2.8, 2.2.9 and 2.4 beta 2, both in GUI and console modes. I've also run the test method as a stand-alone c# app (invoking the test method directly from a Main) to pull nunit out of the mix, and the program performs as expected, so something about the integration of TypeMock and NUnit must be causing this problem.
A bit more info: This only started becoming an issue after introducing generics into our class hierarchy. The method ReferenceList`1.Contains(T reference) is an abstract class that SavedReferenceList extends (and provides a closed type to, in the class declaration). Contains has the same pedigree (implementation location, override location, visibility.. signature etc.) as another method WasViewed(T reference) which *can* be called successfully at the same location on the stack that the exception is thrown. (this was tested by adding watches in the debugger when the TypeLoadException was thrown and caught by Visual Studio.)
If I am able to extract a stand-alone test case that exhibits this failure I will provide that as well.
This problem has proven to be quite a show-stopper. Any assistance you can offer in finding a solution or workaround will be greatly appreciated.
Thank You,
Rogan Creswick