Enable Rhino Mocks to mock internal types

Settembre 17th, 2007

Description: Unit tests often are required to mock types defined in other assemblies. If those types are marked as Internal then it will fail to mock them. Enter InternalsVisibleToAttribute …

Link: http://www.codekeep.net/snippets/0b3da5af-819b-4289-88d2-c70cb8d8c6e7.aspx

[assembly :InternalsVisibleTo("Rhino.Mocks")]	// obviously the Rhino Mocks assembly
[assembly :InternalsVisibleTo("DynamicProxyGenAssembly2")]	// Rhino Mocks uses Castle DynamicProxy for the heavy lifting
[assembly :InternalsVisibleTo("<unit test assembly name>")]	// your unit test assembly

  • .NET
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Trackback URI | Comments RSS

Leave a Reply

You must be logged in to post a comment.