I'm just trying to mock the SPContentType class out of the SharePoint assembly but I'm facing several problems because of its nested constructors. I've already searched for a solution but cannot find any information about the mocking of this class.
When simply trying to mock this class:
SPContentType mockedContentType = Mock.Create<SPContentType>();
I receive the following error:
Initialization method X.KeywordFinderTests.Initialize threw exception. System.MissingMethodException: System.MissingMethodException: Constructor on type
After that I had a look at the SPContentType class using dotPeek; but it has an internal empty constructor. Well it has many internal calls so I tried the following code to avoid them:
SPContentType mockedContentType = Mock.Create<SPContentType>(SPContentTypeId.Empty);
SPContentType mockedContentType = Mock.Create<SPContentType>(
SPContentType mockedContentType = Mock.Create<SPContentType>(Constructor.Mocked);
But those constructor calls fail with the same error message. Even trying to create a mock using any of the other public constructor always leads to an error message.
SPContentType mockedContentType =
"My Content Type"
Initialization method X.KeywordFinderTests.Initialize threw exception. System.NullReferenceException: System.NullReferenceException: Object reference not
to an instance of an
Can some one help me to mock this class?