Andrey Shchekin » Moq Sat, 13 Apr 2013 23:16:21 +0000 en-US hourly 1 http://wordpress.org/?v=4.2.14 Mocking internal interfaces with Moq /2008/05/09/mocking-internal-interfaces-with-moq/ /2008/05/09/mocking-internal-interfaces-with-moq/#comments Fri, 09 May 2008 08:57:00 +0000 /index.php/2008/05/09/mocking-internal-interfaces-with-moq/ Is a same method you would use with NMock2, but with “DynamicProxyGenAssembly2″ in InternalsVisibleTo.
This strange name is a default dynamic assembly name used by Castle.DynamicProxy.

Do not forget that the attribute should be added to the assembly with internal types, not to the tests assembly (obvious, but I got it wrong the first time).

Update: yesthatmcgurk has pointed me to the fact that for strongly named assemblies you have to specify the public key as well. So the correct attribute for the strongly named assembly should be

[assembly:InternalsVisibleTo("DynamicProxyGenAssembly2, 
PublicKey=002400000480000094000000060200000024000052534
1310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b
3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d926665
4753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb
4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c486
1eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] 
// without line-breaks
]]>
/2008/05/09/mocking-internal-interfaces-with-moq/feed/ 5