Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Test Edition
Test Types
Unit Tests Overview
 ASP.NET Unit Tests and Private Acce...
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
Visual Studio Team System
ASP.NET Unit Tests and Private Accessors

Updated: November 2007

The code that is generated for testing an ASP.NET application uses private accessors even when everything that you are testing is public.

Why does the generated code use private accessors? Because Web code does not have a predictable assembly name to which you can bind a process at run time and deployment time. At run time, the test assembly, which contains your unit tests, must be able to bind to an assembly that contains the code you want to test. This binding lets your unit tests run on the methods in that assembly.

To make run-time binding possible, the generation of the unit test also creates a type, by using reflection, in the ASP.NET context. This newly created type is located in an assembly in the app domain of your ASP.NET application. After this run-time binding is achieved, reflection must be used to access it, and this reflection is performed by the private accessor object.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker