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