LoadTestUserContext Class
Encapsulates information about the user context in which a test is running, in a load test.
Inheritance Hierarchy
Object
MarshalByRefObject
Microsoft.VisualStudio.TestTools.LoadTesting.LoadTestUserContext
Namespace: Microsoft.VisualStudio.TestTools.LoadTesting
Assembly: Microsoft.VisualStudio.QualityTools.LoadTestFramework (in Microsoft.VisualStudio.QualityTools.LoadTestFramework.dll)
Syntax
'Declaration
<SerializableAttribute> _
Public Class LoadTestUserContext _
Inherits MarshalByRefObject _
Implements IDictionary(Of String, Object), _
ICollection(Of KeyValuePair(Of String, Object)), IEnumerable(Of KeyValuePair(Of String, Object)), _
IEnumerable
[SerializableAttribute]
public class LoadTestUserContext : MarshalByRefObject,
IDictionary<string, Object>, ICollection<KeyValuePair<string, Object>>,
IEnumerable<KeyValuePair<string, Object>>, IEnumerable
[SerializableAttribute]
public ref class LoadTestUserContext : public MarshalByRefObject,
IDictionary<String^, Object^>, ICollection<KeyValuePair<String^, Object^>>,
IEnumerable<KeyValuePair<String^, Object^>>, IEnumerable
[<SerializableAttribute>]
type LoadTestUserContext =
class
inherit MarshalByRefObject
interface IDictionary<string, Object>
interface ICollection<KeyValuePair<string, Object>>
interface IEnumerable<KeyValuePair<string, Object>>
interface IEnumerable
end
public class LoadTestUserContext extends MarshalByRefObject implements IDictionary<String, Object>, ICollection<KeyValuePair<String, Object>>, IEnumerable<KeyValuePair<String, Object>>, IEnumerable
The LoadTestUserContext type exposes the following members.
Properties
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 | 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. |
Top
Methods
Name | Description | |
---|---|---|
Add(KeyValuePair<String, Object>) | Adds a KeyValuePair 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 | Determines whether the LoadTestUserContext contains a specific value. | |
ContainsKey | Indicates whether the LoadTestUserContext contains an element that has the specified key. | |
CopyTo | Copies the elements of the LoadTestUserContext to an Array, starting at a particular Array index. | |
CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.) | |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetEnumerator | Returns an enumerator that iterates through the LoadTestUserContext. | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
MemberwiseClone(Boolean) | Creates a shallow copy of the current MarshalByRefObject object. (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 | Returns a string that represents the current object. (Inherited from Object.) | |
TryGetValue | Gets the value that is associated with the specified key. |
Top
Fields
Name | Description | |
---|---|---|
LoadTestUserContextKey | Represents a key in LoadTestUserContext. |
Top
Explicit Interface Implementations
Name | Description | |
---|---|---|
IEnumerable.GetEnumerator | Returns an enumerator that iterates through a collection of LoadTestUserContext elements. |
Top
Remarks
LoadTestUserContext encapsulates information about the user context in which a test is running in a load test.
Examples
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 nulla null reference (Nothing in Visual Basic).
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.