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 | 從特定的 Array 索引開始,將 LoadTestUserContext 的項目複製至 Array。 |
![]() |
CreateObjRef | 建立包含所有相關資訊的物件,這些資訊是產生用來與遠端物件通訊的所需 Proxy。 (繼承自 MarshalByRefObject)。 |
![]() |
Equals | 判斷指定的物件是否等於目前的物件。 (繼承自 Object)。 |
![]() |
Finalize | 在記憶體回收開始前,允許物件嘗試釋放資源,並執行其他清除作業。 (繼承自 Object)。 |
![]() |
GetEnumerator | 傳回在 LoadTestUserContext 中逐一查看的列舉值。 |
![]() |
GetHashCode | 做為預設雜湊函式。 (繼承自 Object)。 |
![]() |
GetLifetimeService | 擷取控制這個執行個體存留期 (Lifetime) 原則的目前存留期服務物件。 (繼承自 MarshalByRefObject)。 |
![]() |
GetType | 取得目前實例 Type 的屬性。 (繼承自 Object)。 |
![]() |
InitializeLifetimeService | 取得存留期服務物件來控制這個執行個體的存留期原則。 (繼承自 MarshalByRefObject)。 |
![]() |
MemberwiseClone | 建立目前 Object 的淺層複製 (Shallow Copy) 。 (繼承自 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)。
執行緒安全
這個類型的任何 Public static (在 Visual Basic 中為 Shared) 成員都是安全執行緒。不保證任何執行個體成員是安全執行緒。