Share

NMock

Tracker: Bugs

5 NMock don't work with interfaces with visiblity internal - ID: 1740285
Last Update: Comment added ( scmitcham )

If you define an interface like:

interface ITest
{
uint GetValue();
}


an try to create a Mock object like:

mocks = new Mockery();
mock = mocks.NewMock<ITest>();

you get an exception by testing with NUnit.
System.TypeLoadException : Access is denied: 'MockTest.Test'.


Nobody/Anonymous ( nobody ) - 2007-06-20 11:40

5

Closed

Wont Fix

Nobody/Anonymous

None

None

Public


Comment ( 1 )




Date: 2007-10-12 20:13
Sender: scmitchamProject Admin


The dynamic code generators for .NET cannot violate the visibility rules
for assemblies. Since the mocks are put into a dynamic assembly they do not
inherit the InternalsVisibleTo setting if you've used it.

A work around is possible and described at
http://blog.ashmind.com/index.php/2007/07/07/mocking-internal-interfaces-with-nmock2

However, this will probably not work with signed assemblies.



Log in to comment.

Attached File

No Files Currently Attached

Changes ( 3 )

Field Old Value Date By
status_id Open 2007-10-12 20:13 scmitcham
resolution_id None 2007-10-12 20:13 scmitcham
close_date - 2007-10-12 20:13 scmitcham