metahack

jan's notes on seemingly random things

    • Edit
    • Delete
    • Autopost

    Unit Testing a .NET project's internal APIs

    Testing Internal APIs may sound superfluous but it's necessary. It increases the team's confidence in the codebase as well as be more creative with regards to maintaining and refactoring the codebase.

    In C/C++, the symbols of internal APIs are exposed in Debug builds so these can be unit tested. In .NET, these internal APIs need be a 'Friend' and use the InternalsVisibleTo Assembly instruction like the following

    <Assembly: InternalsVisibleTo("MyUnitTestProject")>

    That's all there is and you can start unit testing your project's internal APIs. See http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute.aspx for more info on InternalsVisibleTo.

    Tags » #dotnet #vbnet
    • 7 May 2010
    • Views
    • 0 Comments
    • Permalink
    • Favorited 0 Times
    • Tweet

    Comments 0 Comments

    Leave a Comment

  • Jan Michael Alonzo's Posterous

    Programmer, hobbyist and technologist. Interested in GTD, cool new shiny things and productivity/efficiency tools; always looking for new challenges and opportunities.

  • About Jan Michael Alonzo

    Programmer, hobbyist and technologist. Interested in GTD, cool new shiny things and productivity/efficiency tools; always looking for new challenges and opportunities.

  • Subscribe

    Subscribe to this posterous
    Unsubscribe
    Follow this posterous RSS
  • Follow Me

                   

Theme created for Posterous by Obox