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
Hello,

I am testing the current version of TypeMock (version 2.2) and I am getting a error with the Dynamic Mock objects example in the user guide.

The example in the guide was:(with the added IList cast, little bug in the documentation :wink: )

MockManager.Init();
// Mock our interface 
MockObject mock = MockManager.MockObject(typeof(IList));
// Lets mock a return of 4 for Count 
mock.ExpectGet("Count",4);
// Get our concrete mocked Object
IList list = (IList) mock.Object;
// Let just test it
Assert.AreEqual(3,list.Count);
MockManager.Verify();


When I run the example it seems to throw an exception on the MockObject() method.
The message is the following:
System.TypeLoadException : Method CopyTo in type MockIList from assembly DynamicMockAssembly, Version=0.0.0.0 does not have an implementation.
at System.Reflection.Emit.TypeBuilder.TermCreateClass(TypeToken handle, Module module)
at System.Reflection.Emit.TypeBuilder.CreateType()
at TypeMock.ClassGenerator.Generate(Type type)
at TypeMock.MockManager.MockObject(Type type, Constructor mockConstructors)
at TypeMock.MockManager.MockObject(Type type)

Did I need to configure something else to make this example work or is it a bug?


Regards,

Benjamin
asked by benjamin dover (1.8k points)

3 Answers

0 votes
Hi Benjamin,
Thanks for pointing out the typo.
This seem like a bug, I will check it out...
answered by scott (32k points)
0 votes
Hi,
This was a bug an has been fixed, you can now download version 2.2.1

We have also as a treat added a new Check.CustomCheck() API
answered by scott (32k points)
0 votes
Hi Scott,

The version 2.2.1 fixed my problem.

Thanks,

Louis
answered by benjamin dover (1.8k points)
...