Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

PrivateObject Class

 

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

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

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

No code example is currently available or this language may not be supported.

NameDescription
System_CAPS_pubmethodPrivateObject(Object)

Initializes a new instance of the PrivateObject class that creates the wrapper for the specified object.

System_CAPS_pubmethodPrivateObject(Object, PrivateType)

Initializes a new instance of the PrivateObject class that creates the wrapper for the specified object.

System_CAPS_pubmethodPrivateObject(Object, String)

Initializes a new instance of the PrivateObject class that creates the wrapper for the specified object.

System_CAPS_pubmethodPrivateObject(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.

System_CAPS_pubmethodPrivateObject(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.

System_CAPS_pubmethodPrivateObject(Type, Object[])

Initializes a new instance of the PrivateObject class that creates the wrapper for the specified object.

System_CAPS_pubmethodPrivateObject(Type, Type[], Object[])

Initializes a new instance of the PrivateObject class.

NameDescription
System_CAPS_pubpropertyRealType

Gets the type of the underlying object.

System_CAPS_pubpropertyTarget

Gets or sets the wrapped object.

NameDescription
System_CAPS_pubmethodEquals(Object)

Returns a value that indicates whether two private objects are encapsulating the same target object.(Overrides Object.Equals(Object).)

System_CAPS_protmethodFinalize()

(Inherited from Object.)

System_CAPS_pubmethodGetArrayElement(String, BindingFlags, Int32[])

Gets the array element by using an array of subscripts for each dimension.

System_CAPS_pubmethodGetArrayElement(String, Int32[])

Gets the array element by using an array of subscripts for each dimension.

System_CAPS_pubmethodGetField(String)

Gets a value from a named field, based on the name.

System_CAPS_pubmethodGetField(String, BindingFlags)

Gets a value from a named field, based on the name and lookup mask.

System_CAPS_pubmethodGetFieldOrProperty(String)

Gets a value of a wrapped field or property based on the name.

System_CAPS_pubmethodGetFieldOrProperty(String, BindingFlags)

Gets a value of a wrapped field or property based on the name.

System_CAPS_pubmethodGetHashCode()

Gets the hash code of the wrapped object.(Overrides Object.GetHashCode().)

System_CAPS_pubmethodGetProperty(String, BindingFlags, Object[])

Gets a property for a wrapped object identified by name with binding flags.

System_CAPS_pubmethodGetProperty(String, BindingFlags, Type[], Object[])

Gets an indexed property for a wrapped object identified by name.

System_CAPS_pubmethodGetProperty(String, Object[])

Gets a property for a wrapped object identified by name.

System_CAPS_pubmethodGetProperty(String, Type[], Object[])

Gets a property for a wrapped object identified by name.

System_CAPS_pubmethodGetType()

(Inherited from Object.)

System_CAPS_pubmethodInvoke(String, BindingFlags, Object[])

Used to access the members of the private object.

System_CAPS_pubmethodInvoke(String, BindingFlags, Object[], CultureInfo)

Used to access the members of the private object.

System_CAPS_pubmethodInvoke(String, BindingFlags, Type[], Object[])

Used to access the members of the private object.

System_CAPS_pubmethodInvoke(String, BindingFlags, Type[], Object[], CultureInfo)

Used to access the members of the private object.

System_CAPS_pubmethodInvoke(String, BindingFlags, Type[], Object[], CultureInfo, Type[])

Used to access generic members of a private object.

System_CAPS_pubmethodInvoke(String, Object[])

Used to access the members of the private object.

System_CAPS_pubmethodInvoke(String, Object[], CultureInfo)

Used to access the members of the private object.

System_CAPS_pubmethodInvoke(String, Type[], Object[])

Used to access the methods of the private object.

System_CAPS_pubmethodInvoke(String, Type[], Object[], CultureInfo)

Used to access the members of the private object.

System_CAPS_pubmethodInvoke(String, Type[], Object[], Type[])

Used to access generic members of a private object.

System_CAPS_protmethodMemberwiseClone()

(Inherited from Object.)

System_CAPS_pubmethodSetArrayElement(String, BindingFlags, Object, Int32[])

Sets the array element by using an array of subscripts for each dimension.

System_CAPS_pubmethodSetArrayElement(String, Object, Int32[])

Sets the array element by using an array of subscripts for each dimension.

System_CAPS_pubmethodSetField(String, BindingFlags, Object)

Sets a value for the field of the wrapped object, identified by name.

System_CAPS_pubmethodSetField(String, Object)

Sets a value for the field of the wrapped object, identified by name.

System_CAPS_pubmethodSetFieldOrProperty(String, BindingFlags, Object)

Sets a value of a wrapped field or property based on the name.

System_CAPS_pubmethodSetFieldOrProperty(String, Object)

Sets a value of a wrapped field or property based on the name.

System_CAPS_pubmethodSetProperty(String, BindingFlags, Object, Object[])

Sets a property for a wrapped object identified by name with binding flags.

System_CAPS_pubmethodSetProperty(String, BindingFlags, Object, Type[], Object[])

Sets an indexed property for a wrapped object identified by name.

System_CAPS_pubmethodSetProperty(String, Object, Object[])

Sets a property for a wrapped object identified by name.

System_CAPS_pubmethodSetProperty(String, Type[], Object, Object[])

Sets an indexed property for a wrapped object identified by name.

System_CAPS_pubmethodToString()

(Inherited from Object.)

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.

ReflectionPermission

The user must have the TypeInformation and MemberAccess flags set to use this type.

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

Return to top
Show: