Click to Rate and Give Feedback
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
Team Test API
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)
Visual Basic (Declaration)
<SerializableAttribute> _
Public Class LoadTestUserContext _
    Implements IDictionary(Of String, Object),  _
    ICollection(Of KeyValuePair(Of String, Object)), IEnumerable(Of KeyValuePair(Of String, Object)),  _
    IEnumerable
Visual Basic (Usage)
Dim instance As LoadTestUserContext
C#
[SerializableAttribute]
public class LoadTestUserContext : IDictionary<string, Object>, 
    ICollection<KeyValuePair<string, Object>>, IEnumerable<KeyValuePair<string, Object>>, 
    IEnumerable
Visual C++
[SerializableAttribute]
public ref class LoadTestUserContext : IDictionary<String^, Object^>, 
    ICollection<KeyValuePair<String^, Object^>>, IEnumerable<KeyValuePair<String^, Object^>>, 
    IEnumerable
JScript
public class LoadTestUserContext implements IDictionary<String, Object>, ICollection<KeyValuePair<String, Object>>, IEnumerable<KeyValuePair<String, Object>>, IEnumerable

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

The code for a unit test that is running in the context of a load test can get a reference to the LoadTestUserContext for the virtual user that is running the unit test by using the key "$LoadTestUserContext" when accessing 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 is running outside the context of a load test, the LoadTestUserContext returned by the preceding code is nullNothingnullptra null reference (Nothing in Visual Basic).

System..::.Object
  Microsoft.VisualStudio.TestTools.LoadTesting..::.LoadTestUserContext
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker