blog community

Welcome to blog community Sign in | Join | Help
in Search

Raimond Brookman

Architecture and .NET Development

InternalsVisibleToAttribute to support unit testing of nonpublic types

My colleague wouter spotted this new feature in the .NET 2.0 framework.

This attribute gives you the ability to do an Animal Farm trick.. all assemblies are equal, but some assemblies are more equal in the fact that they are allowed to access your internal stuff.

This solves a problem we've had with unittesting. Because we always use a separate project (assembly) to contain the unit tests (as VS2005 does also), you cannot access internal classes etc. By giving the unit test assembly rights to your business logic assembly, this problem can be solved, because we are then able to also access all nonpublic types. I bet this is probably also the reason why this attribute was invented, because in other cases it would be mostly bad design when you need these kinds of attributes...

This also does away will all kinds of nasty tricks used in the past, such as using reflection to access nonpublic types.

Another reason to switch to .NET 2.0 I think

Published Tuesday, December 13, 2005 10:49 PM by Raimondb
Filed under: ,

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

No Comments

Leave a Comment

(required) 
(optional)
(required) 
Submit

This Blog

Syndication

News

Subscribe in NewsGator Online

Subscribe in Bloglines

Add to Google


 Visitors since June 2005




Powered by Community Server, by Telligent Systems