LoadTestUserContext 类
封装有关运行负载测试的用户上下文的信息。
继承层次结构
Object
MarshalByRefObject
Microsoft.VisualStudio.TestTools.LoadTesting.LoadTestUserContext
命名空间: Microsoft.VisualStudio.TestTools.LoadTesting
程序集: Microsoft.VisualStudio.QualityTools.LoadTestFramework(在 Microsoft.VisualStudio.QualityTools.LoadTestFramework.dll 中)
语法
声明
<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
LoadTestUserContext 类型公开以下成员。
属性
名称 | 说明 | |
---|---|---|
![]() |
CompletedTestCount | 获取或设置 LoadTestUserContext 对象表示的虚拟用户自负载测试开始以来已完成的测试数目。 |
![]() |
Count | 获取 LoadTestUserContext 对象中包含的元素数。 |
![]() |
InitializeTestContext | 获取或设置与 LoadTestUserContext 对象关联的虚拟用户在 InitializeTest 已完成时的用户上下文的状态。 |
![]() |
IsNewUser | 获取一个值,该值指示是否是新创建的虚拟用户在运行当前测试。 |
![]() |
IsReadOnly | 获取一个值,该值指示 LoadTestUserContext 是否为只读。 |
![]() |
Item | 获取或设置具有指定键的一个 LoadTestUserContext 元素。 |
![]() |
Keys | 获取一个 ICollection,其中包含 LoadTestUserContext 元素的键。 |
![]() |
ScenarioName | 获取或设置负载测试方案的名称,该方案创建由此 LoadTestUserContext 表示的虚拟用户。 |
![]() |
UserId | 获取负载测试方案中的用户的 UserId。 |
![]() |
Values | 获取一个 ICollection,其中包含 LoadTestUserContext 元素中的值。 |
页首
方法
名称 | 说明 | |
---|---|---|
![]() |
Add(KeyValuePair<String, Object>) | 将 KeyValuePair 项添加到 LoadTestUserContext。 |
![]() |
Add(String, Object) | 将具有所提供键和值的元素添加到 LoadTestUserContext。 |
![]() |
Clear | 从 LoadTestUserContext 中移除所有项。 |
![]() |
Contains | 确定 LoadTestUserContext 是否包含特定值。 |
![]() |
ContainsKey | 指示 LoadTestUserContext 是否包含具有指定键的元素。 |
![]() |
CopyTo | 从特定的 LoadTestUserContext 索引处开始,将 Array 的元素复制到一个 Array 中。 |
![]() |
CreateObjRef | 创建一个对象,该对象包含生成用于与远程对象进行通信的代理所需的全部相关信息。 (继承自 MarshalByRefObject。) |
![]() |
Equals | 确定指定的对象是否等于当前对象。 (继承自 Object。) |
![]() |
Finalize | 在垃圾回收将某一对象回收前允许该对象尝试释放资源并执行其他清理操作。 (继承自 Object。) |
![]() |
GetEnumerator | 返回循环访问 LoadTestUserContext 的枚举数。 |
![]() |
GetHashCode | 作为默认哈希函数。 (继承自 Object。) |
![]() |
GetLifetimeService | 检索控制此实例的生存期策略的当前生存期服务对象。 (继承自 MarshalByRefObject。) |
![]() |
GetType | 获取当前实例的 Type。 (继承自 Object。) |
![]() |
InitializeLifetimeService | 获取控制此实例的生存期策略的生存期服务对象。 (继承自 MarshalByRefObject。) |
![]() |
MemberwiseClone | 创建当前 Object 的浅表副本。 (继承自 Object。) |
![]() |
MemberwiseClone(Boolean) | 创建当前 MarshalByRefObject 对象的浅表副本。 (继承自 MarshalByRefObject。) |
![]() |
Remove(KeyValuePair<String, Object>) | 从 LoadTestUserContext 中移除特定对象的第一个匹配项。 |
![]() |
Remove(String) | 返回一个值,该值指示是否必须从 LoadTestUserContext 对象中移除特定对象的第一个匹配项。 |
![]() |
ToString | 返回表示当前对象的字符串。 (继承自 Object。) |
![]() |
TryGetValue | 获取与指定的键关联的值。 |
页首
字段
名称 | 说明 | |
---|---|---|
![]() ![]() |
LoadTestUserContextKey | 表示 LoadTestUserContext 中的键。 |
页首
显式接口实现
名称 | 说明 | |
---|---|---|
![]() ![]() |
IEnumerable.GetEnumerator | 返回一个循环访问 LoadTestUserContext 元素集合的枚举器。 |
页首
备注
LoadTestUserContext 封装有关运行负载测试的用户上下文的信息。
示例
在负载测试上下文中运行的单元测试的代码在用户访问 TestContext 属性时,可以使用键“$LoadTestUserContext”获取对运行此单元测试的虚拟用户的 LoadTestUserContext 的引用。
例如:
LoadTestUserContext loadTestUserContext =
this.TestContext.Properties["$LoadTestUserContext"]
as LoadTestUserContext;
同样,编码的 Web 测试也可以通过如下方式访问 LoadTestUserContext:
LoadTestUserContext loadTestUserContext =
this.Context["$LoadTestUserContext"] as LoadTestUserContext;
当单元测试或 Web 测试在负载测试的上下文外部运行时,上面的代码返回的 LoadTestUserContext 为 nullnull 引用(在 Visual Basic 中为 Nothing)。
线程安全
此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。