Ok, so maybe I am the last person on the planet to learn about this new attribute, but oh well.
Last week a co-worker of mine came across this attribute when doing some research and both of us just kinda looked at each other and smiled. See, for a long while now we have been saying how it would be nice to be able to test non-public methods from external assemblies without the use reflection. It appears that Microsot thought that this was important enough to add to the framework (thanks guys) in the form of a simple attribute [InternalsVisibleTo] (MSDN Documentation). Sorry VB.Net developers, Microsoft is again shunning you guys and this attribute is NOT available to you.... :(
In order to use this attribute you need to add one line of code to your AssemblyInfo.cs class for each external assembly that needs to access internal methods.
Now, to create a Simple application to test. For this example I will create a simple ShoppingCart that takes a Shopping Cart item.
Here is the test that allows the testing of the internal method.
Now, you can test those internal methods from external assemblies. Like I said above, maybe I was the last to find this, but I am glad I finally did.
Derik
Posted
04-09-2007 6:33 AM
by
Derik Whittaker