Classe PostWebTestEventArgs
Fornisce dati per l'evento WebTest.PostWebTest.
Gerarchia di ereditarietà
Object
EventArgs
Microsoft.VisualStudio.TestTools.WebTesting.PostWebTestEventArgs
Spazio dei nomi: Microsoft.VisualStudio.TestTools.WebTesting
Assembly: Microsoft.VisualStudio.QualityTools.WebTestFramework (in Microsoft.VisualStudio.QualityTools.WebTestFramework.dll)
Sintassi
'Dichiarazione
Public Class PostWebTestEventArgs _
Inherits EventArgs
public class PostWebTestEventArgs : EventArgs
public ref class PostWebTestEventArgs : public EventArgs
type PostWebTestEventArgs =
class
inherit EventArgs
end
public class PostWebTestEventArgs extends EventArgs
Il tipo PostWebTestEventArgs espone i seguenti membri.
Proprietà
Nome | Descrizione | |
---|---|---|
WebTest | Ottiene l'oggetto WebTest che ha completato e causato l'evento PostWebTest. |
In alto
Metodi
Nome | Descrizione | |
---|---|---|
Equals | Determina se l'oggetto specificato è uguale all'oggetto corrente. (Ereditato da Object) | |
Finalize | Consente a un oggetto di effettuare un tentativo di liberare risorse ed eseguire altre operazioni di pulizia prima che venga recuperato da Garbage Collection. (Ereditato da Object) | |
GetHashCode | Funge da funzione hash predefinita. (Ereditato da Object) | |
GetType | Ottiene l'oggetto Type dell'istanza corrente. (Ereditato da Object) | |
MemberwiseClone | Crea una copia superficiale dell'oggetto Object corrente. (Ereditato da Object) | |
ToString | Restituisce una stringa che rappresenta l'oggetto corrente. (Ereditato da Object) |
In alto
Note
Fornisce in modo specifico un riferimento alla classe WebTest che ha richiamato l'evento PostWebTest.
Esempi
Nell'esempio riportato di seguito viene illustrato un plug-in del test delle prestazioni Web che aggiunge un numero casuale al contesto prima dell'esecuzione del test delle prestazioni Web e visualizza la lunghezza dell'ultimo oggetto WebTestResponse al termine dell'esecuzione del test delle prestazioni Web.
Si noti l'utilizzo della classe PostWebTestEventArgs nel fornire un riferimento alla classe WebTest.
using System;
using Microsoft.VisualStudio.TestTools.WebTesting;
using System.Windows.Forms;
namespace WebTestPluginNamespace
{
public class MyWebTestPlugin : WebTestPlugin
{
public static string NewRandomNumberString(int size)
{
byte[] buffer = new byte[size];
// Seed using system time
Random random = new Random(unchecked((int)DateTime.Now.Ticks));
random.NextBytes(buffer);
return BitConverter.ToInt32(buffer, 0).ToString();
}
public override void PreWebTest(object sender, PreWebTestEventArgs e)
{
e.WebTest.Context["RandNum"] = NewRandomNumberString(4);
}
public override void PostWebTest(object sender, PostWebTestEventArgs e)
{
MessageBox.Show(e.WebTest.LastResponse.ContentLength.ToString());
}
}
}
Codice thread safe
Qualsiasi membro static (Shared in Visual Basic) pubblico di questo tipo è thread-safe. I membri di istanza non sono garantiti come thread-safe.
Vedere anche
Riferimenti
Spazio dei nomi Microsoft.VisualStudio.TestTools.WebTesting