Home
Manage Your Code
Snippet: Enable Rhino Mocks to mock internal types (C#)
Title: Enable Rhino Mocks to mock internal types Language: C#
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 ... Views: 240
Author: William Bain Date Added: 9/17/2007
Copy Code  
1[assembly :InternalsVisibleTo("Rhino.Mocks")]	// obviously the Rhino Mocks assembly
2[assembly :InternalsVisibleTo("DynamicProxyGenAssembly2")]	// Rhino Mocks uses Castle DynamicProxy for the heavy lifting
3[assembly :InternalsVisibleTo("<unit test assembly name>")]	// your unit test assembly
4
Notes
The attributes are added to the AssemblyInfo.cs of the assembly that defines the types to be mocked. Note that thuis is the unsigned method, if your assemblies are signed then the full public key needs to follow the assembly name, i.e. "Rhino.Mocks, ".