I checked following forum post which resolves the problem in case of Assembly without Strong Name.
https://www.typemock.com/community/viewtopic.php?t=1346&start=0&postdays=0&postorder=asc&highlight=internal+interface
But I tried with following simple interface and test case. Both of them are in a Strong-Named assembly.
// Sample Interface Under Test
namespace TestLibrary
{
internal interface ITestInterface
{
bool TestProperty { get; }
}
}
// Example Test Class
namespace TestLibrary.Tests
{
[TestFixture]
public class TestClass1
{
[Test]
[Isolated]
public void TestFakeInteralInterfaceFromStrongNamedAssembly()
{
ITestInterface fakeTestInterface = Isolate.Fake.Instance<ITestInterface>(Members.ReturnRecursiveFakes);
Isolate.WhenCalled(() => fakeTestInterface.TestProperty).WillReturn(true);
Assert.AreEqual(true, fakeTestInterface.TestProperty);
}
}
}
I added following lines in AssemblyInfo.cs file. I didn't include complete public key below as it will mess the structure of this post.
[assembly: InternalsVisibleTo("TestLibrary.Tests, PublicKey=2400000...")]
[assembly:InternalsVisibleTo("DynamicMockAssembly,PublicKey=2400000...")]
When I run the test I get following exception.
System.TypeLoadException : Type 'Mock0000ITestInterface' from assembly 'DynamicMockAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=a0857b23fb3f20d9' is attempting to implement an inaccessible interface.
BTW, I'm using following tools
- Typemock 5.4.4.0
- NUnit 2.5.2.9222
- Visual Studio 2008