I am preparing a typemock test case for an internal class. However when trying to verify a private method of this internal class, I am getting the following exception.
TypeMock.VerifyException:
TypeMock Verification: Method Components.Workspace.Impersonation.ImpWorkspaceProvider_Accessor.CreatePermissions(Microsoft.SharePoint.SPWeb, Microsoft.SharePoint.SPWeb) was expected but was not called.
The method is actually getting called and executed.
Following is the code.
[TestInitialize]
public void TestInitialize()
{
_classUnderTest = Isolate.Fake.Instance<ImpWorkspaceProvider_Accessor>(Members.CallOriginal);
}
[TestMethod()]
[Isolated]
[VerifyMocks]
public void AddSiteTest()
{
//Arrange statements....
Isolate.Fake.StaticMethods<HiddenList>(Members.CallOriginal);
_classUnderTest.ReturnItem = fakeItem;
_classUnderTest.AddSite();
Isolate.Verify.NonPublic.WasCalled (_classUnderTest, "CreatePermissions"); //fails
Isolate.Verify.WasCalledWithAnyArguments(() => _classUnderTest.CreatePermissions(null, null));//fails
Isolate.Verify.WasCalledWithExactArguments(() =>HiddenList.GetSiteNameFromTitle(_cwsTitle)); //passes
}
The AddSite method inturn calls the CreatePermissions private method.
How can I verify this method call successfully? I am able to verify static method calls within the same method succesfully.