Export (0) Print
Expand All

PrivateObject Class

Allows test code to call methods and properties on the code under test that would be inaccessible because they are not public.

System.Object
  Microsoft.VisualStudio.TestTools.UnitTesting.PrivateObject

Namespace:  Microsoft.VisualStudio.TestTools.UnitTesting
Assembly:  Microsoft.VisualStudio.QualityTools.UnitTestFramework (in Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll)

public class PrivateObject

The PrivateObject type exposes the following members.

  NameDescription
Public methodPrivateObject(Object)Initializes a new instance of the PrivateObject class that creates the wrapper for the specified object.
Public methodPrivateObject(Object, PrivateType)Initializes a new instance of the PrivateObject class that creates the wrapper for the specified object.
Public methodPrivateObject(Object, String)Initializes a new instance of the PrivateObject class that creates the wrapper for the specified object.
Public methodPrivateObject(Type, Object[])Initializes a new instance of the PrivateObject class that creates the wrapper for the specified object.
Public methodPrivateObject(String, String, Object[])Initializes a new instance of the PrivateObject class. This creates the object of the specified type and wraps it in the private object.
Public methodPrivateObject(Type, Type[], Object[])Initializes a new instance of the PrivateObject class.
Public methodPrivateObject(String, String, Type[], Object[])Initializes a new instance of the PrivateObject class. This creates an object of the specified type and wraps it in the private object.
Top

  NameDescription
Public propertyRealTypeGets the type of the underlying object.
Public propertyTargetGets or sets the wrapped object.
Top

  NameDescription
Public methodEqualsReturns a value that indicates whether two private objects are encapsulating the same target object. (Overrides Object.Equals(Object).)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetArrayElement(String, Int32[])Gets the array element by using an array of subscripts for each dimension.
Public methodGetArrayElement(String, BindingFlags, Int32[])Gets the array element by using an array of subscripts for each dimension.
Public methodGetField(String)Gets a value from a named field, based on the name.
Public methodGetField(String, BindingFlags)Gets a value from a named field, based on the name and lookup mask.
Public methodGetFieldOrProperty(String)Gets a value of a wrapped field or property based on the name.
Public methodGetFieldOrProperty(String, BindingFlags)Gets a value of a wrapped field or property based on the name.
Public methodGetHashCodeGets the hash code of the wrapped object. (Overrides Object.GetHashCode().)
Public methodGetProperty(String, Object[])Gets a property for a wrapped object identified by name.
Public methodGetProperty(String, BindingFlags, Object[])Gets a property for a wrapped object identified by name with binding flags.
Public methodGetProperty(String, Type[], Object[])Gets a property for a wrapped object identified by name.
Public methodGetProperty(String, BindingFlags, Type[], Object[])Gets an indexed property for a wrapped object identified by name.
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodInvoke(String, Object[])Used to access the members of the private object.
Public methodInvoke(String, Object[], CultureInfo)Used to access the members of the private object.
Public methodInvoke(String, BindingFlags, Object[])Used to access the members of the private object.
Public methodInvoke(String, Type[], Object[])Used to access the methods of the private object.
Public methodInvoke(String, BindingFlags, Object[], CultureInfo)Used to access the members of the private object.
Public methodInvoke(String, BindingFlags, Type[], Object[])Used to access the members of the private object.
Public methodInvoke(String, Type[], Object[], CultureInfo)Used to access the members of the private object.
Public methodInvoke(String, Type[], Object[], Type[])Used to access generic members of a private object.
Public methodInvoke(String, BindingFlags, Type[], Object[], CultureInfo)Used to access the members of the private object.
Public methodInvoke(String, BindingFlags, Type[], Object[], CultureInfo, Type[])Used to access generic members of a private object.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodSetArrayElement(String, Object, Int32[])Sets the array element by using an array of subscripts for each dimension.
Public methodSetArrayElement(String, BindingFlags, Object, Int32[])Sets the array element by using an array of subscripts for each dimension.
Public methodSetField(String, Object)Sets a value for the field of the wrapped object, identified by name.
Public methodSetField(String, BindingFlags, Object)Sets a value for the field of the wrapped object, identified by name.
Public methodSetFieldOrProperty(String, Object)Sets a value of a wrapped field or property based on the name.
Public methodSetFieldOrProperty(String, BindingFlags, Object)Sets a value of a wrapped field or property based on the name.
Public methodSetProperty(String, Object, Object[])Sets a property for a wrapped object identified by name.
Public methodSetProperty(String, BindingFlags, Object, Object[])Sets a property for a wrapped object identified by name with binding flags.
Public methodSetProperty(String, Type[], Object, Object[])Sets an indexed property for a wrapped object identified by name.
Public methodSetProperty(String, BindingFlags, Object, Type[], Object[])Sets an indexed property for a wrapped object identified by name.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

The test generator creates most of the calls to these objects. The test generator creates code to wrap the private objects in a wrapper that allows access to the private object's members.

For a list of initial property values for an instance of the PrivateObject class, see the PrivateObject constructor.

This class represents the live non-public internal object in the system.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft