I have the following code, that is trying to mock a certain MS Sharepoint object:
using Microsoft.SharePoint.Workflow;
using NUnit.Framework;
using TypeMock;
[Test]
public void Test()
{
MockManager.Init();
MockObject spWFAssocs = MockManager.MockObject(typeof(SPWorkflowAssociationCollection));
spWFAssocs.ExpectGetAlways("get_Count", 0);
MockManager.Verify();
}
When I execute this test code I get this error:
failed: System.TypeLoadException : Method 'Add' on type 'MockSPWorkflowAssociationCollection' from assembly 'DynamicMockAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' is overriding a method that is not visible from that assembly.
at System.Reflection.Emit.TypeBuilder.TermCreateClass(Int32 handle, Module module)
at System.Reflection.Emit.TypeBuilder.CreateTypeNoLock()
at System.Reflection.Emit.TypeBuilder.CreateType()
at u.a(Type A_0, Object[] A_1)
at TypeMock.MockManager.MockObject(Type type, Constructor mockConstructors, Object[] args)
at TypeMock.MockManager.MockObject(Type type, Object[] args)
Any inside to this error, or any workarounds? I quickly tried using Mock instead of MockObject, it didn't give the error, but I may need to use MockObject to be able to mock different instance differently. I have TypeMock 3.7.1 installed currently.
TIA