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.

LoadTestUserContext Class

 

Encapsulates information about the user context in which a test is running, in a load test.

Namespace:   Microsoft.VisualStudio.TestTools.LoadTesting
Assembly:  Microsoft.VisualStudio.QualityTools.LoadTestFramework (in Microsoft.VisualStudio.QualityTools.LoadTestFramework.dll)

System.Object
  System.MarshalByRefObject
    Microsoft.VisualStudio.TestTools.LoadTesting.LoadTestUserContext

[SerializableAttribute]
public class LoadTestUserContext : MarshalByRefObject, IDictionary<stringobject>, 
	ICollection<KeyValuePair<stringobject>>, IEnumerable<KeyValuePair<stringobject>>, 
	IEnumerable

NameDescription
System_CAPS_pubpropertyCompletedTestCount

Gets or sets the number of tests that have been completed by the virtual user that is represented by the LoadTestUserContext object since the start of the load test.

System_CAPS_pubpropertyCount

Gets the number of elements that are contained in the LoadTestUserContext object.

System_CAPS_pubpropertyInitializeTestContext

Gets or sets the state of the user context at the time InitializeTest was completed for the virtual user that is associated with the LoadTestUserContext object.

System_CAPS_pubpropertyIsNewUser

Gets a value that indicates whether a newly created virtual user is running the current test.

System_CAPS_pubpropertyIsReadOnly

Gets a value that indicates whether LoadTestUserContext is read-only.

System_CAPS_pubpropertyItem[String]

Gets or sets a LoadTestUserContext element that has the specified key.

System_CAPS_pubpropertyKeys

Gets an ICollection that contains the keys of the LoadTestUserContext elements.

System_CAPS_pubpropertyScenarioName

Gets or sets the name of the load test scenario that created the virtual user that is represented by this LoadTestUserContext.

System_CAPS_pubpropertyUserId

Gets the UserId of the user in the load test scenario.

System_CAPS_pubpropertyValues

Gets an ICollection that contains the values in the LoadTestUserContext elements.

NameDescription
System_CAPS_pubmethodAdd(KeyValuePair<String, Object>)

Adds a KeyValuePair<TKey, TValue> item to the LoadTestUserContext.

System_CAPS_pubmethodAdd(String, Object)

Adds an element that has the provided key and value to the LoadTestUserContext.

System_CAPS_pubmethodClear()

Removes all items from the LoadTestUserContext.

System_CAPS_pubmethodContains(KeyValuePair<String, Object>)

Determines whether the LoadTestUserContext contains a specific value.

System_CAPS_pubmethodContainsKey(String)

Indicates whether the LoadTestUserContext contains an element that has the specified key.

System_CAPS_pubmethodCopyTo(KeyValuePair<String, Object>[], Int32)

Copies the elements of the LoadTestUserContext to an Array, starting at a particular Array index.

System_CAPS_pubmethodCreateObjRef(Type)

(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodEquals(Object)

(Inherited from Object.)

System_CAPS_protmethodFinalize()

(Inherited from Object.)

System_CAPS_pubmethodGetEnumerator()

Returns an enumerator that iterates through the LoadTestUserContext.

System_CAPS_pubmethodGetHashCode()

(Inherited from Object.)

System_CAPS_pubmethodGetLifetimeService()

(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodGetType()

(Inherited from Object.)

System_CAPS_pubmethodInitializeLifetimeService()

(Inherited from MarshalByRefObject.)

System_CAPS_protmethodMemberwiseClone()

(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone(Boolean)

(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodRemove(KeyValuePair<String, Object>)

Removes the first occurrence of a specific object from the LoadTestUserContext.

System_CAPS_pubmethodRemove(String)

Returns a value that indicates whether the first occurrence of a specific object must be moved from the LoadTestUserContext object.

System_CAPS_pubmethodToString()

(Inherited from Object.)

System_CAPS_pubmethodTryGetValue(String, Object)

Gets the value that is associated with the specified key.

NameDescription
System_CAPS_pubfieldSystem_CAPS_staticLoadTestUserContextKey

Represents a key in LoadTestUserContext.

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodIEnumerable.GetEnumerator()

Returns an enumerator that iterates through a collection of LoadTestUserContext elements.

LoadTestUserContext encapsulates information about the user context in which a test is running in a load test.

Legacy Code Example

The code for a unit test that runs in the context of a load test can obtain a reference to the LoadTestUserContext for the virtual user that runs the unit test by using the key "$LoadTestUserContext" when the user accesses the TestContext properties.

For example:

LoadTestUserContext loadTestUserContext = 
    this.TestContext.Properties["$LoadTestUserContext"] 
    as LoadTestUserContext;

Similarly, a coded Web test can access the LoadTestUserContext as follows:

LoadTestUserContext loadTestUserContext = 
    this.Context["$LoadTestUserContext"] as LoadTestUserContext;

When the unit test or Web test runs outside the context of a load test, the LoadTestUserContext that is returned by the preceding code is null.

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: