chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
Hi All,

I'm new to TypeMock, and I'm trying to do what I described on my Web site at http://travisspencer.com/blog/2008/10/x.html.

This was working, but now I'm getting this exception:

System.MissingFieldException: Field not found: 'TypeMock.MockManager.s'.
at TypeMock.ArrangeActAssert.Isolate.CleanUp()
at TypeMock.ArrangeActAssert.IsolatedAttribute.Execute()
at TypeMock.MethodDecorator.e()
at TypeMock.MockManager.a(String A_0, String A_1, Object A_2, Object A_3, Boolean A_4, Object[] A_5)
at TypeMock.InternalMockManager.getReturn(Object that, String typeName, String methodName, Object methodParameters, Boolean isInjected)
at Test()
in Test.cs: line 0

What on Earth?!

Anyone have any ideas?

--

Regards,

Travis Spencer
asked by travislspencer (1.3k points)

6 Answers

0 votes
It seems to be a problem with my environment as the unit test passes on my colleagues laptop and our build machine. Very odd.

I uninstalled and reinstalled TypeMock Isolator, but the result was the same. Any thoughts?
answered by travislspencer (1.3k points)
0 votes
Same code under test, same test, and it's failing... but only on your machine? Weird.

(The unclear exception messages have been a long running problem. Don't feel bad that you're confused.)

Are you running the tests through a command-line build or through a Visual Studio add-in like TestDriven.NET?

I've seen odd behavior like this before and it's usually one of two things:

1) The tests are referencing (through the .csproj) one version of Isolator but the machine running the tests has a different version installed. For example, the .csproj references version 5.1 and the 5.1 assemblies are checked in with your source code, but your developer machine has 5.0 installed.

2) The command-line build script tries to auto-deploy Typemock Isolator to my developer machine but I've already got it installed. I've found inexplicable behavior comes from auto-deploy running on a machine where Isolator's already installed.

I've also found that removing the .user and .suo files, as odd and unrelated as it sounds, sometimes cleans up weird behavior like this when running tests from within Visual Studio. (Maybe just coincidence, but worth a shot?)

I might also try doing a full uninstall of Isolator and then installing from scratch rather than a repair (assuming you've been repairing). That might shake something loose.

Unrelated: I noticed you're using the AAA API but also using the [VerifyMocks] attribute. Generally speaking the "Assert" part of "Arrange, Act, Assert" includes manually verifying calls via Isolate.Verify. [VerifyMocks] is more for use with the Natural and Reflective mocking styles. (Typemock support folks - correct me if I'm wrong there.)
answered by tillig (6.7k points)
0 votes
Hi

I would second what tillig said.
I can add that the reason can be duplication of Typemock.dll in the GAC
so removing the older version from the GAC can solve this issue.

Tillig is right about mixing the AAA API with VerifyMocks attribute.
It is recommended to use the Isolate.Verify when using AAA API.
answered by ohad (35.4k points)
0 votes
Same code under test, same test, and it's failing... but only on your machine? Weird.


Correct.

Are you running the tests through a command-line build or through a Visual Studio add-in like TestDriven.NET?


Yes. I'm running the tests using R#.

1) The tests are referencing (through the .csproj) one version of Isolator but the machine running the tests has a different version installed. For example, the .csproj references version 5.1 and the 5.1 assemblies are checked in with your source code, but your developer machine has 5.0 installed.


The project is using 5.1 and that's what's checked into source code control. I checked the GAC on my machine, and the only version there is 5.1. I had 5.0 installed, but then I installed the 5.1 release. That seems to have removed the 5.0 DLLs from the GAC and left only the new version.

2) The command-line build script tries to auto-deploy Typemock Isolator to my developer machine but I've already got it installed. I've found inexplicable behavior comes from auto-deploy running on a machine where Isolator's already installed.


I don't think that this is an issue for me because I'm not using a command-line build script.

I've also found that removing the .user and .suo files, as odd and unrelated as it sounds, sometimes cleans up weird behavior like this when running tests from within Visual Studio. (Maybe just coincidence, but worth a shot?)


Tried that, but it didn't help.

I might also try doing a full uninstall of Isolator and then installing from scratch rather than a repair (assuming you've been repairing). That might shake something loose.


Initially when I started having this issue, I ran an uninstall. However, I accidentally installed 5.0 again afterwords. (It was sitting on my desktop and I mistook it for 5.1.) So, I upgraded it to 5.1. After that didn't solve the problem, I tried a repair. I'll try uninstalling and reinstalling again.

Unrelated: I noticed you're using the AAA API but also using the [VerifyMocks] attribute. Generally speaking the "Assert" part of "Arrange, Act, Assert" includes manually verifying calls via Isolate.Verify. [VerifyMocks] is more for use with the Natural and Reflective mocking styles. (Typemock support folks - correct me if I'm wrong there.)


I found that I had to create an instance of ISingleResult<MyGoodStoredProcedureResult> using the mock manager. That's why I added the VerifyMocks attribute. I just omitted the call to Isolate.Verify for the fake I created using the AAA syntax. I'll revisit that.

Thanks, Travis, for the help in this. I appreciate it.

--

Regards,

Travis Spencer
answered by travislspencer (1.3k points)
0 votes
Hi Travis,

Can you try to install the latest version (5.1.1) and let me know if it resolves your problem? The uninstall + install of a new assembly may clear up your system.

Also, I'd like to resolve the problem you had with faking the Linq to SQL object - I'll contact you offline to gather more details.

Thanks,
Doron
Typemock support
answered by doron (17.2k points)
0 votes
Uninstalled 5.1 completely and reinstalling it solved the issue. Thanks, Travis, for the suggestion and the help w/ this.

Doron, I can't install 5.1.1 because that would put me out of sync w/ my team (though I'm looking forward to the trying the new duck syntax). BTW, I think the issue w/ LINQ to SQL was due to my limited understanding of TypeMock, but please free to contact me for more details.

--

Regards,

Travis Spencer
answered by travislspencer (1.3k points)
...