LoadTestUserContext Class
Encapsulates information about the user context in which a test is running, in a load test.
Assembly: Microsoft.VisualStudio.QualityTools.LoadTestFramework (in Microsoft.VisualStudio.QualityTools.LoadTestFramework.dll)
System::MarshalByRefObject
Microsoft.VisualStudio.TestTools.LoadTesting::LoadTestUserContext
| Name | Description | |
|---|---|---|
![]() | CompletedTestCount | 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. |
![]() | Count | Gets the number of elements that are contained in the LoadTestUserContext object. |
![]() | InitializeTestContext | 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. |
![]() | IsNewUser | Gets a value that indicates whether a newly created virtual user is running the current test. |
![]() | IsReadOnly | Gets a value that indicates whether LoadTestUserContext is read-only. |
![]() | Item[String^] | Gets or sets a LoadTestUserContext element that has the specified key. |
![]() | Keys | Gets an ICollection that contains the keys of the LoadTestUserContext elements. |
![]() | ScenarioName | Gets or sets the name of the load test scenario that created the virtual user that is represented by this LoadTestUserContext. |
![]() | UserId | Gets the UserId of the user in the load test scenario. |
![]() | Values | Gets an ICollection that contains the values in the LoadTestUserContext elements. |
| Name | Description | |
|---|---|---|
![]() | Add(KeyValuePair<String^, Object^>) | Adds a KeyValuePair<TKey, TValue> item to the LoadTestUserContext. |
![]() | Add(String^, Object^) | Adds an element that has the provided key and value to the LoadTestUserContext. |
![]() | Clear() | Removes all items from the LoadTestUserContext. |
![]() | Contains(KeyValuePair<String^, Object^>) | Determines whether the LoadTestUserContext contains a specific value. |
![]() | ContainsKey(String^) | Indicates whether the LoadTestUserContext contains an element that has the specified key. |
![]() | CopyTo(array<KeyValuePair<String^, Object^>>^, Int32) | Copies the elements of the LoadTestUserContext to an Array, starting at a particular Array index. |
![]() | CreateObjRef(Type^) | (Inherited from MarshalByRefObject.) |
![]() | Equals(Object^) | (Inherited from Object.) |
![]() | Finalize() | (Inherited from Object.) |
![]() | GetEnumerator() | Returns an enumerator that iterates through the LoadTestUserContext. |
![]() | GetHashCode() | (Inherited from Object.) |
![]() | GetLifetimeService() | (Inherited from MarshalByRefObject.) |
![]() | GetType() | (Inherited from Object.) |
![]() | InitializeLifetimeService() | (Inherited from MarshalByRefObject.) |
![]() | MemberwiseClone() | (Inherited from Object.) |
![]() | MemberwiseClone(Boolean) | (Inherited from MarshalByRefObject.) |
![]() | Remove(KeyValuePair<String^, Object^>) | Removes the first occurrence of a specific object from the LoadTestUserContext. |
![]() | Remove(String^) | Returns a value that indicates whether the first occurrence of a specific object must be moved from the LoadTestUserContext object. |
![]() | ToString() | (Inherited from Object.) |
![]() | TryGetValue(String^, Object^) | Gets the value that is associated with the specified key. |
| Name | Description | |
|---|---|---|
![]() ![]() | LoadTestUserContextKey | Represents a key in LoadTestUserContext. |
| Name | Description | |
|---|---|---|
![]() ![]() | IEnumerable::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.






